Mcp Gateway

Mcp Gateway

🚀 MCP 服务器网关

MCP 服务器网关是一个服务网关,用于将基于标准输入输出(stdio)的模型上下文协议(MCP)实现(如Claude Desktop)与基于 HTTP/SSE(Server-Sent Events)的 MCP 服务器进行桥接。它有效解决了协议兼容性问题,因为目前 Claude Desktop 仅支持基于 stdio 的 MCP 服务器。相关讨论见此处

🚀 快速开始

MCP 服务器网关可使 Claude Desktop 与任何 HTTP/SSE MCP 服务器通信,解决协议兼容性问题。下面将详细介绍其安装、配置等步骤。

✨ 主要特性

  • 协议转换:Claude Desktop 应用程序当前仅支持基于 stdio 的 MCP 服务器协议,而许多 MCP 服务器使用 HTTP 结合 SSE(Server-Sent Events)传输协议。此网关充当协议转换器,具体功能如下:
    1. 接受来自 Claude Desktop 的标准输入输出。
    2. 转换并转发请求到 HTTP/SSE MCP 服务器。
    3. 将 SSE 响应转换回标准输入输出格式供 Claude Desktop 使用。

📦 安装指南

使用 npm 全局安装网关:

npm install -g @mcphub/gateway

📚 详细文档

配置步骤

1. 查找网关路径

安装完成后,通过以下命令查找 npm 安装的网关位置:

# 显示全局包的根目录
npm root -g

# 网关位于:
/@mcphub/gateway/dist/src/mcphub-gateway.js

常见全局安装路径:

  • macOS(使用 Homebrew Node):/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

创建或更新你的 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 服务器:

# 设置 MCP 服务器 URL(可选)
export MCP_SERVER_URL=https://your-mcp-server.com/api/mcp

默认情况下,网关连接到 MCP Hub 服务器 https://server.mcphub.ai/api/mcp,该服务器提供多种预配置的 MCP 服务访问。

4. 启动 Claude Desktop

启动或重新启动 Claude Desktop 以应用更改。

故障排除

1. 找不到网关路径

# 列出所有全局包并查找@mcphub/gateway
npm list -g

# 或者专门查看网关
npm list -g @mcphub/gateway

2. 验证你的 Node.js 安装

# 检查 Node 版本
node --version

# 检查 npm 版本
npm --version

3. 常见问题

  • 如果在 macOS 上使用 Homebrew,请确保 Node.js 已正确链接:
brew doctor
brew link node
  • 如果遇到权限错误,可能需要使用 sudo 进行安装

📄 许可证

Apache 2.0 License

🔗 支持

如果你遇到问题或有任何疑问,可在 GitHub 上提交问题。

🌟 贡献

欢迎贡献!请随意提交 Pull Request。

  • 0 关注
  • 0 收藏,18 浏览
  • system 提出于 2025-09-18 14:33

相似服务问题

相关AI产品