MCP Gateway
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Gateway查询demo_sql中客户数量"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Gateway — MCP Agent Gateway
Unified enterprise tool gateway for integrating and managing multiple MCP Servers: The upper-layer LLM Agent only needs to connect to a single gateway entry point to invoke tools provided by any number of MCP Servers behind it, with full coverage of authentication, rate limiting, logging, and metrics.
Architecture
┌─────────────────────────────┐
│ 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
Tech Stack
Python 3.12 · FastAPI · MCP Official SDK(stdio / SSE / Streamable HTTP)· pydantic-settings + YAML · structlog · Prometheus · SQLite(interface layer abstracted, replaceable with PostgreSQL)· pytest · Docker · GitHub Actions · uv
Quick Start
uv sync # 安装依赖(自动准备 Python 3.12)
uv run uvicorn app.main:app --reload # 启动开发服务器
uv run pytest # 运行测试
uv run ruff check . # lint
docker compose up --build # 一键启动After startup, access:
GET /health— Health checkGET /metrics— Prometheus metrics (includes tool call count/duration:mcp_gateway_tool_calls_total,mcp_gateway_tool_call_duration_seconds)GET /docs— OpenAPI interactive documentation
Call example (demo key can be found in the auth section of 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 comes with a built-in mini e-commerce database (customers / products / orders), providing 4 tools:
ask (Chinese question → automatically generate and execute read-only SQL), run_sql (directly execute read-only SQL),
list_tables (table structure), echo (link debugging). NL2SQL is a rule-based template engine,
offline with zero dependencies, interfaces decoupled from LLM implementation, smoothly replaceable.
Configuration
config/gateway.yaml (priority: code defaults < YAML < environment variable 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 uses config/gateway.docker.yaml: demo_sql runs as a standalone container with Streamable HTTP, the gateway connects via http://demo_sql:9001/mcp.
Project Structure
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/ # 单元测试Development Roadmap
Phase 1: Engineering skeleton + CI(/health, /metrics, configuration center, structured logging)
Phase 2: Protocol layer integration(stdio/SSE/HTTP three transport clients + tool registry + demo server)
Phase 3: Unified API(GET /tools, POST /tools/{{name}}/call)+ API Key authentication + Token bucket rate limiting
Phase 4: Tool call metrics + demo_sql_server upgrade NL2SQL + docker-compose dual containers(public deployment and demo video pending)
Phase 5: Agent call examples + open source promotion
Enterprise Extension Path
Multi-tenant + RBAC · Model routing (similar to One-API) · Audit compliance · K8s auto-scaling · OpenTelemetry tracing · Circuit breaking / caching
This server cannot be deployed
Maintenance
Related MCP Connectors
- gatewayOAuthai.sealgate
MCP gateway with runtime security policy, tool-call-level control, and audit of agent actions.
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
Zero-secret MCP gateway for AI agents: risk-scored, audited calls with human-in-the-loop approval.
One MCP endpoint for Claude, GPT & Gemini: 100+ tools + no-code connectors + agent workers.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA 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
- FlicenseNot gradedqualityAmaintenanceA production-ready MCP gateway and control plane that provides credential vault, policy engine, audit logging, and managed runtime for routing tool calls between AI agents and downstream MCP servers.58-
- FlicenseNot gradedqualityBmaintenanceSingle gateway that aggregates dozens of upstream MCP servers, enabling AI clients to connect once and access all tools.-
- AlicenseNot gradedqualityCmaintenanceA 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