MCP Gateway
MCP Gateway — MCP エージェントゲートウェイ
複数の MCP Server を統一的に接続・管理するエンタープライズ向けツールゲートウェイ。上位の LLM Agent はゲートウェイという一つのエントリポイントに接続するだけで、背後にある任意の複数の MCP Server が提供するツールを呼び出すことができ、認証、レート制限、ログ、メトリクスをすべてカバーします。
アーキテクチャ
┌─────────────────────────────┐
│ LLM Agent / 应用 │
│ (LangChain / OpenAI 等) │
└──────────────┬──────────────┘
│ 统一 REST API
┌──────────────▼──────────────┐
│ MCP Gateway (FastAPI) │
│ ┌────────────────────────┐ │
│ │ 鉴权 (API Key) │ │
│ │ 限流 (令牌桶) │ │
│ │ 日志 / 指标 (横切层) │ │
│ └───────────┬────────────┘ │
│ ┌───────────▼────────────┐ │
│ │ 工具注册中心 registry │ │
│ │ (聚合所有 server 工具) │ │
│ └───────────┬────────────┘ │
│ ┌───────────▼────────────┐ │
│ │ MCP 客户端 (多传输) │ │
│ └────────────────────────┘ │
└───────┬───────────┬───────────┘
stdio ──┤ ├── Streamable HTTP / SSE
┌──────────────▼──┐ ┌────▼───────────────┐
│ MCP Server #1 │ │ MCP Server #2 ... │
│ (demo_sql_server)│ │ (数据库/内部API等) │
└─────────────────┘ └─────────────────────┘Related MCP server: Peta Core
技術スタック
Python 3.12 · FastAPI · MCP 公式 SDK(stdio / SSE / Streamable HTTP)· pydantic-settings + YAML · structlog · Prometheus · SQLite(インターフェース層で抽象化、PostgreSQL に変更可能)· pytest · Docker · GitHub Actions · uv
クイックスタート
uv sync # 安装依赖(自动准备 Python 3.12)
uv run uvicorn app.main:app --reload # 启动开发服务器
uv run pytest # 运行测试
uv run ruff check . # lint
docker compose up --build # 一键启动起動後にアクセス:
GET /health— ヘルスチェックGET /metrics— Prometheus メトリクス(ツール呼び出し回数/所要時間:mcp_gateway_tool_calls_total、mcp_gateway_tool_call_duration_seconds)GET /docs— OpenAPI 対話型ドキュメント
呼び出し例(デモ Key は config/gateway.yaml の auth セクションを参照):
curl -H "X-API-Key: dev-key-please-change" http://localhost:8000/tools
curl -X POST http://localhost:8000/tools/demo_sql__ask/call \
-H "X-API-Key: dev-key-please-change" -H "Content-Type: application/json" \
-d '{"arguments": {"question": "有多少客户?"}}'demo_sql_server にはミニ E コマースデータベース(customers / products / orders)が組み込まれており、4 つのツールを提供:
ask(日本語の質問 → 自動生成・実行される読み取り専用 SQL)、run_sql(読み取り専用 SQL を直接実行)、
list_tables(テーブル構造)、echo(リンクデバッグ)。NL2SQL はルールベースのテンプレートエンジンで、
オフラインで依存関係ゼロ、インターフェースと LLM 実装は疎結合で、スムーズに置き換え可能。
設定
config/gateway.yaml(優先順位:コードデフォルト値 < YAML < 環境変数 GATEWAY_*):
gateway:
port: 8000
log_level: INFO
auth: # API Key 鉴权(SQLite 存储,启动种子写入)
db_path: data/gateway.db
api_keys:
- { key: dev-key-please-change, name: demo, rate_limit_per_minute: 60 }
servers: # MCP Server 声明式接入,无需改代码
- name: demo_sql
transport: stdio # stdio / sse / http
command: python
args: ["servers/demo_sql_server/server.py"]Docker Compose では config/gateway.docker.yaml を使用:demo_sql は独立したコンテナで
Streamable HTTP を実行し、ゲートウェイは http://demo_sql:9001/mcp 経由で接続。
プロジェクト構造
app/
├── main.py # FastAPI 入口
├── config.py # 配置中心(pydantic-settings + YAML)
├── core/ # 横切层:security / rate_limit / logging / metrics
├── mcp/ # 协议层:registry / client / transports / schemas
├── api/ # 接口层:deps.py + routes/
└── schemas/ # Pydantic 模型
servers/demo_sql_server/ # 示例 MCP Server(自然语言→SQL,阶段 2/4)
examples/ # LLM Agent 调用示例(阶段 5)
tests/ # 单元测试開発ロードマップ
フェーズ 1:エンジニアリングスケルトン + CI(/health、/metrics、設定センター、構造化ログ)
フェーズ 2:プロトコル層の確立(stdio/SSE/HTTP 三つのトランスポートクライアント + ツールレジストリ + デモサーバー)
フェーズ 3:統一 API(GET /tools、POST /tools/{name}/call)+ API Key 認証 + トークンバケットレート制限
フェーズ 4:ツール呼び出しメトリクス + demo_sql_server の NL2SQL アップグレード + docker-compose デュアルコンテナ(パブリックデプロイとデモ録画は未対応)
フェーズ 5:Agent 呼び出し例 + オープンソースプロモーション
エンタープライズ拡張パス
マルチテナント + RBAC · モデルルーティング(One-API に類似)· 監査コンプライアンス · K8s 自動スケーリング · OpenTelemetry トレーシング · サーキットブレーカー / キャッシュ
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceA production-ready unified entry point for AI agents that implements the Model Context Protocol (MCP). It provides a secure gateway with rate limiting, authentication, and observability for managing and proxying requests to multiple downstream APIs.MIT
- Flicense-qualityBmaintenanceSingle gateway that aggregates dozens of upstream MCP servers, enabling AI clients to connect once and access all tools.
- Alicense-qualityDmaintenanceA unified MCP gateway that aggregates multiple MCP servers and API plugins behind a single endpoint with authentication, rate limiting, audit logging, REST API bridge, and web dashboard.8MIT
Related MCP Connectors
Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/NightR71/mcp_gateway_demo_nightr71'
If you have feedback or need assistance with the MCP directory API, please join our Discord server