Qwen 3 Has MCP Server Support and Here's How to Use It

Discover how Qwen 3 leverages MCP server support in this tutorial! Use Qwen 3 with MCP to query SQLite databases and build smarter AI agents.

Ashley Goolam

Ashley Goolam

1 May 2025

Qwen 3 Has MCP Server Support and Here's How to Use It

If you’re excited about Qwen 3 and its shiny MCP (Model-Context-Protocol) support, you’re in for a treat! I recently dug into Qwen 3’s capabilities on my windows computer, and let me tell you—it’s a game-changer for building AI agents that interact with tools like SQLite databases. In this tutorial, we’ll explore how Qwen 3 leverages MCP to make your coding life easier, with a hands-on example of querying a database. We’ll also touch on Qwen 3’s impressive benchmarks and show you how to use OpenRouter and Roo Code to get started quickly. Ready to make Qwen 3 and MCP your new besties? Let’s dive in!

💡
Before we start, a quick shoutout to Apidog—a fantastic tool for API lovers! It simplifies designing, testing, and documenting APIs, which is perfect for managing Qwen 3 integrations. Check it out at apidog.com—it’s a lifesaver! Now, let’s get to the good stuff…
button

What is Qwen 3 with MCP Support?

Qwen 3 is the latest large language model series from Alibaba Cloud’s Qwen team, released in late April 2025. It’s a powerhouse with models ranging from 0.6B to 235B parameters, including dense and Mixture-of-Experts (MoE) variants like Qwen3-235B-A22B (22B active parameters). According to qwen3.org, Qwen 3 competes with top models like DeepSeek-R1, OpenAI’s o1, o3-mini, Grok-3, and Gemini-2.5-Pro in coding, math, and general tasks. Its smaller MoE model, Qwen3-30B-A3B, even outshines QwQ-32B despite having 10 times fewer active parameters—pretty impressive, right?

Qwen 3

What makes Qwen 3 extra cool is its MCP support, which lets it seamlessly interact with external tools like SQLite databases, memory, and file systems. MCP (Model-Context-Protocol) allows Qwen 3 to call server-based tools, enabling agentic workflows where the model can fetch data, run commands, and more. Posts on X are buzzing about this feature, with users noting its optimization for advanced function calling and agent capabilities. Let’s set it up and see it in action with a database query example!

Setting Up Your Environment to Work with Qwen 3: The Basics

Let’s get your system ready to use Qwen 3 with MCP. Don’t worry—I’ll break it down step-by-step so you’re never lost.

Check Prerequisites: Make sure you have these tools installed:

Create a Project Folder: Let’s keep things tidy:

mkdir qwen3-mcp
cd qwen3-mcp

This folder will be your workspace for Qwen 3 and MCP magic.

Set Up a Virtual Environment: To avoid dependency conflicts, create a Python virtual environment:

python -m venv venv

Activate it:

The (venv) prompt in your terminal means you’re ready to roll.

Installing Qwen-Agent for MCP Support

Qwen 3 uses the Qwen-Agent framework to enable MCP support, as noted on GitHub. Let’s install it and set up the dependencies for our SQLite example.

Qwen 3 Agent

Install Qwen-Agent with MCP Support:

pip install -U "qwen-agent[gui,rag,code_interpreter,mcp]"

This command installs Qwen-Agent with all optional dependencies, including [mcp] for MCP support, [gui] for web UI, [rag] for retrieval-augmented generation, and [code_interpreter] for running code.

Verify Installation: Ensure Qwen-Agent installed correctly by running:

python -c "import qwen_agent; print(qwen_agent.__version__)"

If you see a version number (e.g., 0.1.0), you’re good to go. If not, reinstall or check your Python environment.

Configuring Qwen 3 with MCP Server

Now, let’s configure Qwen 3 to work with an MCP server for tool calling. We’ll use the SQLite example from the Qwen-Agent GitHub repo to query a database.

Set Up the MCP Server for SQLite:

The example uses an MCP server to handle SQLite database interactions. First, create a test database (test.db) if you don’t have one:

sqlite3 test.db "CREATE TABLE example (id INTEGER PRIMARY KEY, name TEXT); INSERT INTO example (name) VALUES ('Alice'), ('Bob');"

Now, start the MCP SQLite server:

uvx mcp-server-sqlite --db-path test.db

This runs the SQLite MCP server, allowing Qwen 3 to query test.db. Keep this terminal running.

Configure Qwen 3 in Your Code:

Let’s write a Python script to use Qwen 3 with the MCP server, based on the assistant_mcp_sqlite_bot.py example. Create a file named qwen3_mcp_sqlite.py:

import os
from qwen_agent.agents import Assistant
from qwen_agent.gui import WebUI

# Define the agent with Qwen 3 and MCP configuration
def init_agent_service():
    llm_cfg = {
        'model': 'qwen3-32b',  # Use Qwen 3 model
        'model_type': 'qwen_dashscope',
        'api_key': os.getenv('DASHSCOPE_API_KEY'),
    }
    tools = [{
        'mcpServers': {
            'sqlite': {
                'command': 'uvx',
                'args': ['mcp-server-sqlite', '--db-path', 'test.db']
            }
        }
    }]
    bot = Assistant(
        llm=llm_cfg,
        function_list=tools,
        name='MCP-SQLite-Bot',
        description='This bot can answer questions by SQLite database'
    )
    return bot

# Test the agent with a query
def test(query='How many tables are in the database?'):
    bot = init_agent_service()
    messages = [{'role': 'user', 'content': query}]
    for response in bot.run(messages=messages):
        print(response)

