AI代理工具服务平台

MCPHub是一个基于MCP协议的工具服务平台,通过统一入口集中管理AI代理工具,支持热插拔模块、代理第三方服务和AI代码生成功能。

  • by Jayden-Dong
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 Jayden-Dong/MCPHub

使用说明

英语 | 中文

MCPHub

🚀 An MCP Tool Service Platform - One Connection, Infinite Possibilities for AI Agents

Key Features • Quick Start • Feature Details • API Documentation • Development Guide


📸 系统屏幕截图

登录界面

默认凭据:用户名 admin,密码 admin123

模块管理界面

管理所有MCP模块,支持加载、卸载和重新加载操作

工具详细信息和控制

单独启用/禁用每个工具,实时编辑工具描述

代理服务器管理

无需修改即可代理现有的MCP服务器

使用统计仪表板

可视化工具调用次数、成功率和响应时间

AI代码生成

通过自然语言对话生成MCP插件代码


🎯 这是什么?

MCPHub 是一个 工具服务平台 基于MCP(模型上下文协议)。它解决了当前AI Agent系统中的一个痛点:

每个MCP服务器都需要在客户端单独配置。随着工具数量的增加,配置管理变得混乱。

MCPHub的解决方案:

┌─────────────────────────────────────────────────────────────────┐
│                    Before: Scattered Configuration              │
│  Claude/Cursor needs to configure dozens of MCP Server addresses│
│  - mcp-server-filesystem                                        │
│  - mcp-server-github                                            │
│  - mcp-server-postgres                                          │
│  - mcp-server-python                                            │
│  - ... (configuration explosion)                                │
└─────────────────────────────────────────────────────────────────┘
                              ⬇️
┌─────────────────────────────────────────────────────────────────────┐
│                    After: Unified Entry Point                       
│  Claude/Cursor only needs to configure one address                  
│  { "mcpServers": { "mcp-hub": { "url": "http://host:6081/mcp" } } } 
│                                                                     
│  MCP Hub automatically aggregates all tools, providing:             
│  ✅ Centralized tool management                                     
│  ✅ Hot-pluggable enable/disable                                    
│  ✅ Unified monitoring and statistics                               
└─────────────────────────────────────────────────────────────────────┘

✨ 主要特点

1.️⃣ 一个地址,无限工具

AI代理客户端只需配置 一个MCP服务器地址 访问平台上的所有工具。无论是内置工具、自定义插件还是代理的第三方MCP服务器,它们对客户端都是透明的。

2.️⃣ 热插拔工具管理

  • 模块级管理:在不重新启动服务的情况下加载、卸载和重新加载模块
  • 刀具液位控制:可以独立启用/禁用单个工具
  • 热配置更新:工具描述更改立即生效,无需重新启动

3.️⃣ 代理现有MCP服务器

已经有MCP服务器了吗?无需修改-只需配置一个代理进行集成:

{
  "name": "my-existing-server",
  "url": "http://existing-server:8080/mcp",
  "transport": "streamable-http"
}

该平台自动发现并透明地代理来自该服务器的所有工具。

4.️⃣ 人工智能驱动的MCP插件生成

内置AI代码生成功能-通过自然语言对话生成兼容的MCP模块代码:

User: Help me create a weather query tool
AI: Generated t_weather module with get_current_weather and get_forecast tools...

每个人都可以成为MCP工具开发人员!

5.️⃣ 插件生态系统:安装和共享

  • 一键安装:上传ZIP包以安装第三方插件
  • 一键导出:将自定义插件打包为ZIP,以便与其他用户共享
  • 模块化隔离:对内置工具进行单独管理(tools/)以及外部插件(tools_external/)

6.️⃣ 基于组的访问控制

将模块和代理服务器组织到 群组 控制不同AI客户端可以访问哪些工具:

  • 群体隔离:每个组都有自己的一组模块和代理服务器
  • 每个客户端访问:客户端通过指定组 x-group-id HTTP标头——它们只能看到并调用该组中的工具
  • 默认组:所有新添加的模块/代理都会自动添加到默认组中,确保向后兼容性
  • 灵活分配:一个模块或代理服务器可以同时属于多个组
┌──────────────┐         ┌──────────────┐
│  Group A     │         │  Group B     │
│  (Dev Tools) │         │  (Ops Tools) │
│  • t_python  │         │  • t_cli     │
│  • t_notebook│         │  • t_ftp     │
└──────────────┘         └──────────────┘
      ↑ x-group-id: A          ↑ x-group-id: B
 Claude Dev Agent          Claude Ops Agent

7.️⃣ 综合使用统计

直观地查看每个工具的使用情况:

  • 通话计数统计
  • 成功率跟踪
  • 响应时间分析
  • 24小时趋势图

🛠️ 内置工具

该平台配备了可随时使用的核心工具模块:

类别 模块 工具 描述
🖥️ CLI执行 t_cli run_cli_command, list_directory, get_system_info, get_disk_usage, get_running_processes, find_files… 执行系统命令、查看进程、磁盘监控、网络信息
🐍 Python执行 t_python run_python_script, installPackage, run_python_script_async, get_script_status 安全执行Python脚本、安装依赖项、异步执行
🤖 GUI自动化 t_autogui autogui_start_task, autogui_get_status, autogui_get_history, autogui_stop_task AI驱动的桌面自动化,自动鼠标和键盘操作
📓 笔记本 t_notebook add_note, read_note 笔记创建和查询,持久存储

特色:AI驱动的GUI自动化

这 t_autogui 模块实现 AI驱动的桌面自动化:

User: Help me open the browser and visit GitHub
Agent: [Calls autogui_start_task] → AI plans task steps → Executes mouse and keyboard operations

这是一个 杀手锏 AI可以像人类一样操作计算机桌面,完成复杂的GUI交互任务。


📦 扩展工具

除了内置工具外,该平台还支持安装扩展插件。当前可用的扩展工具 tools_external/:

类别 模块 工具 描述
🌐 FTP传输 t_ftp ftp_upload_file, ftp_download_file, ftp_create_directory FTP文件传输和管理

扩展工具位于 tools_external/ 目录,并且可以通过Web接口或API按需加载。您还可以开发自己的扩展工具并将其安装在平台上。


🚀 快速开始

需求

  • Python 3.10+
  • (可选)Node.js 18+-用于构建前端

安装

# Clone the project
git clone https://github.com/Jayden-Dong/MCPHub.git
cd MCPHub

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # Linux/Mac
# .venv\Scripts\activate   # Windows

# Install dependencies
pip install -r requirements.txt

启动服务

cd app
python main.py

启动后,访问:

  • 🌐 Web管理界面: http://localhost:6080
  • 📚 API文档: http://localhost:6080/docs
  • 🔌 MCP端点: http://localhost:6081/mcp

配置MCP客户端

在克劳德桌面/光标/樱桃工作室或其他MCP客户端中添加以下内容:

{
  "mcpServers": {
    "general-tools": {
      "url": "http://localhost:6081/mcp"
    }
  }
}

🎉 完成!您的AI代理现在可以使用平台上所有已启用的工具。


📖 功能详细信息

模块管理

通过Web界面或API管理模块:

┌───────────────────────────────────────────────────────────┐
│  Module List              [Scan New Modules] [Install]    
├───────────────────────────────────────────────────────────┤
│  ✅ t_cli        Loaded      [Details] [Reload] [Unload]  
│  ✅ t_python     Loaded      [Details] [Reload] [Unload]  
│  ⏸️ t_autogui    Paused      [Details] [Load]             
│  📦 t_weather    Not Loaded  [Details] [Load]    [Export] 
└───────────────────────────────────────────────────────────┘

刀具液位控制

输入模块详细信息以单独启用/禁用每个工具:

┌─────────────────────────────────────────────────────────┐
│  t_cli Module Details                                   
├─────────────────────────────────────────────────────────┤
│  🔧 run_cli_command      [✅ Enabled]                   
│  🔧 list_directory       [✅ Enabled]                   
│  🔧 get_system_info      [❌ Disabled]                  
│  🔧 kill_process         [❌ Disabled]  ⚠️ Dangerous      
└─────────────────────────────────────────────────────────┘

代理MCP服务器

将现有MCP服务器连接到平台:

通过Web界面:

  1. 导航到“代理管理”页面
  2. 点击“添加服务器”
  3. 填写服务器名称、URL和传输类型
  4. 点击“同步工具”→ 工具会自动出现在平台中

通过API:

curl -X POST http://localhost:6080/api/proxy/servers \
  -H "Content-Type: application/json" \
  -d '{
    "name": "filesystem-server",
    "url": "http://localhost:3000/mcp",
    "transport": "streamable-http"
  }'

AI代码生成

通过对话生成MCP插件:

# Start conversation
curl -X POST http://localhost:6080/api/codegen/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "Help me create a stock query tool that supports real-time prices and historical trends"}'

# Preview generated code
curl http://localhost:6080/api/codegen/preview/{task_id}

# Install directly to platform
curl -X POST http://localhost:6080/api/codegen/install/{task_id}

组管理

组允许您组织模块和代理服务器,并控制每个AI客户端可以访问哪些工具。

通过Web界面:

  1. 导航到“组管理”页面
  2. 点击“创建组”并为其命名
  3. 将模块或代理服务器添加到组中
  4. 复制组ID并通过 x-group-id 头球

