j

jbwcloudflare

agent-orchestrationcloud-platformscode-execution

312 查看 · 2026-07-07 更新

在 Cloudflare 上构建无需认证的远程 MCP 服务器

本示例允许你在 Cloudflare Workers 上部署一个不需要认证的远程 MCP 服务器。

开始使用:

Deploy to Workers

这将把你的 MCP 服务器部署到类似这样的 URL:remote-mcp-server-authless.<your-account>.workers.dev/sse

或者,你可以使用以下命令行在本地机器上创建远程 MCP 服务器: bash npm create cloudflare@latest -- my-mcp-server --template=cloudflare/ai/demos/remote-mcp-authless

自定义你的 MCP 服务器

要向 MCP 服务器添加你自己的 工具,请在 src/index.tsinit() 方法中使用 this.server.tool(...) 定义每个工具。

连接到 Cloudflare AI Playground

你可以从 Cloudflare AI Playground(这是一个远程 MCP 客户端)连接到你的 MCP 服务器:

  1. 前往 https://playground.ai.cloudflare.com/
  2. 输入你已部署的 MCP 服务器 URL (remote-mcp-server-authless.<your-account>.workers.dev/sse)
  3. 现在你就可以直接从 playground 使用你的 MCP 工具了!

将 Claude Desktop 连接到你的 MCP 服务器

你也可以通过使用 mcp-remote 代理 从本地 MCP 客户端连接到你的远程 MCP 服务器。

要从 Claude Desktop 连接到你的 MCP 服务器,请按照 Anthropic 的快速入门指南 操作,并在 Claude Desktop 中进入设置 > 开发者 > 编辑配置。

更新为如下配置:

json { "mcpServers": { "calculator": { "command": "npx", "args": [ "mcp-remote", "http://localhost:8787/sse" // 或 remote-mcp-server-authless.your-account.workers.dev/sse ] } } }

重启 Claude 后,你应该能看到工具变得可用。

来源