@zhangzwd/mcp-gateway
A lightweight MCP gateway that aggregates multiple MCP services into a unified stdio interface, automatically prefixing tool names with the service name to avoid conflicts.
README
@zhangzwd/mcp-gateway
一个轻量级 MCP 网关,将多个 MCP 服务聚合成一个统一的 stdio 接口。
每个子服务的工具会自动加上 {服务名}_ 前缀,避免工具名冲突。
安装
npx @zhangzwd/mcp-gateway
无需全局安装,npx 会自动下载运行。
配置文件
默认读取 ~/.mcp/gateway.config.json,可通过环境变量 MCP_GATEWAY_CONFIG 覆盖路径。
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "你的API_KEY"]
},
"另一个服务名": {
"command": "node",
"args": ["path/to/server.js"]
}
}
}
mcpServers 中的每个 key 就是服务名,会作为工具前缀。例如 context7 服务的 resolve-library-id 工具对外暴露为 context7_resolve-library-id。
在 AI 工具中使用
opencode.json
{
"mcp": {
"gateway": {
"type": "local",
"command": ["npx", "-y", "@zhangzwd/mcp-gateway"]
}
}
}
codex config.toml
[mcp_servers.gateway]
command = "npx"
args = ["-y", "@zhangzwd/mcp-gateway"]
reasonix config.json
{
"mcpServers": {
"gateway": {
"command": "npx",
"args": ["-y", "@zhangzwd/mcp-gateway"]
}
}
}
项目结构
~/.mcp/gateway.config.json # 配置文件(你编辑这个)
~/.mcp-gateway/
gateway.js # 主程序(已发布到 npm)
package.json
README.md
工作原理
- 读取
gateway.config.json,获取子 MCP 服务列表 - 为每个子服务启动一个子进程(stdio 通信)
- 调用
listTools获取工具列表,工具名加{服务名}_前缀 - 将自己注册为一个 MCP Server,暴露合并后的工具列表
- 收到
tools/call请求时,根据工具名前缀路由到对应的子服务
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.