# Qwen-Agent — Multi-Tool AI Agent Framework > Build AI agents with Alibaba Qwen models featuring tool calling, code execution, RAG, and browser control. Supports MCP protocol and custom tool development. ## Install Save as a script file and run: ## Quick Use ```bash pip install qwen-agent ``` ```python from qwen_agent.agents import Assistant bot = Assistant( llm={'model': 'qwen-max'}, function_list=['code_interpreter', 'image_gen'], ) messages = [{'role': 'user', 'content': 'Draw a sine wave plot'}] for response in bot.run(messages): print(response) ``` ## What is Qwen-Agent? Qwen-Agent is an agent framework built around Alibaba's Qwen language models. It provides built-in tools (code interpreter, browser, RAG), supports MCP protocol, and includes a GUI for building custom agent applications — from simple chatbots to complex multi-agent workflows. **Answer-Ready**: Qwen-Agent is an AI agent framework by Alibaba featuring built-in code execution, browser control, RAG retrieval, and MCP protocol support. It works with Qwen models and compatible APIs for building multi-tool agent applications. **Best for**: Developers building AI agents with Qwen models or compatible APIs. **Works with**: Qwen-Max, Qwen-Plus, any OpenAI-compatible API. **Setup time**: Under 3 minutes. ## Core Features ### 1. Built-In Tools ```python from qwen_agent.agents import Assistant # Code Interpreter — execute Python in sandbox bot = Assistant( llm={'model': 'qwen-max'}, function_list=['code_interpreter'], ) # RAG — retrieve from documents bot = Assistant( llm={'model': 'qwen-max'}, function_list=['doc_qa'], files=['report.pdf', 'data.csv'], ) ``` ### 2. MCP Protocol Support ```python from qwen_agent.agents import Assistant bot = Assistant( llm={'model': 'qwen-max'}, mcp_servers={ 'filesystem': { 'command': 'npx', 'args': ['-y', '@anthropic/mcp-filesystem', '/tmp'] } }, ) ``` ### 3. Custom Tool Development ```python from qwen_agent.tools.base import BaseTool, register_tool @register_tool('weather') class WeatherTool(BaseTool): description = 'Get current weather for a city' parameters = [{'name': 'city', 'type': 'string', 'required': True}] def call(self, params, **kwargs): city = params['city'] return f'Sunny, 25C in {city}' ``` ### 4. Multi-Agent Workflows ```python from qwen_agent.agents import GroupChat researcher = Assistant(llm=cfg, name='Researcher', system_message='You research topics.') writer = Assistant(llm=cfg, name='Writer', system_message='You write articles.') group = GroupChat(agents=[researcher, writer]) for response in group.run(messages): print(response) ``` ### 5. Browser Control ```python bot = Assistant( llm={'model': 'qwen-max'}, function_list=['browser'], ) # Agent can navigate, read, and interact with web pages ``` ### 6. GUI Application ```bash python -m qwen_agent.gui --agent-config config.json # Launches a Gradio-based chat interface ``` ## FAQ **Q: Does it work with non-Qwen models?** A: Yes, any OpenAI-compatible API works. Set the base_url and api_key accordingly. **Q: Is it open source?** A: Yes, Apache 2.0 license. Fully open-source with active development. **Q: How does MCP support work?** A: Qwen-Agent can connect to MCP servers as tool providers, similar to Claude Code or Cline. ## Source & Thanks > Created by [Alibaba Qwen Team](https://github.com/QwenLM). Licensed under Apache 2.0. > > [QwenLM/Qwen-Agent](https://github.com/QwenLM/Qwen-Agent) — 6k+ stars ## 快速使用 ```bash pip install qwen-agent ``` 三行代码创建带工具调用的 AI 代理。 ## 什么是 Qwen-Agent? Qwen-Agent 是阿里巴巴基于通义千问模型构建的代理框架。提供内置工具(代码解释器、浏览器、RAG)、支持 MCP 协议,包含 GUI 界面。 **一句话总结**:Qwen-Agent 是阿里 AI 代理框架,内置代码执行、浏览器控制、RAG 检索和 MCP 协议支持。 **适合人群**:使用 Qwen 模型或兼容 API 构建 AI 代理的开发者。**支持**:Qwen-Max、Qwen-Plus、任何 OpenAI 兼容 API。 ## 核心功能 ### 1. 内置工具 代码解释器、文档 QA、浏览器控制、图片生成。 ### 2. MCP 协议支持 连接任意 MCP 服务器作为工具提供者。 ### 3. 自定义工具 装饰器注册自定义工具,代理自动发现和调用。 ### 4. 多代理工作流 GroupChat 模式,多个代理协作完成复杂任务。 ### 5. GUI 界面 内置 Gradio 界面,一键启动聊天应用。 ## 常见问题 **Q: 支持非 Qwen 模型吗?** A: 支持,任何 OpenAI 兼容 API 都可以。 **Q: 开源吗?** A: 是,Apache 2.0 许可证。 ## 来源与致谢 > [QwenLM/Qwen-Agent](https://github.com/QwenLM/Qwen-Agent) — 6k+ stars, Apache 2.0 --- Source: https://tokrepo.com/en/workflows/cfd97f48-99e4-4cf9-b584-180c9fda8905 Author: Prompt Lab