MCP Gateway

MCP Gateway

A TypeScript gateway that aggregates multiple MCP servers into a single endpoint, enabling AI agents to access tools from many backends through one connection.

Category
访问服务器

README

MCP Gateway

A TypeScript gateway that aggregates multiple MCP (Model Context Protocol) servers into a single endpoint, enabling AI agents to access tools from many backends through one connection.

AI Agent
   │
   ▼
MCP Gateway  ←─── servers.json (config)
   │
   ├── Ceph Storage Assistant  (fastmcp)
   ├── Other MCP Server        (sse / streamable-http)
   └── Local Tool              (stdio)

⚠️ Agent Support

Currently, MCP Gateway officially supports Hermes Agent only.

Hermes connects using the MCP Streamable HTTP protocol (2025-11-25) via mcp.client.streamable_http. Support for other agents (LangChain, AutoGen, OpenAI Agents SDK, etc.) is planned for future development.


Features

  • Multi-server aggregation — connect as many MCP servers as needed, tools are merged into one list
  • Namespace isolation — tools are prefixed with server ID (ceph_alpha__get_health_summary) so agents know exactly which backend to target, even when multiple servers expose the same tool names
  • 4 transport types — supports all current MCP transport protocols plus a custom Ceph-compatible transport
  • Persistent configservers.json is the single source of truth; adding/removing servers via the dashboard persists across restarts
  • Web dashboard — visual overview of connected servers and aggregated tools
  • Docker-ready — runs in a container with host networking for internal backend access

Transport Types

Value Protocol Use when
streamable-http MCP 2025-11-25 Server uses modern Streamable HTTP
sse MCP 2024-11-05 Server uses legacy SSE protocol
fastmcp Custom (Ceph) Ceph Storage Assistant — persistent POST stream
stdio stdio Local process (npx, python, etc.)

Quick Start

1. Start the gateway

docker compose up -d --build

Dashboard: http://localhost:3010

2. Add MCP servers

Open the dashboard and click "Add New MCP-Client". Select the transport type, enter the URL and an ID — the server connects immediately and is saved automatically.

servers.json is automatically updated by the gateway whenever you add or remove a server via the dashboard or API. There is no need to edit this file manually.

Only edit it directly if you want to pre-configure servers before the very first docker compose up.

3. Connect Hermes

In your Hermes config.yaml:

mcp_servers:
  Ceph-Alpha:
    url: http://localhost:3010/sse?apiKey=mcp_gateway_secret_123

Hermes will discover all aggregated tools automatically. Tools are namespaced by server ID:

  • ceph_alpha__get_health_summary
  • ceph_alpha__get_cluster_capacity
  • my_other_mcp__some_tool

Configuration

Environment variables (docker-compose.yaml)

Variable Default Description
PORT 3010 Gateway listen port
API_KEY mcp_gateway_secret_123 Auth key required in ?apiKey=
SERVERS_CONFIG /app/servers.json Path to servers config file

servers.json schema

[
  { "id": "string", "transport": "streamable-http", "url": "http://..." },
  { "id": "string", "transport": "sse",             "url": "http://..." },
  { "id": "string", "transport": "fastmcp",         "url": "http://..." },
  { "id": "string", "transport": "stdio", "command": "npx", "args": ["pkg"] }
]

servers.json is automatically updated whenever you add or remove a server via the dashboard or API. Only edit it manually to pre-configure servers before the first docker compose up — after that, use the dashboard.


Management API

# List connected servers + status
curl http://localhost:3010/api/status

# List all aggregated tools
curl http://localhost:3010/api/tools

# Add a server at runtime (persisted to servers.json)
curl -X POST http://localhost:3010/api/servers \
  -H "Content-Type: application/json" \
  -d '{"id":"new-server","transport":"streamable-http","url":"http://..."}'

# Remove a server at runtime (removed from servers.json)
curl -X DELETE http://localhost:3010/api/servers/new-server

# Test tools/list as an agent would
curl -X POST "http://localhost:3010/sse?apiKey=mcp_gateway_secret_123" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":1,"params":{}}'

Development

# Install dependencies
npm install

# Run in dev mode (hot reload)
npm run dev

# Build
npm run build

# Start production
npm start

# Docker
docker compose up -d --build   # build & start
docker compose restart          # restart (picks up servers.json changes)
docker compose logs -f          # stream logs

Project Structure

mcp-gateway/
├── src/
│   ├── index.ts        # Express app, /sse endpoint, management API
│   ├── aggregator.ts   # Tool/resource/prompt fan-out + namespace prefixing
│   ├── upstream.ts     # Transport classes, UpstreamManager
│   └── config.ts       # Zod schema for servers.json
├── public/             # Web dashboard (HTML/CSS/JS)
├── docs/
│   └── plan.md         # Architecture & issue history
├── servers.json        # Upstream server registry (persistent)
└── docker-compose.yaml

Roadmap

  • [ ] Support for additional AI agents (LangChain, AutoGen, OpenAI Agents SDK, ...)
  • [ ] Auto-reconnect on upstream stream drop
  • [ ] Health check endpoint per upstream server
  • [ ] Authentication per upstream (API key injection)

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选