使用说明
MCP服务器网关
一种网关服务,将Claude Desktop中基于stdio的模型上下文协议(MCP)实现与基于HTTP/SSE的MCP服务器连接起来。这解决了协议兼容性差距,因为Claude Desktop目前仅支持基于stdio的MCP服务器。查看讨论 这里.
为什么是这个网关?
Claude Desktop App目前仅支持MCP服务器的stdio协议,而许多MCP服务器使用HTTP和服务器发送事件(SSE)传输。此网关充当协议转换器,允许Claude Desktop通过以下方式与任何HTTP/SSE MCP服务器通信:
- 接受来自Claude Desktop的stdio输入
- 将请求转换并转发到HTTP/SSE MCP服务器
- 将SSE响应转换回Claude Desktop的stdio格式
安装
使用npm全局安装网关:
npm install -g @mcphub/gateway
配置
1.查找网关路径
安装后,使用以下命令找到npm安装网关的位置:
# This shows the root directory of global packages
npm root -g
# The gateway will be located at:
<npm_global_root>/@mcphub/gateway/dist/src/mcphub-gateway.js
通用全球包裹位置:
- 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 - 窗户:
%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
添加此配置(使用您在步骤1中找到的路径):
{
"mcpServers": {
"server-name": {
"command": "node",
"args": ["/opt/homebrew/lib/node_modules/@mcphub/gateway/dist/src/mcphub-gateway.js"]
}
}
}
注意:替换中的路径 args 从第一步开始的实际路径。
3.配置MCP服务器连接
网关使用环境变量指定要连接到哪个MCP服务器:
# Set the MCP server URL (optional)
export MCP_SERVER_URL=https://your-mcp-server.com/api/mcp
默认情况下,网关连接到MCP Hub服务器 https://server.mcphub.ai/api/mcp,其提供对各种预配置的MCP服务的访问。
4.启动克劳德桌面
启动或重新启动Claude Desktop以应用更改。
故障排除
-
如果找不到网关路径:
# List all global packages and look for @mcphub/gateway npm list -g # Or specifically check the gateway npm list -g @mcphub/gateway -
验证您的Node.js安装:
# Check Node version node --version # Check npm version npm --version -
常见问题:
- 如果在macOS上使用Homebrew,请确保Node.js已正确链接:
brew doctor brew link node - 如果您遇到权限错误,可能需要使用
sudo对于安装
- 如果在macOS上使用Homebrew,请确保Node.js已正确链接:
许可证
支持
如果您遇到任何问题或有疑问:
- 在GitHub上提交问题
贡献
欢迎投稿!请随时提交拉取请求。
