Skip to main content
Glama

mcp-agent-mesh

MCP用メッシュゲートウェイ — プレフィックスベースのルーティング、ヘルスチェック、サーキットブレーカーによるフェイルオーバー、そしてstdioとStreamable HTTPの両方に対応した統合エンドポイントにより、1つのMCPクライアントがN台のMCPサーバーに到達できるようにします。

機能

mcp-agent-meshは、複数のアップストリームMCPサーバーを1つの論理MCPサーバーの背後に集約します。すべてのアップストリームのツールはserver_name.tool_nameプレフィックスの下で公開されるため、メッシュに接続するクライアントには、健全なすべてのアップストリームのツールを含む単一の tools/listが見えます。

ツール呼び出しが失敗してサーバーのサーキットブレーカーがオープンした場合、メッシュはクライアントにエラーを返す前に、設定済みのレプリカサーバーへ自動的にフェイルオーバーします。

Related MCP server: mcp-0ne

特徴

特徴

説明

集約

tools/list は、すべてのアップストリームサーバーのツールを1つのフラットなリストにマージします

プレフィックスルーティング

math.add を呼び出すと、メッシュは math サーバーにルーティングします

サーキットブレーカー

しきい値とタイムアウトを設定可能なサーバー単位のサーキットブレーカー

ヘルスポーリング

バックグラウンドのpingループがアップストリームの早期障害を検出します

フェイルオーバー

設定可能なフェイルオーバーグループにより、エイリアスが障害発生サーバーの代役を務めます

デュアルトランスポート

stdio MCPサーバーおよびStreamable HTTPサーバーとして動作します

タイムアウトとリトライ

すべてのアップストリーム呼び出しは asyncio.wait_for でラップされます

アーキテクチャ

                     ┌─────────────────────┐
  MCP client ───────►│   MeshGateway       │
                     │   (stdio / HTTP)    │
                     └────────┬───────────┘
                              │ tools/list
                              │ tools/call
                    ┌─────────┼─────────────┐
                    ▼         ▼             ▼
               ┌────────┐ ┌─────────┐ ┌─────────┐
               │ Server │ │ Server  │ │ Server  │
               │  "A"   │ │  "B"   │ │  "C"   │   (upstream MCP servers)
               └────────┘ └─────────┘ └─────────┘

モジュール

モジュール

役割

config.py

YAML設定の解析 — ServerConfig、MeshConfig

health.py

サーバー単位の CircuitBreaker + ServerHealthMonitor(バックグラウンドping)

router.py

プレフィックスルーティング(server.tool)、フェイルオーバーグループの解決、ツールレジストリ

gateway.py

MeshGateway — アップストリームへの接続、ツール一覧の集約、呼び出しのルーティング、stdio + HTTPでのMCP提供

インストール

pip install -e ".[dev]"

使用方法

CLI(stdioモード)

mcp-agent-mesh --config examples/mesh.yaml --transport stdio

HTTPモード

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

Maintenance

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    A 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
  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP Gateway that aggregates multiple upstream MCP servers into a single endpoint with persistent connections, tool registry, and authentication.
    16 npm
    2
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    A 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.
    1
    MIT