MCP Gateway
MCP Gateway — Gateway de Agentes MCP
Gateway empresarial para unificar y gestionar múltiples servidores MCP: el LLM Agent de capa superior solo necesita conectar con el gateway como punto de entrada para invocar herramientas proporcionadas por cualquier número de servidores MCP detrás, cubriendo por completo autenticación, limitación de tasa, registro y métricas.
Arquitectura
┌─────────────────────────────┐
│ 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
Stack tecnológico
Python 3.12 · FastAPI · SDK oficial de MCP (stdio / SSE / Streamable HTTP) · pydantic-settings + YAML · structlog · Prometheus · SQLite (capa de interfaz abstracta, intercambiable por PostgreSQL) · pytest · Docker · GitHub Actions · uv
Inicio rápido
uv sync # 安装依赖(自动准备 Python 3.12)
uv run uvicorn app.main:app --reload # 启动开发服务器
uv run pytest # 运行测试
uv run ruff check . # lint
docker compose up --build # 一键启动Una vez iniciado, acceder a:
GET /health— verificación de saludGET /metrics— métricas de Prometheus (incluye número/duración de llamadas a herramientas:mcp_gateway_tool_calls_total,mcp_gateway_tool_call_duration_seconds)GET /docs— documentación interactiva de OpenAPI
Ejemplo de llamada (ver clave de demostración en la sección auth de 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 incluye una base de datos de mini comercio electrónico (customers / products / orders), y proporciona 4 herramientas:
ask (pregunta en chino → genera y ejecuta automáticamente SQL de solo lectura), run_sql (ejecuta directamente SQL de solo lectura),
list_tables (estructura de tablas), echo (depuración de enlace). NL2SQL es un motor de plantillas basado en reglas,
sin dependencias externas, con interfaz desacoplada de la implementación del LLM, reemplazable de forma fluida.
Configuración
config/gateway.yaml (prioridad: valores por defecto del código < YAML < variables de entorno 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 usa config/gateway.docker.yaml: demo_sql se ejecuta como un contenedor independiente con
Streamable HTTP, el gateway se conecta a través de http://demo_sql:9001/mcp.
Estructura del proyecto
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/ # 单元测试Hoja de ruta de desarrollo
Fase 1: esqueleto del proyecto + CI (/health, /metrics, centro de configuración, registro estructurado)
Fase 2: capa de protocolo (cliente triple transporte stdio/SSE/HTTP + registro central de herramientas + servidor de demostración)
Fase 3: API unificada (GET /tools, POST /tools/{name}/call) + autenticación por API Key + limitación de tasa con token bucket
Fase 4: métricas de llamadas a herramientas + actualización de demo_sql_server a NL2SQL + docker-compose de dos contenedores (pendiente despliegue público y grabación de demostración)
Fase 5: ejemplo de invocación de Agent + promoción de código abierto
Rutas de expansión empresarial
Multiinquilino + RBAC · Enrutamiento de modelos (similar a One-API) · Cumplimiento de auditoría · Autoescalado en K8s · Trazado de enlaces con OpenTelemetry · Disyuntor/ degradación / caché
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