Skip to main content
Glama

MCP Gateway - 二级路由聚合网关

一个 MCP 网关,将多个第三方 MCP Server 聚合为少量顶层工具,大幅减少 LLM 的上下文占用与解决某些IDE没法支持太多tools的问题。

效果图

网关mcp示例图

工作原理

┌─────────────────────────────────────────────────────┐
│                   MCP Gateway                       │
├─────────────────────────────────────────────────────┤
│ 对外暴露的工具 (仅 2 个):                           │
│   - use_git(action, params)                         │
│   - use_filesystem(action, params)                  │
├─────────────────────────────────────────────────────┤
│ 内部连接:                                           │
│   ├── mcp-server-filesystem      │
│   └── mcp-server-git                               │
└─────────────────────────────────────────────────────┘

效果:无论后台有多少个 MCP Server,LLM 只看到 N 个工具(N = Server 数量)。

安装

# 克隆项目
git clone https://github.com/LunFengChen/Gateway-Mcp.git
cd Gateway-Mcp

pip install fastmcp

配置

编辑 Gateway-Mcp 中的 mcps_config.json,添加您原来json中的 MCP Server:

{
  "mcpServers": {
    "filesystem": {
      "command": "【你的python.exe路径】",
      "args": ["【你的py文件路径】"]
    },
    "git": {
      "command": "【你的python.exe路径】",
      "args": ["【你的py文件路径】"]
    },
    "github": {
      "command": "【你的python.exe路径】",
      "args": ["【你的py文件路径】"]
    }
  }
}

去IDE中配置顶层mcp,也就是这里的Gateway-Mcp,配置文件的参考如下(需要你修改 python.exe和gateway_mcp_server.py文件路径哦)

理论上autoApprove不需要加,但是为了解决某些ide不能自动调用工具的问题,我加了一下,你的估计不需要

{
  "mcpServers": {
    "GateWay-Mcp": {
      "command": "C:\\Users\\xiaofeng\\.pyenv\\pyenv-win\\versions\\3.11.9\\python.exe",
      "args": [
        "C:\\Users\\xiaofeng\\Desktop\\projects\\Gateway-Mcp\\gateway_mcp_server.py"
      ],
      "disabled": false,
      "autoApprove": [
        "use_ida-pro-mcp",
        "use_jadx-mcp-server",
        "use_adb-mcp",
        "use_proxypin-mcp"
      ]
    }
  }
}

使用示例

LLM 调用方式简单展示:

# 列出 filesystem 的所有可用工具
use_filesystem(action="list", params={})

# 读取文件
use_filesystem(action="read_file", params={"path": "/tmp/test.txt"})

# 查看 git 状态
use_git(action="git_status", params={})

# 提交代码
use_git(action="git_commit", params={"message": "fix: bug"})

添加更多 MCP Server

只需在 mcps_config.json 中添加新的条目,Gateway 会自动为其创建对应的 use_{name} 工具和拉取工具最新描述。

许可证

MIT

-
security - not tested
F
license - not found
-
quality - not tested

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

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/LunFengChen/Gateway-Mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server