# Run a web UI for interactive testing
def app_gui():
    bot = init_agent_service()
    WebUI(bot).run()

if __name__ == '__main__':
    test()
    # Uncomment to run the web UI
    # app_gui()

This script sets up Qwen 3 (specifically qwen3-32b) to work with an MCP SQLite server. It defines a bot that can query the database and includes a web UI option for interactive testing.

Set the DashScope API Key:

The script uses Alibaba Cloud’s DashScope service for Qwen 3. You’ll need a DashScope API key:

export DASHSCOPE_API_KEY="your-dashscope-api-key"

Add this to your shell profile (e.g., ~/.zshrc) and reload with source ~/.zshrc.

Using OpenRouter and Roo Code for Qwen 3 with MCP

If you don’t want to deal with DashScope, you can use OpenRouter to access Qwen 3 and leverage Roo Code’s pre-configured MCP server. Here’s how:

Get an OpenRouter API Key:

Set Up Roo Code with OpenRouter:

Roo Code is a platform that simplifies AI agent workflows and often comes with pre-configured MCP servers. Assuming you have Roo Code set up:

{
    "model": "qwen3-32b",
    "model_server": "https://openrouter.ai/api/v1",
    "api_key": "your-openrouter-api-key"
}

Run the Same Script with Roo Code:

Modify the llm_cfg in your qwen3_mcp_sqlite.py script to use OpenRouter:

llm_cfg = {
    'model': 'qwen3-32b',
    'model_server': 'https://openrouter.ai/api/v1',
    'api_key': 'your-openrouter-api-key'
}

Run the script as before—Roo Code’s MCP server will handle the SQLite queries, and Qwen 3 will process them via OpenRouter.

Option 2: Configuring Roo Code to Work with OpenRouter:
If you'd prefer not to use a custom script, you can easily set up Roo Code with OpenRouter by following these steps:

  1. Open Roo’s settings.
  2. Change the default provider to OpenRouter.
  3. Select the Qwen 3 model.
RooCode with Qwen 3

Once configured, your existing MCP servers in roo code will seamlessly work with the Qwen 3 model.

Testing Qwen 3 with MCP: Querying a Database

Let’s test Qwen 3 with our MCP setup by querying the SQLite database.

Run the Script:

With the MCP SQLite server running (from step 1 in “Configuring Qwen 3 with MCP Server”), execute your script:

python qwen3_mcp_sqlite.py

The default query (“How many tables are in the database?”) should return a response indicating one table (example), since we created it earlier.

Interactive Testing with Web UI:

Uncomment the app_gui() call in the script and run it again:

if __name__ == '__main__':
    # test()
    app_gui()

This launches a Gradio-based web UI. Open the provided URL (usually http://127.0.0.1:7860) in your browser, type queries like “List all names in the example table,” and Qwen 3 will use the MCP server to fetch results (e.g., “Alice, Bob”).

Understand the Results:

The SQLite example shows how Qwen 3 uses MCP to interact with external tools. The model sends a query to the MCP server, which executes it against test.db and returns the result. This setup is perfect for building agents that need to fetch data dynamically—pretty powerful, huh?

How to Use MCP Servers with Roo Code (within VSCode)
Transform Visual Studio with RooCode and MCP. Learn installation, browser automation, custom tool creation, and pro tips for AI-powered development.
Learn how to get started with RooCode and MCP Servers

Tips for Using Qwen 3 with MCP Effectively

My Takes on Qwen 3 with MCP

After playing with Qwen 3 and MCP, here’s what I think:

If you hit any snags, double-check your API key and ensure the MCP server is running.

Wrapping Up: Your Qwen 3 and MCP Journey

You’ve just unlocked the power of Qwen 3 with MCP support, making your AI agents smarter and more capable! From querying databases to exploring other MCP tools, you’re ready to build amazing things. For more details, feel free to check out the Qwen-Agent GitHub repo or qwen3.org. Keep rocking with Qwen 3 and MCP!

button

Explore more

How to Create Apple's Liquid Glass Effects in React

How to Create Apple's Liquid Glass Effects in React

Apple has always been at the forefront of user interface design, and one of their most captivating recent effects is the "liquid glass" look. This effect, characterized by its fluid, jelly-like appearance, adds a layer of depth and interactivity to UI elements. It's a subtle yet powerful way to make your applications feel more dynamic and engaging. In this article, we'll explore how to recreate this stunning effect in your React applications using the liquid-glass-react library. This library p

14 June 2025

What is Shadcn/UI? Beginner's Tutorial to Get Started

What is Shadcn/UI? Beginner's Tutorial to Get Started

For web developers, the quest for the perfect UI toolkit is a constant endeavor. For years, React developers have relied on traditional component libraries like Material-UI (MUI), Ant Design, and Chakra UI. These libraries offer a wealth of pre-built components, promising to accelerate development. However, they often come with a trade-off: a lack of control, style overrides that feel like a battle, and bloated bundle sizes. Enter Shadcn UI, a paradigm-shifting approach that has taken the React

14 June 2025

10 Best Small Local LLMs to Try Out (< 8GB)

10 Best Small Local LLMs to Try Out (< 8GB)

The world of Large Language Models (LLMs) has exploded, often conjuring images of massive, cloud-bound supercomputers churning out text. But what if you could harness significant AI power right on your personal computer, without constant internet connectivity or hefty cloud subscriptions? The exciting reality is that you can. Thanks to advancements in optimization techniques, a new breed of "small local LLMs" has emerged, delivering remarkable capabilities while fitting comfortably within the me

13 June 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs