mcp-agent-mesh
mcp-agent-mesh
面向 MCP 的网格网关 — 让一个 MCP 客户端能够访问 N 个 MCP 服务器,具备前缀路由、健康检查、熔断器故障转移,以及同时基于 stdio 和 Streamable HTTP 的统一端点。
它能做什么
mcp-agent-mesh 将多个上游 MCP 服务器聚合在单个逻辑 MCP 服务器之后。每个上游工具都以 server_name.tool_name 前缀暴露,因此连接到网格的客户端会看到一个单一的 tools/list,其中包含来自所有健康上游的工具。
当工具调用失败且该服务器的熔断器打开时,网格会在向客户端返回错误之前,自动故障转移到配置的副本服务器。
Related MCP server: mcp-0ne
功能
功能 | 描述 |
聚合 |
|
前缀路由 | 调用 |
熔断器 | 每服务器熔断器,支持可配置的阈值与超时 |
健康轮询 | 后台 ping 循环可提前发现上游故障 |
故障转移 | 可配置的故障转移组让别名接管故障服务器 |
双传输 | 同时作为 stdio MCP 服务器 和 Streamable HTTP 服务器运行 |
超时与重试 | 每次上游调用都包装在 |
架构
┌─────────────────────┐
MCP client ───────►│ MeshGateway │
│ (stdio / HTTP) │
└────────┬───────────┘
│ tools/list
│ tools/call
┌─────────┼─────────────┐
▼ ▼ ▼
┌────────┐ ┌─────────┐ ┌─────────┐
│ Server │ │ Server │ │ Server │
│ "A" │ │ "B" │ │ "C" │ (upstream MCP servers)
└────────┘ └─────────┘ └─────────┘模块
模块 | 职责 |
| YAML 配置解析 — |
| 每服务器的 |
| 前缀路由( |
|
|
安装
pip install -e ".[dev]"使用
CLI(stdio 模式)
mcp-agent-mesh --config examples/mesh.yaml --transport stdioHTTP 模式
mcp-agent-mesh --config examples/mesh.yaml --transport http --host 0.0.0.0 --port 8000作为客户端配置(Claude Code / Codex / OpenCode)
{
"mcpServers": {
"mesh": {
"command": "mcp-agent-mesh",
"args": ["--config", "/path/to/mesh.yaml", "--transport", "stdio"]
}
}
}{
"mcpServers": {
"mesh": {
"url": "http://127.0.0.1:8000/mcp"
}
}
}配置
完整示例请参见 examples/mesh.yaml。关键字段:
servers:
- name: math # tool-name prefix
transport: stdio # "stdio" or "http"
command: python # stdio: how to spawn
args: ["-m", "..."]
url: http://... # http: endpoint URL
timeout: 30.0
circuit_breaker_threshold: 3
circuit_breaker_timeout: 300.0
failover_groups:
math: [math_backup] # failover aliases for the "math" server测试
pytest tests/ -v测试套件使用内存中的模拟 MCP 服务器(无需真实子进程),涵盖配置解析、熔断器逻辑、前缀路由、工具聚合、故障转移以及网关的端到端行为。
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP Gateway: wrap any MCP server with cold-start retries, uptime SLA, and per-execution MPP billing.
Stateless MCP gateway and OTel span-streaming bridge for hosted MCP servers.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
Managed MCP gateway with OAuth, per-agent permissions, shared accounts and activity logs.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceGateway MCP Server - Route MCP requests intelligently to multiple backend servers.3MIT
- AlicenseNot gradedqualityCmaintenanceA standalone MCP gateway that multiplexes multiple backend MCP servers behind a single endpoint, supporting both HTTP and stdio transports. It allows users to dynamically manage backends at runtime and organizes tools using a configurable namespace prefix.MIT
- AlicenseNot gradedqualityCmaintenanceMCP Gateway that aggregates multiple upstream MCP servers into a single endpoint with persistent connections, tool registry, and authentication.33 npm2MIT
- AlicenseNot gradedqualityAmaintenanceA universal MCP gateway that aggregates multiple MCP servers into a single endpoint, providing features like hot-reload, auto-healing, and a hook system for request/response mutation.1MIT