MCP Server Gateway
用于MCP SSE Server的网关示例。
简介
MCP 服务器网关是一个连接工具,将 Claude Desktop 应用的基于 stdio 的 MCP 实现与基于 HTTP/SSE 的 MCP 服务器连接起来,解决协议兼容性问题。
安装
npm install -g @mcphub/gateway
使用步骤
1. 找到网关路径
安装后,使用以下命令确定网关路径:
npm root -g
典型路径示例:
- macOS (Homebrew):
/opt/homebrew/lib/node_modules/@mcphub/gateway/dist/src/mcphub-gateway.js
- macOS (默认):
/usr/local/lib/node_modules/@mcphub/gateway/dist/src/mcphub-gateway.js
- Windows:
%AppData%\npm\node_modules\@mcphub\gateway\dist\src\mcphub-gateway.js
验证安装:
npm list -g @mcphub/gateway
2. 配置 Claude Desktop
编辑配置文件:
- macOS:
~/Library/Application Support/Claude Desktop/config.json
- Windows:
%APPDATA%\Claude Desktop\config.json
添加以下配置(使用您的实际路径):
{
"mcpServers": {
"server-name": {
"command": "node",
"args": ["/path/to/@mcphub/gateway/dist/src/mcphub-gateway.js"]
}
}
}
3. 配置 MCP 服务器连接(可选)
默认连接到 MCP Hub 服务器(https://server.mcphub.ai/api/mcp
)。
要连接到自定义服务器,请设置环境变量:
export MCP_SERVER_URL=https://your-mcp-server.com/api/mcp
4. 重启 Claude Desktop
重新启动 Claude Desktop 应用以应用配置。
故障排除
- 找不到网关:运行
npm list -g @mcphub/gateway
确认安装位置 - Node.js 问题:确认版本
node --version
和npm --version
- macOS 权限问题:可能需要使用
sudo
安装或运行brew link node
更多资源
- MCP 协议讨论
- 许可证: Apache 2.0
- 问题支持: 请在 GitHub 上提交问题