通过API:

# Create a group
curl -X POST http://localhost:6080/api/groups \
  -H "Content-Type: application/json" \
  -d '{"name": "dev-tools", "description": "Tools for development"}'

# Add a module to the group
curl -X POST http://localhost:6080/api/groups/{group_id}/modules \
  -H "Content-Type: application/json" \
  -d '{"module_name": "t_python"}'

使用组配置MCP客户端:

{
  "mcpServers": {
    "dev-tools": {
      "url": "http://localhost:6081/mcp",
      "headers": {
        "x-group-id": "<your-group-id>"
      }
    }
  }
}

当客户提供 x-group-id header,它只能列出和调用属于该组的工具。没有组标头的客户端可以访问所有启用的工具。

使用统计

查看工具调用信息:

# Overall overview
curl http://localhost:6080/api/stats/overview

# Statistics by tool
curl http://localhost:6080/api/stats/tools

# Recent call records
curl http://localhost:6080/api/stats/recent?limit=100

响应示例:

{
  "total_calls": 1523,
  "success_rate": 0.98,
  "top_tools": [
    {"name": "run_python_script", "calls": 456, "avg_duration_ms": 1234},
    {"name": "run_cli_command", "calls": 312, "avg_duration_ms": 567}
  ]
}

🔌 API文档

模块管理 /api/modules

方法 路径 描述
得到 /api/modules 获取所有模块列表
得到 /api/modules/scan 扫描卸载的模块
职位 /api/modules/load 加载模块
职位 /api/modules/{name}/unload 卸载模块
职位 /api/modules/{name}/reload 重新加载模块
职位 /api/modules/tool/enable 启用工具
职位 /api/modules/tool/disable 禁用工具
职位 /api/modules/install 安装ZIP插件
得到 /api/modules/{name}/export 将模块导出为ZIP
删除 /api/modules/{name} 删除外部模块

代理管理 /api/proxy

方法 路径 描述
得到 /api/proxy/servers 获取代理服务器列表
职位 /api/proxy/servers 添加代理服务器
PUT /api/proxy/servers/{id} 更新配置
删除 /api/proxy/servers/{id} 删除服务器
职位 /api/proxy/servers/{id}/sync 同步工具列表
职位 /api/proxy/servers/{id}/enable 启用服务器
职位 /api/proxy/servers/{id}/disable 禁用服务器

组管理 /api/groups

方法 路径 描述
得到 /api/groups 获取所有组
职位 /api/groups 创建组
得到 /api/groups/{group_id} 获取组详细信息
PUT /api/groups/{group_id} 更新组信息
删除 /api/groups/{group_id} 删除组
得到 /api/groups/{group_id}/members 获取所有成员(模块+代理)
职位 /api/groups/{group_id}/modules 将模块添加到组
删除 /api/groups/{group_id}/modules/{module_name} 从组中删除模块
职位 /api/groups/{group_id}/proxies 将代理服务器添加到组
删除 /api/groups/{group_id}/proxies/{server_id} 从组中删除代理
得到 /api/groups/by-module/{module_name} 获取包含模块的组
得到 /api/groups/by-proxy/{server_id} 获取包含代理的组

统计查询 /api/stats

方法 路径 描述
得到 /api/stats/overview 总体统计概述
得到 /api/stats/modules 按模块统计
得到 /api/stats/tools 按工具统计
得到 /api/stats/recent 最近通话记录

AI代码生成 /api/codegen

方法 路径 描述
职位 /api/codegen/chat 会话代码生成
职位 /api/codegen/chat/stream 流媒体对话
得到 /api/codegen/preview/{task_id} 预览生成的代码
职位 /api/codegen/install/{task_id} 安装到平台上
职位 /api/codegen/download/{task_id} 下载ZIP

🧩 开发指南

创建自定义模块

有关详细的模块开发规范,请参阅 MCP_MODULE_DEV_GUIDE.md.

快速入门:

my_module/
├── __init__.py          # Package marker
├── MODULE_INFO          # Module metadata
├── my_module_mcp.py     # MCP tool registration
├── my_module_tool.py    # Business logic
└── requirements.txt     # Optional dependencies

模块信息:

{
  "display_name": "My Tool",
  "version": "1.0.0",
  "description": "Tool description",
  "author": "Your Name"
}

my_module_mcp.py:

from mcp_service import mcp
from config_py.config import settings
from config_py.prompt import prompt_manager
from utils import com_utils
from utils.com_utils import get_mcp_exposed_url

TOOL_NAME = "my_tool"

@mcp.tool(
    name=f'{settings.MCP_TOOL_NAME_PREFIX}{TOOL_NAME}',
    description=f'MCP Server URL: {get_mcp_exposed_url()}. {prompt_manager.get(TOOL_NAME)}',
    enabled=com_utils.get_tool_enable(TOOL_NAME),
)
def my_tool(param: str) -> dict:
    """Tool description"""
    return {"success": True, "data": "result"}

