使用说明
MCP代理网关
多个MCP包裹服务器,压缩工具定义Claude Code将条目添加到文档注册表。
特徴
- 上下文缩减:工具定义压缩减少了50-75%的令牌
- 工具过滤:仅发布所需工具
- 名前空间管理:工具名称用于避免冲突的前缀(
upstream__toolname形式) - 复数MCP对应: stdio类型/HTTP支持两种类型
安装
npm install
npm run build
使用方法
1.创建配置文件
mcp-proxy.config.yaml创建:
upstreams:
serena:
type: stdio
command: "uvx"
args:
- "--from"
- "git+https://github.com/oraios/serena"
- "serena"
- "start-mcp-server"
allowedTools:
- find_symbol
- get_symbols_overview
deepwiki:
type: http
url: "https://mcp.deepwiki.com/mcp"
allowedTools:
- ask_question
2. Claude Code与集成
.mcp.json添加到:
{
"mcpServers": {
"proxy": {
"type": "stdio",
"command": "node",
"args": [
"/path/to/mcp-proxy/dist/index.js",
"--config",
"/path/to/mcp-proxy/mcp-proxy.config.yaml"
]
}
}
}
3. 実行
# 開発モード
npm run dev -- --config mcp-proxy.config.yaml
# 本番モード
npm start -- --config mcp-proxy.config.yaml
配置选项
上游
stdio型
upstreams:
example:
type: stdio
command: "npx"
args: ["-y", "some-mcp-server"]
env:
API_KEY: "${API_KEY}"
allowedTools:
- tool1
- tool2
|选项|说明|必需|
|-----------|------|------|
| type | stdio指定=0
| command |执行命令|◯|
| args 命令参数
| env |环境变数| - |
| allowedTools 公开的工具(未指定时全部)
HTTP型
upstreams:
example:
type: http
url: "https://example.com/mcp"
allowedTools:
- tool1
|选项|说明|必需|
|-----------|------|------|
| type | http指定=0
| url | MCP端点URL | ◯ |
| allowedTools 公开的工具(未指定时全部)
环境变数
在配置文件中${VAR}或${VAR:-default}以格式引用环境变量:
upstreams:
example:
type: stdio
command: "uvx"
args: ["--project", "${PWD}"]
env:
API_KEY: "${API_KEY:-default_key}"
体系结构
Claude Code -----> MCP Proxy Gateway -----> Upstream MCPs
stdio stdio/http
+-------------+
|ToolRegistry | フィルタリング・圧縮
+-------------+
许可证
麻省理工学院