Skip to main content
Glama

MCP Gateway

PyPI version Python License

複数のMCP(Model Context Protocol)サーバーを単一のHTTP/SSEエンドポイントの背後に集約するスタンドアロンCLIゲートウェイで、Code Mode を備えています。複数のMCPサーバーを使用する際、LLMの入力トークン使用量を最大92%削減します。

特徴

  • マルチサーバー集約 — 複数のMCPサーバー(HTTP、SSE、Stdio、Streamable HTTP)に接続し、単一のエンドポイントを通じて公開します

  • Code Mode — LLMがすべてのスキーマを事前に読み込むことなくツールを動的に発見・使用できる4つのメタツール

  • OAuth 2.0サポート — 動的クライアント登録(RFC 7591)とトークン保存を備えた組み込みOAuthフロー

  • 密閉型サンドボックス — 安全なコード実行のためのStarlarkベースのサンドボックス

  • MCPプロトコル準拠 — Claude Desktop、Cursor、およびMCP互換のクライアントで動作します

Related MCP server: ToolMux

インストール

pip install mcp-gway

またはmiseを使用する場合:

mise install
uv sync

クイックスタート

# Add an MCP server
mcp-gway add youtube --type http --url http://localhost:3001/mcp

# Add a stdio server
mcp-gway add filesystem --type stdio --command npx --args '["-y", "@anthropic/mcp-filesystem"]'

# Add a server requiring OAuth
mcp-gway add supabase --type streamable-http --url https://mcp.supabase.com/mcp

# List all servers
mcp-gway list

# Start the gateway
mcp-gway serve --port 8080

Claude Desktopから接続

Claude Desktopの設定(~/Library/Application Support/Claude/claude_desktop_config.json)に追加します:

{
  "mcpServers": {
    "gateway": {
      "url": "http://localhost:8080/mcp"
    }
  }
}

コマンド

コマンド

説明

mcp-gway add

MCPサーバーを追加し、.pyiスタブを生成します

mcp-gway remove

MCPサーバーを削除します

mcp-gway update

サーバーのツールを更新します

mcp-gway list

接続されているすべてのサーバーを一覧表示します

mcp-gway inspect

サーバーのツールシグネチャを表示します

mcp-gway refresh

接続を更新し、ツールを再発見します

mcp-gway serve

ゲートウェイサーバーを起動します

Code Mode

接続すると、ゲートウェイは4つのメタツールを公開します:

ツール

説明

listToolFiles

利用可能なすべての.pyiスタブファイルを一覧表示します

readToolFile

スタブから関数シグネチャを読み取ります

getToolDocs

ツールの詳細なドキュメントを取得します

executeToolCode

サンドボックス化されたStarlarkインタープリターでコードを実行します

OAuth認証

OAuthを必要とするサーバー(例:Supabase)の場合:

# Trigger OAuth flow
mcp-gway refresh supabase --auth

# Or store token manually
mkdir -p ~/.config/mcp-gway/tokens
echo '{"access_token": "YOUR_TOKEN"}' > ~/.config/mcp-gway/tokens/supabase.json

開発

# Install dependencies
mise install
uv sync

# Run tests
uv run pytest -v

# Lint and format
uv run ruff check src/ tests/
uv run ruff format src/ tests/

アーキテクチャ

┌─────────────────────────────────────────────────────────┐
│                    MCP Gateway                          │
├─────────────────────────────────────────────────────────┤
│  CLI (click)     │  HTTP/SSE Server (Starlette)        │
│  - add           │  - POST /mcp (JSON-RPC)             │
│  - remove        │  - GET /mcp (SSE stream)            │
│  - list          │  - POST /mcp/messages               │
│  - refresh       │                                     │
├─────────────────────────────────────────────────────────┤
│  Code Mode (4 meta-tools)     │  Starlark Sandbox      │
│  - listToolFiles               │  - Hermetic execution  │
│  - readToolFile                │  - Server injection    │
│  - getToolDocs                 │                        │
│  - executeToolCode             │                        │
├─────────────────────────────────────────────────────────┤
│  Registry (.pyi files)        │  OAuth2 (RFC 7591)     │
│  - servers/*.pyi               │  - Dynamic registration│
│  - Tool signatures             │  - Token storage       │
└─────────────────────────────────────────────────────────┘
         │                │                │
    ┌────┴────┐      ┌────┴────┐      ┌────┴────┐
    │ Server1 │      │ Server2 │      │ Server3 │
    │ (HTTP)  │      │ (SSE)   │      │ (Stdio) │
    └─────────┘      └─────────┘      └─────────┘

ライセンス

MIT

Maintenance

ActivityNo data
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Aggregates multiple MCP servers into a single endpoint, enabling LLM clients to access tools, resources, and prompts from various backends through one connection.
    9 npm
    MIT
  • A
    license
    B
    quality
    C
    maintenance
    Aggregates multiple MCP servers via a single interface with token optimization and multiple operating modes (Gateway, Meta, Proxy, Search, Code).
    7
    8
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Centralizes management and routing of multiple MCP servers, exposing them to AI clients via HTTP/SSE endpoints with configurable visibility, sharing, and smart routing.
    1,706 npm
    Apache 2.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    Centralized management and routing of multiple MCP servers via unified Streamable HTTP/SSE endpoints, with granular group visibility, smart routing, and authentication.
    1,706 npm
    Apache 2.0