打包与分享

# Package
zip -r my_module.zip my_module/

# Install
curl -X POST http://localhost:6080/api/modules/install \
  -F "file=@my_module.zip"

🏗️ 系统架构

┌─────────────────────────────────────────────────────────────────┐
│                    MCP Client (Claude / Cursor)                 │
└───────────────────────────────┬─────────────────────────────────┘
                                │ MCP Protocol (HTTP Streamable)
                                ▼ :6081
┌─────────────────────────────────────────────────────────────────┐
│                    MCP Service (FastMCP)                        
│  ┌───────────────────────────────────────────────────────────┐ 
│  │  Middleware Layer                                          
│  │  • RequestMCPMiddleware (logging/statistics)               
│  │  • ToolDescriptionCheckerMiddleware (description hot update)
│  │  • ToolEnabledCheckerMiddleware (tool filtering)          
│  └───────────────────────────────────────────────────────────┘  
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐              
│  │  Built-in   │  │  External   │  │  Proxy      │              
│  │  Tools      │  │  Plugins    │  │  Tools      │              
│  │  tools/     │  │  external/  │  │  proxy/     │              
│  └─────────────┘  └─────────────┘  └─────────────┘              
└─────────────────────────────────────────────────────────────────┘
                                │
┌─────────────────────────────────────────────────────────────────┐
│                    REST API (FastAPI) :6080                     │
│  /api/modules  /api/stats  /api/proxy  /api/codegen  /api/auth  │
└───────────────────────────────┬─────────────────────────────────┘
                                │
┌─────────────────────────────────────────────────────────────────┐
│                    Web Frontend (Vue 3)                         │
│  Module Management | Tool Control | Proxy Config | Statistics   │
└─────────────────────────────────────────────────────────────────┘
                                │
┌─────────────────────────────────────────────────────────────────┐
│                    Data Layer (SQLite)                          │
│  Module Status | Tool Config | Call Statistics | Proxy Config   │
│  User Authentication                                            │
└─────────────────────────────────────────────────────────────────┘

📁 项目结构

MCPHub/
├── requirements.txt              # Python dependencies
├── README.md                     # This file
├── MCP_MODULE_DEV_GUIDE.md       # Module development guide
├── config/
│   ├── config.json               # Main configuration file
│   └── mcp_hub.db               # SQLite database
└── app/
    ├── main.py                   # FastAPI entry point
    ├── mcp_service.py            # MCP service initialization
    ├── my_mcp_middleware.py      # MCP middleware
    ├── config_py/                # Configuration management
    ├── managers/                 # Core managers
    │   ├── module_manager.py     # Module lifecycle
    │   ├── proxy_manager.py      # Proxy servers
    │   └── stats_manager.py      # Statistics management
    ├── api/                      # REST API
    ├── tools/                    # Built-in modules
    │   ├── t_autogui/            # GUI automation
    │   ├── t_cli/                # CLI commands
    │   ├── t_python/             # Python execution
    │   └── ...
    ├── tools_external/           # External plugins
    ├── toolsmcp/                 # MCP tool wrappers
    └── web/                      # Vue 3 frontend

⚙️ 配置

主配置文件: config/config.json

{
  "api": {
    "title": "MCPHub Service",
    "version": "1.0.0"
  },
  "server": {
    "host": "0.0.0.0",
    "port": 6080
  },
  "mcp": {
    "service_name": "mcphub",
    "host": "0.0.0.0",
    "port": 6081,
    "path": "/mcp",
    "tool_name_prefix": "",
    "module_enable": [
      {
        "enable": true,
        "module_name": "tools.t_cli.cli_mcp",
        "disable_tool": [],
        "config": {}
      }
    ]
  },
  "database": {
    "db_path": "./config/mcp_hub.db"
  },
  "auth": {
    "secret_key": "your-secret-key",
    "token_expire_hours": 24
  }
}
配置 说明
mcp.tool_name_prefix 用于区分多实例部署的工具名称前缀
mcp.module_enable 启动时自动加载的模块列表
module_enable[].disable_tool 模块中禁用的工具名称列表
module_enable[].config 传递给模块的自定义配置

🤝 贡献

欢迎投稿、错误报告和建议!

  1. 分叉此存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 创建拉取请求

📄 许可证

该项目根据MIT许可证获得许可。


🙏 致谢

  • FastMCP -快速构建MCP服务器的框架
  • MCP协议 -模型上下文协议规范
  • 快速API -现代高性能Python web框架

Empower AI Agents with Infinite Possibilities 🚀