freshcrate
Skin:/
Home > MCP Servers > Qwen-Agent

Qwen-Agent

Agent framework and applications built upon Qwen>=3.0, featuring Function Calling, MCP, Code Interpreter, RAG, Chrome extension, etc.

Why this rank:Strong adoptionHealthy release cadence

Description

Agent framework and applications built upon Qwen>=3.0, featuring Function Calling, MCP, Code Interpreter, RAG, Chrome extension, etc.

README

中文 | English


💜 Qwen Chat   |   🤗 Hugging Face   |   🤖 ModelScope   |    📑 Blog    |   📖 Documentation
📊 Benchmark   |   💬 WeChat (微信)   |   🫨 Discord  

Qwen-Agent is a framework for developing LLM applications based on the instruction following, tool usage, planning, and memory capabilities of Qwen. It also comes with example applications such as Browser Assistant, Code Interpreter, and Custom Assistant. Now Qwen-Agent plays as the backend of Qwen Chat.

News

  • 🔥🔥🔥Feb 16, 2026: Open-sourced Qwen3.5. For usage examples, refer to Qwen3.5 Agent Demo.
  • Jan 27, 2026: Open-sourced agent evaluation benchmark DeepPlanning and added Qwen-Agent documentation.
  • Sep 23, 2025: Added Qwen3-VL Tool-call Demo, supporting tools such as zoom in, image search, and web search.
  • Jul 23, 2025: Add Qwen3-Coder Tool-call Demo; Added native API tool call interface support, such as using vLLM's built-in tool call parsing.
  • May 1, 2025: Add Qwen3 Tool-call Demo, and add MCP Cookbooks.
  • Mar 18, 2025: Support for the reasoning_content field; adjust the default Function Call template, which is applicable to the Qwen2.5 series general models and QwQ-32B. If you need to use the old version of the template, please refer to the example for passing parameters.
  • Mar 7, 2025: Added QwQ-32B Tool-call Demo. It supports parallel, multi-step, and multi-turn tool calls.
  • Dec 3, 2024: Upgrade GUI to Gradio 5 based. Note: GUI requires Python 3.10 or higher.
  • Sep 18, 2024: Added Qwen2.5-Math Demo to showcase the Tool-Integrated Reasoning capabilities of Qwen2.5-Math. Note: The python executor is not sandboxed and is intended for local testing only, not for production use.

Getting Started

Installation

  • Install the stable version from PyPI:
pip install -U "qwen-agent[gui,rag,code_interpreter,mcp]"
# Or use `pip install -U qwen-agent` for the minimal requirements.
# The optional requirements, specified in double brackets, are:
#   [gui] for Gradio-based GUI support;
#   [rag] for RAG support;
#   [code_interpreter] for Code Interpreter support;
#   [mcp] for MCP support.
  • Alternatively, you can install the latest development version from the source:
git clone https://github.com/QwenLM/Qwen-Agent.git
cd Qwen-Agent
pip install -e ./"[gui,rag,code_interpreter,mcp]"
# Or `pip install -e ./` for minimal requirements.

Preparation: Model Service

You can either use the model service provided by Alibaba Cloud's DashScope, or deploy and use your own model service using the open-source Qwen models.

  • If you choose to use the model service offered by DashScope, please ensure that you set the environment variable DASHSCOPE_API_KEY to your unique DashScope API key.

  • Alternatively, if you prefer to deploy and use your own model service, please follow the instructions provided in the README of Qwen2 for deploying an OpenAI-compatible API service. Specifically, consult the vLLM section for high-throughput GPU deployment or the Ollama section for local CPU (+GPU) deployment. For the QwQ and Qwen3 model, it is recommended to do not add the --enable-auto-tool-choice and --tool-call-parser hermes parameters, as Qwen-Agent will parse the tool outputs from vLLM on its own. For Qwen3-Coder, it is recommended to enable both of the above parameters, use vLLM's built-in tool parsing, and combine with the use_raw_api parameter usage.

Developing Your Own Agent

Qwen-Agent offers atomic components, such as LLMs (which inherit from class BaseChatModel and come with function calling) and Tools (which inherit from class BaseTool), along with high-level components like Agents (derived from class Agent).

The following example illustrates the process of creating an agent capable of reading PDF files and utilizing tools, as well as incorporating a custom tool:

