remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Integrations
Supports containerization of the MCP server for deployment to Google Cloud Run, with the deployment script handling Docker container building and pushing to Google Container Registry.
Enables hosting an MCP server on Google Cloud Run with IAM authentication, allowing teams to securely access the server over the internet using Cloud SDK for authentication and proxy connections.
在 Google Cloud Run 上托管 MCP SSE 服务器
目前(2024年3月4日),MCP 仍在处理身份验证和授权问题。他们计划在 2025 年上半年完成。问题是,我现在想和我的团队共享我的 MCP 服务器。所以现在就到了。目前,在 Cursor 等平台上使用 SSE MCP 服务器的唯一直接解决方案是基于网络层的解决方案(例如代理)。基本身份验证、API 密钥,还是别想了。
利用 GCP Cloud Run 和基于用户的 IAM 身份验证,我创建了一种简单、安全的方式,允许客户端通过互联网访问自定义 MCP 服务器。
工作原理
MCP 服务器托管在 Google Cloud Run 上。利用 Cloud Run IAM 身份验证,我们可以利用 Google Cloud SDK 创建代理连接,安全地从互联网连接到服务器。
TLDR 自述文件
如果您已经在本地设置了 docker 和 gcloud CLI,那么这应该可以以最少的配置开箱即用。
**步骤 1:**使用您的项目 ID、服务帐户电子邮件等更新deploy.sh
。
**第 2 步:**部署成功后,获取提供的云运行 URL,并将其与您的项目 ID 一起添加到mcp_proxy.ts
。
**步骤 3:**运行代理npx ts-node mcp_proxy.ts
**步骤 3:**使用http://localhost:3030访问您的 MCP 服务器 - 将其添加到“设置”>“功能”>“MCP 服务器”下的“光标”中(确保选择 SSE 而不是命令)
冗长乏味的自述文件
部署步骤
- 克隆存储库
- 运行
npm install
来安装依赖项 - 运行
npm run dev
在本地启动服务器
部署到 Google Cloud Run
要将您的 MCP 服务器部署到 Google Cloud Run:
- 确保已安装Google Cloud SDK
- 使用您的项目详细信息更新
deploy.sh
脚本:PROJECT_ID
:您的 Google Cloud 项目 IDREGION
:您首选的 GCP 区域SERVICE_ACCOUNT_EMAIL
:具有适当权限的服务帐户电子邮件
- 运行部署脚本:Copy
部署脚本将:
- 为您的 MCP 服务器构建 Docker 容器
- 将其推送到 Google Container Registry
- 将其部署到 Cloud Run 并启用身份验证
连接到已部署的 MCP 服务器
要连接到已部署的 MCP 服务器:
- 在本地运行 MCP 代理:Copy
- 代理人将:
- 检查您是否已通过 Google Cloud 身份验证
- 自动获取身份验证令牌
- 创建本地代理服务器(默认值: http://localhost:3030 )
- 将经过身份验证的请求转发到您的 Cloud Run 服务
- 配置您的 MCP 客户端以连接到本地代理 URL
在 Cursor 中使用 MCP 服务器
- 首先,让我们运行代理来建立本地机器和托管在 Google Cloud Run 上的 MCP 服务器之间的连接。
- 现在让我们将本地代理服务器添加到 MCP 服务器部分的设置 > 功能选项卡中的光标。
- 现在,我们就可以开始了!启动一个新的 Composer(确保你处于代理模式),并查询某个位置的天气情况。代理连接的终端中的输出 + Composer 的输出应该如下所示:
安全
此设置提供了多种安全优势:
- 未经身份验证,您的 MCP 服务器无法公开访问
- 所有连接均通过 Google Cloud IAM 进行保护
- 团队成员需要 Google Cloud SDK 访问权限才能连接
连接问题
- 验证
mcp_proxy.ts
中的 Cloud Run URL 是否与您部署的服务匹配 - 检查 Cloud Run 日志中是否存在任何服务器端错误
贡献
欢迎贡献!欢迎提交问题或拉取请求。
执照
This server cannot be installed
托管在 Google Cloud Run 上的安全 MCP(模型上下文协议)服务器,通过 Google Cloud IAM 提供经过身份验证的访问,实现团队协作,允许团队在实施官方 MCP 身份验证之前通过互联网共享自定义 MCP 服务器。