MCP Gateway
MCP Gateway – MCP-Agent-Gateway
Einheitliches Gateway für den Zugriff und die Verwaltung mehrerer MCP-Server auf Unternehmensebene: Der übergeordnete LLM-Agent verbindet sich nur mit dem Gateway als einem einzigen Einstiegspunkt und kann dann die Tools aller dahinter liegenden MCP-Server aufrufen, wobei Authentifizierung, Ratenbegrenzung, Protokollierung und Metriken abgedeckt sind.
Architektur
┌─────────────────────────────┐
│ 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
Technologie-Stack
Python 3.12 · FastAPI · MCP Official SDK (stdio / SSE / Streamable HTTP) · pydantic-settings + YAML · structlog · Prometheus · SQLite (Schnittstellenabstraktion, austauschbar mit PostgreSQL) · pytest · Docker · GitHub Actions · uv
Schnellstart
uv sync # 安装依赖(自动准备 Python 3.12)
uv run uvicorn app.main:app --reload # 启动开发服务器
uv run pytest # 运行测试
uv run ruff check . # lint
docker compose up --build # 一键启动Nach dem Start aufrufen:
GET /health— GesundheitscheckGET /metrics— Prometheus-Metriken (Tool-Aufrufanzahl/-dauer:mcp_gateway_tool_calls_total,mcp_gateway_tool_call_duration_seconds)GET /docs— OpenAPI-Interaktionsdokumentation
Aufrufbeispiel (Demo-Key siehe Abschnitt auth in config/gateway.yaml):
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 enthält eine Mini-E-Commerce-Bibliothek (customers / products / orders) und stellt 4 Tools bereit: ask (chinesische Frage → automatisch generiertes und ausgeführtes schreibgeschütztes SQL), run_sql (direktes Ausführen von schreibgeschütztem SQL), list_tables (Tabellenstruktur), echo (Link-Debugging). NL2SQL ist eine Regel-Template-Engine, offline ohne Abhängigkeiten, die Schnittstelle ist von der LLM-Implementierung entkoppelt und kann nahtlos ersetzt werden.
Konfiguration
config/gateway.yaml (Priorität: Standardwerte im Code < YAML < Umgebungsvariablen 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 verwendet config/gateway.docker.yaml: demo_sql läuft als separater Container mit Streamable HTTP, das Gateway verbindet sich über http://demo_sql:9001/mcp.
Projektstruktur
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/ # 单元测试Entwicklungs-Roadmap
Phase 1: Framework + CI (/health, /metrics, Konfigurationszentrum, strukturiertes Logging)
Phase 2: Protokollebene (stdio/SSE/HTTP-Client für drei Transporte + Tool-Registrierungszentrum + Demo-Server)
Phase 3: Einheitliche API (GET /tools, POST /tools/{name}/call) + API-Key-Authentifizierung + Token-Bucket-Ratenbegrenzung
Phase 4: Tool-Aufrufmetriken + Upgrade von demo_sql_server auf NL2SQL + docker-compose mit zwei Containern (öffentliche Bereitstellung und Demo-Bildschirmaufzeichnung noch ausstehend)
Phase 5: Agent-Aufrufbeispiele + Open-Source-Promotion
Erweiterungspfade für Unternehmen
Multi-Tenancy + RBAC · Modell-Routing (analog zu One-API) · Audit-Compliance · Automatische Skalierung in K8s · OpenTelemetry-Tracing · Circuit Breaker / Caching
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