import pprint
import urllib.parse
import json5
from qwen_agent.agents import Assistant
from qwen_agent.tools.base import BaseTool, register_tool
from qwen_agent.utils.output_beautify import typewriter_print


# Step 1 (Optional): Add a custom tool named `my_image_gen`.
@register_tool('my_image_gen')
class MyImageGen(BaseTool):
    # The `description` tells the agent the functionality of this tool.
    description = 'AI painting (image generation) service, input text description, and return the image URL drawn based on text information.'
    # The `parameters` tell the agent what input parameters the tool has.
    parameters = [{
        'name': 'prompt',
        'type': 'string',
        'description': 'Detailed description of the desired image content, in English',
        'required': True
    }]

    def call(self, params: str, **kwargs) -> str:
        # `params` are the arguments generated by the LLM agent.
        prompt = json5.loads(params)['prompt']
        prompt = urllib.parse.quote(prompt)
        return json5.dumps(
            {'image_url': f'https://image.pollinations.ai/prompt/{prompt}'},
            ensure_ascii=False)


# Step 2: Configure the LLM you are using.
llm_cfg = {
    # Use the model service provided by DashScope:
    'model': 'qwen-max-latest',
    'model_type': 'qwen_dashscope',
    # 'api_key': 'YOUR_DASHSCOPE_API_KEY',
    # It will use the `DASHSCOPE_API_KEY' environment variable if 'api_key' is not set here.

    # Use a model service compatible with the OpenAI API, such as vLLM or Ollama:
    # 'model': 'Qwen2.5-7B-Instruct',
    # 'model_server': 'http://localhost:8000/v1',  # base_url, also known as api_base
    # 'api_key': 'EMPTY',

    # (Optional) LLM hyperparameters for generation:
    'generate_cfg': {
        'top_p': 0.8
    }
}

# Step 3: Create an agent. Here we use the `Assistant` agent as an example, which is capable of using tools and reading files.
system_instruction = '''After receiving the user's request, you should:
- first draw an image and obtain the image url,
- then run code `request.get(image_url)` to download the image,
- and finally select an image operation from the given document to process the image.
Please show the image using `plt.show()`.'''
tools = ['my_image_gen', 'code_interpreter']  # `code_interpreter` is a built-in tool for executing code. For configuration details, please refer to the FAQ.
files = ['./examples/resource/doc.pdf']  # Give the bot a PDF file to read.
bot = Assistant(llm=llm_cfg,
                system_message=system_instruction,
                function_list=tools,
                files=files)

# Step 4: Run the agent as a chatbot.
messages = []  # This stores the chat history.
while True:
    # For example, enter the query "draw a dog and rotate it 90 degrees".
    query = input('\nuser query: ')
    # Append the user query to the chat history.
    messages.append({'role': 'user', 'content': query})
    response = []
    response_plain_text = ''
    print('bot response:')
    for response in bot.run(messages=messages):
        # Streaming output.
        response_plain_text = typewriter_print(response, response_plain_text)
    # Append the bot responses to the chat history.
    messages.extend(response)

In addition to using built-in agent implementations such as class Assistant, you can also develop your own agent implemetation by inheriting from class Agent.

The framework also provides a convenient GUI interface, supporting the rapid deployment of Gradio Demos for Agents. For example, in the case above, you can quickly launch a Gradio Demo using the following code:

from qwen_agent.gui import WebUI
WebUI(bot).run()  # bot is the agent defined in the above code, we do not repeat the definition here for saving space.

Now you can chat with the Agent in the web UI. Please refer to the examples directory for more usage examples.

FAQ

How to Use the Code Interpreter Tool?

We implement a code interpreter tool based on local Docker containers. You can enable the built-in code interpreter tool for your agent, allowing it to autonomously write code according to specific scenarios, execute it securely within an isolated sandbox environment, and return the execution results.

⚠️ Note: Before using this tool, please ensure that Docker is installed and running on your local operating system. The time required to build the container image for the first time depends on your network conditions. For Docker installation and setup instructions, please refer to the official documentation.

How to Use MCP?

You can select the required tools on the open-source MCP server website and configure the relevant environment.

Example of MCP invocation format:

{
    "mcpServers": {
        "memory": {
            "command": "npx",
            "args": ["-y", "@modelcontextprotocol/server-memory"]
        },
        "filesystem": {
            "command": "npx",
            "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/files"]
        },
        "sqlite" : {
            "command": "uvx",
            "args": [
                "mcp-server-sqlite",
                "--db-path",
                "test.db"
            ]
        }
    }
}

