mcp-gateway
MCP Gateway
一个用于 Model Context Protocol 服务器的自托管控制平面。在一个地方定义你使用的每个 MCP 服务器,通过 Web GUI 管理它们,并为你的代理提供统一端点——既可以按服务器,也可以按整个 组 服务器(工具带命名空间)。
Claude Code · Claude Desktop · Cursor · VS Code · your agent
│ Streamable HTTP /mcp/servers/<id> /mcp/groups/<id> (+ API key)
▼
┌────────────────────── MCP Gateway ──────────────────────┐
│ web GUI · admin REST API · sessions · logs │
│ groups: namespaced tools pg-analytics__execute_sql … │
│ upstream manager: start/stop, restart w/ backoff, │
│ health checks, idle stop, tool filters & renames │
└───────┬──────────────────┬──────────────────┬───────────┘
stdio (npx/uvx/docker) Streamable HTTP legacy SSE
Postgres, filesystem… remote MCP servers older servers场景。 一个代理需要两个 Postgres 数据库。你在 GUI 中添加 pg-analytics 和 pg-orders(来自 PostgreSQL (DBHub) 模板),将它们放入名为 databases 的组,并将代理指向 http://gateway:8808/mcp/groups/databases。代理会看到 pg-analytics__execute_sql 和 pg-orders__execute_sql;网关负责管理这些进程、凭据、重启和日志。一个完整且可运行的版本位于 examples/postgres-scenario。
功能
任意上游传输 — stdio 进程(
npx、uvx、docker run等),Streamable HTTP 和带 bearer/basic/header 认证的旧版 SSE 远程服务。生命周期管理 — 自动/延迟启动、空闲停止、带指数退避和上限的重启、健康检查 ping、启动/请求/工具调用超时、捕获的 stderr。
组 — 多个服务器位于同一端点之后;工具和提示词带命名空间(
prefix__tool、.或-),或采用带冲突处理的直通;按成员过滤;组合指令;隐式all组。工具策略 — 包含/排除 glob 模式,按服务器隐藏、重命名和重新描述工具。
完整 MCP 代理 — 工具、资源(+模板、订阅)、提示词、补全、日志、进度、取消、
list_changed传播,以及路由回原始会话的服务器→客户端采样 / 引导 / 根。下游传输 — Streamable HTTP(有状态的可恢复流,或无状态)、旧版 SSE,外加
mcp-gateway-connect,一个面向 Claude Desktop 等客户端的 stdio 桥接。安全 — API 密钥(哈希存储、限定到服务器/组、可过期)、用于 GUI/API 的管理员令牌、机密信息脱敏、
${ENV}插值让机密永远不必写入配置、DNS 重绑定保护、CORS 允许列表。GUI — 仪表盘、包含 16 个模板的服务器目录(Postgres ×3、MySQL、SQLite、filesystem、GitHub、Playwright、Context7、fetch、memory,……)、带 测试连接 的标签式编辑器、带 试用 的工具浏览器、资源/提示词浏览器、实时日志、指标、按客户端的连接片段、会话、设置、导入/导出(Claude Desktop / Cursor / VS Code 的
mcpServers文件)。
Related MCP server: Master MCP Server
截图
仪表盘——正在运行的服务器、组、活动会话和实时事件流:

服务器目录,一目了然地显示传输方式、状态、工具数量和重启次数:

服务器的详情视图——运行时和端点信息,以及可直接从 GUI 调用工具的工具浏览器:

