一个通用的 MCP 工具,可以轻松地将 Web API 接口转换为 MCP 工具供AI助手使用。
python 3.13
requests>=2.31.0
beautifulsoup4>=4.12.3
websockets>=12.0
python-dotenv>=1.0.0
fastmcp>=0.1.0
pip install -r requirements.txt
python 启动_universal_mcp.py
在“API管理”标签页中,您可以添加、删除和修改API配置
添加API时需要提供以下信息:
添加后点击“保存API”按钮
{
"api_name": "查询天气",
"api_url": "https://api.example.com/weather",
"method": "GET",
"request_format": {
"city": "string",
"days": "number"
},
"response_format": {
"temperature": "number",
"weather": "string",
"humidity": "number"
},
"description": "根据城市名称查询天气预报"
}
{
"api_name": "翻译文本",
"api_url": "https://api.example.com/translate",
"method": "POST",
"api_key": "your-api-key-here",
"key_location": "header",
"key_name": "Authorization",
"request_format": {
"text": "string",
"source": "string",
"target": "string"
},
"response_format": {
"translated": "string",
"status": "number"
},
"description": "将文本从源语言翻译为目标语言"
}
register_api工具可以直接调用AI助手注册新的APIlist_registered_apis工具查看所有已注册的APIremove_registered_api工具删除指定的APIapi_configs.json文件中~/.xiaozhi_mcp_config.json文件中