For more details, you can refer to the MCP usage example

The dependencies required to run this example are as follows:

# Node.js (Download and install the latest version from the Node.js official website)
# uv 0.4.18 or higher (Check with uv --version)
# Git (Check with git --version)
# SQLite (Check with sqlite3 --version)

# For macOS users, you can install these components using Homebrew:
brew install uv git sqlite3

# For Windows users, you can install these components using winget:
winget install --id=astral-sh.uv -e
winget install git.git sqlite.sqlite

Do you have function calling (aka tool calling)?

Yes. The LLM classes provide function calling. Additionally, some Agent classes also are built upon the function calling capability, e.g., FnCallAgent and ReActChat.

The current default tool calling template natively supports Parallel Function Calls.

How to pass LLM parameters to the Agent?

llm_cfg = {
    # The model name being used:
    'model': 'qwen3-32b',
    # The model service being used:
    'model_type': 'qwen_dashscope',
    # If 'api_key' is not set here, it will default to reading the `DASHSCOPE_API_KEY` environment variable:
    'api_key': 'YOUR_DASHSCOPE_API_KEY',

    # Using an OpenAI API compatible model service, such as vLLM or Ollama:
    # 'model': 'qwen3-32b',
    # 'model_server': 'http://localhost:8000/v1',  # base_url, also known as api_base
    # 'api_key': 'EMPTY',

    # (Optional) LLM hyperparameters:
    'generate_cfg': {
        # This parameter will affect the tool-call parsing logic. Default is False:
          # Set to True: when content is `<think>this is the thought</think>this is the answer`
          # Set to False: when response consists of reasoning_content and content
        # 'thought_in_content': True,

        # tool-call template: default is nous (recommended for qwen3):
        # 'fncall_prompt_type': 'nous'

        # Maximum input length, messages will be truncated if they exceed this length, please adjust according to model API:
        # 'max_input_tokens': 58000

        # Parameters that will be passed directly to the model API, such as top_p, enable_thinking, etc., according to the API specifications:
        # 'top_p': 0.8

        # Using the API's native tool call interface
        # 'use_raw_api': True,
    }
}

How to do question-answering over super-long documents involving 1M tokens?

We have released a fast RAG solution, as well as an expensive but competitive agent, for doing question-answering over super-long documents. They have managed to outperform native long-context models on two challenging benchmarks while being more efficient, and perform perfectly in the single-needle "needle-in-the-haystack" pressure test involving 1M-token contexts. See the blog for technical details.

Application: BrowserQwen

BrowserQwen is a browser assistant built upon Qwen-Agent. Please refer to its documentation for details.

Disclaimer

The Docker container-based code interpreter mounts only the specified working directory and implements basic sandbox isolation, but it should still be used with caution in production environments.

Release History