快速开始
要求:Node.js ≥ 20(外加运行你所选上游服务器所需的 npx/uvx/docker)。
git clone <this repo> mcp-gateway && cd mcp-gateway
npm install
npm run build
npm start # → http://127.0.0.1:8808然后在 GUI 中:服务器 → 添加服务器 → PostgreSQL (DBHub) → 粘贴 DSN → 测试连接 → 创建服务器。打开服务器的 连接 选项卡,复制适合你客户端的片段,例如:
claude mcp add --transport http pg-analytics http://127.0.0.1:8808/mcp/servers/pg-analytics开发模式(Vite 在 :5173 上热重载,网关在 :8808 上):npm run dev。
Docker
docker compose up -d --build # GUI on http://localhost:8808, data in ./data该镜像内置 node/npx、uvx 和 git,因此基于 npm 和 Python 的 MCP 服务器可以在容器内启动。当端口可被其他主机访问时,在环境中设置 GATEWAY_ADMIN_TOKEN。要预加载配置,请挂载一个文件并设置 GATEWAY_SEED_CONFIG=/path/to/config.json——它会在首次启动时被复制到数据卷。
如何协同工作
概念 | 说明 |
服务器 | 一个上游 MCP 服务器定义:传输、生命周期、工具策略、转发选项。端点为 |
组 | 一组有序的服务器,作为单个虚拟 MCP 服务器对外暴露,工具/提示词带命名空间,资源被合并。端点为 |
API 密钥 | 用于 |
会话 | 一个已连接的下游客户端(Streamable HTTP 或 SSE)。可在 GUI 中查看和关闭。 |
管理员令牌 | 保护 GUI 和 |
配置是一个单独的 JSON 文件(data/config.json,权限 0600,原子写入,保留 .bak)——每个字段请参阅 docs/CONFIG.md。每个工具对应的客户端设置在 docs/CLIENTS.md;完整设计在 docs/SPEC.md。GUI 还内置了一个 文档 页面(/docs,位于设置旁边),逐步讲解网关的工作原理以及如何添加、自定义和连接服务器。
CLI
mcp-gateway serve [--host 127.0.0.1] [--port 8808] [--data-dir ./data] [--config <file>] [--public-url <url>] [--log-level info]
mcp-gateway import <file> [--format gateway|mcpServers] [--mode merge|replace] # into the config file (restart to apply)
mcp-gateway export [--format gateway|mcpServers] [--secrets] [--out <file>]
mcp-gateway hash-token <token> # sha256 for settings.auth.adminTokenHash
mcp-gateway connect <url> [--api-key K] [--header 'Name: v'] [--sse] # stdio ⇄ HTTP bridge
mcp-gateway-connect <url> … # same bridge as a standalone package (@mcp-gateway/connect)环境变量:GATEWAY_HOST、GATEWAY_PORT、GATEWAY_DATA_DIR、GATEWAY_CONFIG、GATEWAY_ADMIN_TOKEN、GATEWAY_PUBLIC_URL、GATEWAY_LOG_LEVEL、GATEWAY_REQUIRE_API_KEY、GATEWAY_WEB_DIR、GATEWAY_SEED_CONFIG(Docker)。优先级:CLI 标志 > 环境变量 > config.json > 默认值。
端点
路径 | 用途 |
| Streamable HTTP MCP 端点 |
| 旧版 HTTP+SSE |
| 存活检查(无需认证) |
| 管理员 REST API(JSON;设置后使用 |
| 由 GUI 使用的服务器推送事件流(状态、日志、会话、指标) |
| Web GUI |
完整的路由列表及请求/响应格式见 docs/SPEC.md §7。
安全说明
如果没有管理员令牌,GUI/API 将处于开放状态:请保持默认的回环绑定,或设置
GATEWAY_ADMIN_TOKEN。在将
/mcp暴露到 localhost 之外前,请开启 需要 API 密钥;将密钥限定到每个代理所需的服务器/组。机密信息:优先使用
${VAR}引用而非字面值;在 API 响应和导出中,看起来像密钥的键下的值会被脱敏(?secrets=1/ 包含机密 导出会包含它们)。对任何面向互联网的服务,在前面放置一个 TLS 终止反向代理(Anthropic API MCP 连接器需要)。
网关会执行你配置的命令——任何拥有管理员权限的人都可在主机上运行任意进程。
开发
npm run dev # gateway (tsx watch) + Vite dev server
npm run typecheck # all workspaces
npm test # vitest: shared unit tests, server integration tests (real stdio/HTTP fixtures), bridge tests
npm run build # server bundle (esbuild), connect bundle, web (vite)目录结构:packages/shared(zod 配置模式、DTO、模板、命名辅助工具——浏览器安全)、packages/server(Express 5 + @modelcontextprotocol/sdk:上游管理器、代理服务器、会话、REST/MCP 路由、CLI)、packages/web(React 19 + Vite)、packages/connect(stdio 桥接)、examples/postgres-scenario(docker-compose 演示)。
限制 / 路线图
尚未实现对上游服务器的 OAuth(请使用 bearer/basic/header 认证);OAuth 用于下游客户端也未实现(改用 API 密钥)。
组中的资源不带命名空间——URI 会路由到其所属服务器;多个成员间相同的 URI 将解析到第一个成员。
没有速率限制;如果需要,请在前面放一个反向代理。
单进程、内存中的会话和日志(重启会丢弃会话;客户端需重新初始化)。
许可证
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
- AlicenseNot gradedqualityDmaintenanceA central hub that aggregates multiple MCP resource servers into a single unified interface, enabling users to access tools and capabilities from multiple backend servers through one connection point.45202MIT
- FlicenseNot gradedqualityNot gradedmaintenanceAggregates multiple MCP servers behind a single, secure endpoint with unified tool/resource discovery, OAuth authentication, and resilient request routing. Enables users to manage and interact with multiple MCP backends through one centralized interface with load balancing and circuit breakers.2
- FlicenseNot gradedqualityDmaintenanceA centralized gateway and router that integrates multiple MCP servers into a single endpoint with built-in policy enforcement and secret management. It features a Web GUI for managing tool access, audit logs, and multi-environment configurations across various sub-servers.
- AlicenseNot gradedqualityBmaintenanceAggregates multiple backend MCP servers into a single unified interface with optional web management UI for tool control and configuration.45192MIT
Related MCP Connectors
34 production API tools over one hosted MCP endpoint.
MCP Server for agents to onboard, pay, and provision services autonomously with InFlow
MCP server for AI access to Swagger by SmartBear.
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/shamalawy/mcp-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server