Apidog

All-in-one Collaborative API Development Platform

API Design

API Documentation

API Debugging

API Mocking

API Automated Testing

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

Updated on May 1, 2025

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:

  • Python: Version 3.10 or higher. Run python --version in your terminal. If it’s missing, grab it from python.org.
  • Node.js: Needed for some MCP servers. Check with node --version or download from nodejs.org.
  • uv: Version 0.4.18 or higher for running MCP servers. Verify with uv --version. Install via pip install uv if needed.
  • Git: For cloning repos. Check with git --version or install using Homebrew (brew install git on Mac) or winget (winget install git.git on Windows).
  • SQLite: For our example. Confirm with sqlite3 --version or install via Homebrew (brew install sqlite3) or winget (winget install sqlite.sqlite).
  • Hardware: A 4+ core CPU, 16GB+ RAM, and 10GB+ free storage to handle AI processing.

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:

  • Mac/Linux: source venv/bin/activate
  • Windows: venv\Scripts\activate

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:

  • Sign up at dashscope.aliyuncs.com.
  • Navigate to API settings, generate a key, and set it as an environment variable:
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:

  • Visit openrouter.ai and sign up.
  • Go to your account settings, generate an API key, and copy it.

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:

  • Configure your OpenRouter API key in Roo Code’s settings (usually under API integrations).
  • Update the model configuration in Roo Code to use Qwen 3 via OpenRouter:
{
    "model": "qwen3-32b",
    "model_server": "https://openrouter.ai/api/v1",
    "api_key": "your-openrouter-api-key"
}
  • Roo Code typically has an MCP server setup similar to the one in our script. Check its documentation to ensure the SQLite server is running (e.g., uvx mcp-server-sqlite --db-path test.db).

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

  • Keep Queries Simple: For database tasks, use clear prompts like “List all names in the example table” to get accurate results from Qwen 3.
  • Monitor API Usage: Whether using DashScope or OpenRouter, track your API usage to avoid hitting rate limits.
  • Explore More MCP Tools: MCP supports tools like memory and filesystem—check the Qwen-Agent GitHub for more examples.
  • Test Locally First: Use the web UI to test queries interactively before deploying in production.

My Takes on Qwen 3 with MCP

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

  • Seamless Integration: The MCP server setup is straightforward, and Qwen 3 handles tool calls like a champ.
  • Powerful for Agents: Querying databases is just the start—MCP opens up endless possibilities for agent workflows.
  • Performance Boost: Qwen 3’s benchmarks show it’s a top contender, and the MCP support makes it even more versatile.

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
How to Activate Python venv (Beginner's Guide)Viewpoint

How to Activate Python venv (Beginner's Guide)

In the dynamic world of Python development, managing dependencies and project environments is crucial for sanity and success. Imagine working on two different projects: one requires an older version of a popular library like requests, while the other needs the very latest features. Installing both system-wide would inevitably lead to conflicts, breakage, and frustration. This is precisely the problem Python virtual environments are designed to solve. This tutorial will guide you through the fun

Stefania Boiko

May 2, 2025

Qwen2.5-Omni-7B: Small But MightyViewpoint

Qwen2.5-Omni-7B: Small But Mighty

The field of artificial intelligence is rapidly evolving, pushing the boundaries of what machines can perceive, understand, and generate. A significant leap in this evolution is marked by the introduction of the Qwen2.5-Omni-7B model, a flagship end-to-end multimodal model developed by the Qwen team. This model represents a paradigm shift, moving beyond text-centric interactions to embrace a truly omni-modal experience. It seamlessly processes a diverse array of inputs – text, images, audio, and

MiMo-7B-RL: the Reasoning LLM from XiaomiViewpoint

MiMo-7B-RL: the Reasoning LLM from Xiaomi

Xiaomi's LLM-Core Team presents MiMo-7B-RL, challenging the idea that top-tier reasoning in AI requires massive models. This 7-billion-parameter model, specifically engineered for mathematical and coding tasks, demonstrates performance that rivals much larger models and specialized systems like OpenAI's o1-mini. This achievement results from a comprehensive strategy optimizing the entire model lifecycle, proving potent reasoning can be unlocked in more efficient architectures. 💡Want a great AP

Stefania Boiko

May 1, 2025