VersionChangesUrgencyDate
v0.0.26- bugfix: support set sse_read_timeout and automatic reconnection for mcpLow5/29/2025
v0.0.25- support streamable-http for mcp - change license to apache 2.0Low5/22/2025
v0.0.24- allow tool response to be empty string - add a fallback for invalid tool call output - support resource in mcp server as tool - support transformers models, audio input, and fix openvinoLow5/19/2025
v0.0.23- fix missing dashscope api_key after creating fncall_agent with qwen3Low5/16/2025
v0.0.22- add Qwen3 examples and MCP cookbooks - change keygen model in rag - bugfix: pass reasoning_content to oai interfaceLow5/8/2025
v0.0.21- add qwen3 example - fix bug of typewriter_print for code_interpreterLow5/1/2025
v0.0.20- fix mcp dangling processes - add truncation for function role - set QWEN_AGENT_MAX_LLM_CALL_PER_RUN=20, QWEN_AGENT_DEFAULT_MAX_INPUT_TOKENS=58kLow4/28/2025
v0.0.18- llm: Add omni support - gui: Modify the dependency version of gradioLow4/1/2025
v0.0.17- Adjust MCP as an optional dependency - Modify some search strategy in RAGLow3/30/2025
v0.0.16- Add reasoning_content filed to Message - Adjust the default Function Call template - Add a function to assist in printing streaming str response on the terminalLow3/18/2025
v0.0.15- support optional image prefix for vl fn-call - support video understandingLow12/13/2024
v0.0.14- support completion interface for oai - add qwen-audio support and support env for default settings - rm upload image prefix Low12/12/2024
v0.0.13- update modelscope_studio version and fix Windows encoding issuesLow12/4/2024
v0.0.12- upgrade gui to gradio 5 basedLow12/3/2024
v0.0.11- fix signal conflicts in code interpreter - support nous tool-call prompt Low11/29/2024
v0.0.10- Add the [Tool-Integrated Reasoning (TIR) agent](https://github.com/QwenLM/Qwen-Agent/blob/main/examples/tir_math.py) for Qwen2.5-Math. - Add support for [caching the LLM's responses](https://github.com/QwenLM/Qwen-Agent/blob/main/qwen_agent/llm/base.py#L65). LLM caching can be enabled by providing `cache_dir` in the LLM's config, i.e.,`llm = get_chat_model(cfg={..., "cache_dir": "/tmp/directory_to_save_llm_cache"})`. - Add [self-play agents](https://github.com/QwenLM/Qwen-Agent/blob/main/qweLow9/18/2024
v0.0.9 - Bug fix: Incomplete PyPI packaging caused by the absence of `__init__.py`.Low9/4/2024
v0.0.8- Multimodal function calling for [Qwen2-VL](https://github.com/QwenLM/Qwen2-VL). Please see [the function calling example](https://github.com/QwenLM/Qwen-Agent/blob/main/examples/qwen2vl_function_calling.py) and [the agent example](https://github.com/QwenLM/Qwen-Agent/blob/main/examples/qwen2vl_assistant_tooluse.py) for example usage. Low9/3/2024
v0.0.7- Make dependencies for the code interpreter and RAG optional. - `pip install qwen-agent` now only installs minimal dependencies for function calling. - `pip install qwen-agent[rag,code_interpreter,gui]` installs optional dependencies for RAG, Code Interpreter, and GUI.Low8/5/2024
v0.0.6- Added experimental support for [parallel tool calling](https://github.com/QwenLM/Qwen-Agent/blob/main/examples/function_calling_in_parallel.py#L68) and [tool choice](https://github.com/QwenLM/Qwen-Agent/blob/main/examples/function_calling.py#L77).Low6/26/2024
v0.0.5- Added long-context agents to understand *1-million-token* documents. Read the [blog](https://qwenlm.github.io/blog/qwen-agent-2405/) for technical details.Low6/6/2024
v0.0.4- Added experimental support for Gradio-based web GUI components for easy prototyping. - Added vector retrieval, hybrid retrieval, and keyword stemming to improve RAG performance.Low5/11/2024
v0.0.3- Improved the accuracy of the fast RAG strategy. - Reorganized the implementations of RAG-related tools.Low4/25/2024
v0.0.2- Improved documentation. - Support local image files for DashScope Qwen-VL.Low4/17/2024
v0.0.1- Qwen-Agent v0.0.1 released and uploaded to [pypi.org](https://pypi.org/project/qwen-agent/).Low4/7/2024

Dependencies & License Audit

Loading dependencies...

Similar Packages

AI-Skills🤖 Enhance AI capabilities with modular Skills that provide expert knowledge, workflows, and integrations for any project.main@2026-06-07
telegram-mcp🤖 Manage multiple Telegram accounts effortlessly with AI-driven tools for bulk messaging, scheduling, and more in one easy-to-use platform.main@2026-06-07
Enterprise-Multi-AI-Agent-Systems-🤖 Build and deploy scalable Multi-AI Agent systems with LangGraph and Groq LLMs to enhance intelligence across enterprise applications.main@2026-06-07
AIDomesticCoreAIJ🛠️ Build a robust AI Kernel for stable, auditable, and sovereign AI systems, ensuring secure execution and compliance across various domains.main@2026-06-07
argus-mcp🔍 Enhance code quality with Argus MCP, an AI-driven code review server using a Zero-Trust model for safe and efficient development.main@2026-06-07

More in MCP Servers

PlanExeCreate a plan from a description in minutes
agentroveYour own Claude Code UI, sandbox, in-browser VS Code, terminal, multi-provider support (Anthropic, OpenAI, GitHub Copilot, OpenRouter), custom skills, and MCP servers.
ProxmoxMCP-PlusEnhanced Proxmox MCP server with advanced virtualization management and full OpenAPI integration.
node9-proxyThe Execution Security Layer for the Agentic Era. Providing deterministic "Sudo" governance and audit logs for autonomous AI agents.