Doubao MCP Agent
Provides web search capabilities using DuckDuckGo, allowing AI agents to search for current information, news, and data from the internet through the DuckDuckGo search engine.
Enables integration with OpenAI-compatible APIs for AI model inference, supporting various models including Doubao and other OpenAI-format models through standardized API calls.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Doubao MCP Agent帮我查一下上海今天的天气"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ToolKit Local Skill Agent
A local skill assistant based on the MCP (Model Context Protocol), supporting custom skills such as calculators and weather queries, with both Web and API interfaces.
Project Structure
..
├── .env # 大模型 API 配置
├── chat_history.db # SQLite 对话历史数据库(自动生成)
├── index.html # 前端 Web 界面
├── main.py # 主入口(命令行界面)
├── mcp_server.py # MCP 服务端(核心)
├── server.py # Flask 后端服务
├── requirements.txt # 依赖清单
├── README.md # 项目说明
├── tree.txt # 目录结构
├── client/ # 客户端目录
│ ├── doubao_mcp_client.py # 豆包 API 客户端
│ └── __init__.py
├── config/ # 配置目录
│ ├── settings.py # 全局配置
│ └── __init__.py
└── skills/ # 技能实现目录
├── calculator.py # 计算器技能
├── weather.py # 天气查询技能
├── web_search/ # 网络搜索技能目录
│ └── web_search.py # DuckDuckGo搜索实现
| └── SKILL.md # skill描述
| └── _init_.py
└── __init__.pyRelated MCP server: MCP Connection Hub
Tech Stack
Backend Framework: Python + Flask for Web services, providing RESTful APIs and SSE streaming interfaces.
AI Protocol & Model Invocation: Based on OpenAI-compatible SDK to interface with LLM APIs, supporting models like Doubao that use the OpenAI format.
Core Protocol: MCP (Model Context Protocol) for standardized tool invocation, unifying skill registration and scheduling.
Asynchronous Architecture: asyncio processing + thread pool isolation to resolve blocking issues in Flask's synchronous environment.
Data Persistence: SQLite for multi-session conversation context storage, supporting session management and history loading.
Skill Plugin System: Modular skill system supporting pluggable tools like calculators, weather, and web search.
Frontend: Native HTML/JS for the Web interface, supporting Markdown rendering, streaming typing effects, and chain-of-thought display.
Engineering: API variable configuration (.env), dependency management (uv/pip), error retry and fallback mechanisms, and tool invocation caching.
Core Features
✅ Stable Asynchronous Processing - Fixed issues with using asyncio.run() directly in Flask routes; uses a thread pool to execute asynchronous functions.
✅ Conversation History Persistence - Uses SQLite to store conversation history, ensuring data is not lost on service restart, with support for multi-session management.
✅ Tool Invocation Fault Tolerance - Automatic retry mechanism; falls back to direct model response if tool invocation fails.
✅ MCP Tool Caching - Caches the tool list after the first fetch to reduce redundant initialization overhead.
✅ Streaming Output - Implemented a full SSE streaming interface for a character-by-character output experience.
✅ Tool Invocation Prompts - Displays "[Invoked tool: {Tool Name}]" when a skill is called.
✅ Multi-platform Support - Provides both Web and command-line interfaces.
✅ Rich Skill Set - Built-in calculator, weather query, and web search skills.
✅ Skill Management - Visual skill management in the frontend, allowing users to toggle skills freely.
✅ Markdown Rendering - Supports Markdown-formatted responses, including code highlighting, tables, lists, and mathematical formulas.
✅ Chain-of-Thought Display - Collapsible AI reasoning process display for better understanding of logic.
✅ Multi-session Management - Supports creating multiple independent conversations, each with its own saved history.
✅ History Loading - Automatically loads conversation history when switching sessions, maintaining a complete record of interactions.
Environment Requirements
Python 3.11+
openaiSDK(api)
uv package manager (recommended) or pip
Installation
Method 1: Using uv (Recommended)
Install uv
# Windows Set-ExecutionPolicy RemoteSigned -Scope CurrentUser irm https://astral.sh/uv/install.ps1 | iex # macOS / Linux curl -LsSf https://astral.sh/uv/install.sh | shClone the project
git clone https://github.com/taffy123d/Doubao-MCP-agent cd <项目目录>Create a virtual environment
uv venvInstall dependencies
uv sync
Method 2: Using pip
Clone the project
git clone https://github.com/taffy123d/Doubao-MCP-agent cd <项目目录>Create a virtual environment
python -m venv venvActivate the virtual environment
# Windows venv\Scripts\activate # macOS / Linux source venv/bin/activateInstall dependencies
pip install -r requirements.txt
Configuration
Configure API keys in the frontend
Or fill in the API keys in the
.envfile:
# OpenAI 兼容格式的 API 配置
OPENAI_API_KEY=你的API密钥
OPENAI_BASE_URL=https://ark.cn-beijing.volces.com/api/v3
OPENAI_MODEL=你的模型IDRunning
Method 1: Full Startup (Recommended)
uv run server.py
#或者
python server.pyFrontend access:
http://localhost:5000API interface:
http://localhost:5000/api/*
Method 2: Command Line Interface
uv run main.py
#或者
python main.pyChat directly in the terminal
Supports multi-turn conversations and history
Type
clearto clear conversation historyType
exit,quitto exit the program
API Endpoints
Endpoint | Method | Description |
| GET | Frontend page |
| GET | Health check |
| GET | Get skill list |
| GET | Get configuration |
| POST | Save configuration |
| POST | Test API connection |
| POST | Chat (supports history) |
| POST | Streaming chat (SSE) |
| POST | Clear conversation history |
| GET | Get all session lists |
| DELETE | Delete specific session |
| GET | Get session history |
API Request Examples
Chat Endpoint
curl -X POST http://localhost:5000/api/chat \
-H "Content-Type: application/json" \
-d '{
"api_key": "你的API密钥",
"model": "你的模型ID",
"base_url": "https://ark.cn-beijing.volces.com/api/v3",
"message": "北京天气",
"session_id": "default"
}'Streaming Chat Endpoint
curl -X POST http://localhost:5000/api/chat/stream \
-H "Content-Type: application/json" \
-d '{
"api_key": "你的API密钥",
"model": "你的模型ID",
"base_url": "https://ark.cn-beijing.volces.com/api/v3",
"message": "北京天气",
"session_id": "default"
}'Clear History Endpoint
curl -X POST http://localhost:5000/api/chat/clear \
-H "Content-Type: application/json" \
-d '{
"session_id": "default"
}'How to Use
Web Interface
Configure API
Enter API Key and Endpoint ID in the left configuration panel
Click "Test" to verify the connection
Chat
Enter your question in the input box
Supported skills:
Calculator:
calculate 123+456Weather:
Beijing weatherWeb Search:
search latest AI news
Skill Management
Click "🔧 Skill Management" on the left to expand the panel
View all available skills and their descriptions
Toggle switches to enable/disable skills
Only enabled skills will be invoked
Multi-session Management
Click "💬 Conversation Management" on the left to expand the panel
Click "➕ New Chat" to create a new session
Click items in the list to switch sessions
Click 🗑️ to delete unwanted sessions
Each session saves its own history
View Results
The system automatically invokes the appropriate skill and returns results
Supports Markdown formatting (code highlighting, tables, lists, etc.)
Click "🧠 Thought Process" to view AI reasoning logic
Supports multi-turn conversations
Command Line Interface
Run the program
python main.pyEnter questions
Type your question directly in the terminal
Supported skills:
Calculator:
calculate 123+456Weather:
Beijing weather
View results
The system automatically invokes the appropriate skill and returns results
Supports multi-turn conversations
Type
clearto clear conversation history
How to Add New Skills
Step 1: Create a skill file
Create a new skill file in the skills/ directory, e.g., my_skill.py:
"""我的自定义技能"""
from mcp.server.fastmcp import FastMCP
def register_my_skill(mcp: FastMCP):
"""注册技能到 MCP 服务"""
@mcp.tool()
def my_skill(param1: str, param2: int = 1) -> str:
"""
我的自定义技能描述
示例:my_skill(param1="值", param2=2)
Args:
param1: 参数1描述
param2: 参数2描述(默认值)
Returns:
技能执行结果
"""
try:
# 技能逻辑实现
result = f"处理结果: {param1} - {param2}"
return result
except Exception as e:
return f"处理失败: {str(e)}"Step 2: Register the skill
Edit skills/__init__.py and add the registration function for the new skill:
from .calculator import register_calculator_tool
from .weather import register_weather_tool
from .my_skill import register_my_skill
__all__ = [
"register_calculator_tool",
"register_weather_tool",
"register_my_skill"
]Step 3: Update the MCP service
Edit mcp_server.py and add the registration for the new skill:
from skills import register_calculator_tool, register_weather_tool, register_my_skill
# 注册所有技能工具
register_calculator_tool(mcp)
register_weather_tool(mcp)
register_my_skill(mcp) # 添加这一行Step 4: Restart the service
Restart the MCP service and the backend service to use the new skill.
Skill Development Specifications
File Naming: Use lowercase letters and underscores
Function Naming: Use
register_xxx_toolformatTool Decorator: Use
@mcp.tool()decoratorDocstrings: Include functional description, examples, and parameter explanations
Error Handling: Catch exceptions and return friendly prompts
Parameter Types: Use type annotations
How to Create Complex Skills (with SKILL.md)
For complex skills, it is recommended to create an independent skill directory containing the implementation and a SKILL.md description file.
Directory Structure
skills/
└── my_complex_skill/ # skill 目录
├── __init__.py # 导出配置(必选)
├── my_skill.py # 技能实现(必选)
└── SKILL.md # skill 描述文档(必选)Step 1: Create skill directory and implementation file
Create a new skill directory in skills/, e.g., skills/my_complex_skill/
1.1 Create implementation file my_skill.py
"""我的复杂技能实现"""
from mcp.server.fastmcp import FastMCP
from duckduckgo_search import AsyncDuckDuckGoSearcher # 示例依赖
def register_my_complex_skill(mcp: FastMCP):
"""注册复杂技能到 MCP 服务"""
@mcp.tool()
async def my_complex_skill(query: str, limit: int = 5) -> str:
"""
我的复杂技能描述
Args:
query: 查询关键词
limit: 返回结果数量,默认5
Returns:
格式化的搜索结果
"""
try:
async with AsyncDuckDuckGoSearcher() as searcher:
results = await searcher.atext(query, max_results=limit)
# 处理并返回结果
return f"找到 {len(results)} 条结果..."
except Exception as e:
return f"搜索失败: {str(e)}"1.2 Create __init__.py to export configuration
"""my_complex_skill - 我的复杂技能"""
from .my_skill import register_my_complex_skill
__all__ = ["register_my_complex_skill"]1.3 Create SKILL.md description document
# 我的复杂技能
## 功能描述
一句话描述技能功能...
## 使用场景
### ✅ 适用场景
- 场景1
- 场景2
## 参数说明
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| query | string | 是 | - | 查询关键词 |
## 使用示例
```python
# 示例1
my_complex_skill(query="关键词")Return Result Format
Result 1: xxx
Result 2: xxx
Exception Handling
Error Type | Handling Method |
Network Error | Return a friendly error prompt |
Notes
Note 1
Note 2
### 步骤 2:更新 skills/__init__.py
```python
from .calculator import register_calculator_tool
from .weather import register_weather_tool
from .web_search import register_web_search_tool
from .my_complex_skill import register_my_complex_skill # 新增
__all__ = [
"register_calculator_tool",
"register_weather_tool",
"register_web_search_tool",
"register_my_complex_skill" # 新增
]Step 3: Update mcp_server.py
from skills import (
register_calculator_tool,
register_weather_tool,
register_web_search_tool,
register_my_complex_skill # 新增
)
# 注册所有技能工具
register_calculator_tool(mcp)
register_weather_tool(mcp)
register_web_search_tool(mcp)
register_my_complex_skill(mcp) # 新增Step 4: Install extra dependencies (if needed)
If the new skill requires additional Python packages, add them using uv add or in requirements.txt:
uv add 包名称
或
包名称 >=版本号 #requirements.txtThen run:
uv sync
# 或
pip install 包名称Step 5: Restart the service
Restart the service to use the new skill.
SKILL.md Specification
Field | Required | Description |
# Title | Yes | Skill name |
## Functional Description | Yes | One-sentence description of the skill |
## Usage Scenarios | Recommended | List applicable scenarios |
## Parameter Description | Recommended | Explain parameters in table format |
## Usage Examples | Recommended | Code and conversation examples |
## Return Result Format | Recommended | Explain the structure of returned content |
## Exception Handling | Recommended | Error handling methods |
## Notes | Recommended | Usage precautions |
Example Skills
Calculator Skill
Function: Supports addition, subtraction, multiplication, division, parentheses, and exponentiation
Invocation:
calculate (10+5)*2
Weather Query Skill
Function: Query city weather and forecasts
Invocation:
Shanghai weatherorBeijing weather 3 days
Web Search Skill
Function: Use DuckDuckGo to search for the latest news
Invocation:
search latest Python versionorsearch today's tech newsDependency:
ddgslibrary (pip install duckduckgo-search)
Technical Highlights
Async Processing Optimization - Uses a thread pool to execute async functions, avoiding the issue of creating a new event loop for every request
Conversation History Persistence - SQLite-based persistent storage, data survives service restarts, supports multi-session isolation
Tool Invocation Fault Tolerance - Automatically retries twice on failure, falls back to direct model response, improving robustness
MCP Tool Caching - Reduces redundant initialization overhead, improving response speed
Streaming Output Implementation - Full SSE streaming interface for better user experience
Tool Invocation Prompts - Clear tool invocation prompts for better UX
Multi-platform Support - Provides both Web and CLI interfaces
Skill Management System - Visual skill management in the frontend with flexible toggling
Markdown Rendering - Full Markdown support, including code highlighting, tables, etc.
Chain-of-Thought Display - Collapsible AI reasoning process display
Multi-session Management - Full session creation, switching, and deletion functionality
History Loading - Automatically loads and displays session history
Notes
API Key Security: Do not commit API keys to version control
Skill Security: Avoid performing dangerous operations within skills
Performance Optimization: Consider using async processing for time-consuming operations
Error Handling: Ensure skills handle exceptions gracefully
Troubleshooting
Connection Failed: Check API key and network connection
Skill Not Responding: Check if the MCP service is running normally
Frontend Not Displaying: Check browser console for errors
Streaming Interface Issues: Ensure stable network connection to avoid mid-stream disconnection
Database Error: Check
chat_history.dbfile permissions to ensure read/write access
Data Storage
The project uses an SQLite database to persist conversation history:
Database File:
chat_history.db(root directory, generated automatically on first run)Table Structure:
CREATE TABLE messages ( id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, -- 会话ID,支持多会话隔离 role TEXT NOT NULL, -- 角色(user/assistant/tool) content TEXT NOT NULL, -- 消息内容 timestamp DATETIME DEFAULT CURRENT_TIMESTAMP )Query History: Use SQLite tools or command line to view
sqlite3 chat_history.db "SELECT * FROM messages ORDER BY timestamp DESC LIMIT 10;"
Extension Suggestions
More Skills: Add translation, stock queries, news, etc.
Multi-language Support: Add multi-language interface
Deployment Optimization: Use Docker for containerized deployment
Skill Marketplace: Create a marketplace for users to share and download skills
Model Switching: Support switching between different LLMs
Changelog
2026-03-29 Major Update
API Invocation Upgrade
httpx → OpenAI SDK: All API calls changed from
httpxdirect HTTP requests toopenai>=1.0.0SDKConfiguration Field Renaming:
DOUBAO_API_KEY→OPENAI_API_KEYDOUBAO_ENDPOINT_ID→OPENAI_MODELDOUBAO_BASE_URL→OPENAI_BASE_URL(removed/chat/completionssuffix)
Tool Invocation Optimization
Schema Cleanup: Automatically removes fields not supported by Doubao API such as
title,defaultDescription Cleanup: Compresses extra whitespace, optimizes formatting
Message Conversion: Added
_msg_to_dict()function to correctly handleChatCompletionMessageobjects returned by the OpenAI SDKSecond Invocation: Fixed message format issues for secondary requests after tool invocation
Bug Fixes
✅ Fixed "Object of type ChatCompletionMessage is not JSON serializable" error
✅ Fixed type conversion issues when saving message history
✅ Added detailed exception stack traces for easier debugging
Architecture Improvements
Added
_msg_to_dict()helper function for unified message format conversionAdded API type detection (automatically skips
toolsparameter for Xunfei API)Optimized exception handling and logging for
chat()route
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA versatile Model Context Protocol server that enables AI assistants to manage calendars, track tasks, handle emails, search the web, and control smart home devices.23
- FlicenseNot gradedqualityFmaintenanceA unified Model Context Protocol Gateway that bridges LLM interfaces with various tools and services, providing OpenAI API compatibility and supporting both synchronous and asynchronous tool execution.1
- FlicenseNot gradedqualityDmaintenanceA comprehensive demonstration server that provides tools for calculations, weather, and note management alongside an interactive web interface. It showcases how AI assistants can seamlessly interact with external data sources and functions using the Model Context Protocol.
- AlicenseNot gradedqualityFmaintenanceEnables AI assistants to operate Huawei Cloud resources (ECS, OBS, GaussDB, etc.) through conversational workflows via the Model Context Protocol.Apache 2.0
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Agent-first skill marketplace with USK open standard for Claude, Cursor, Gemini, Codex CLI.
Git-backed platform for skills, tools, and context for AI agents
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/taffy123d/LocalSkill-MCP-Agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server