Remote MCP Server on Cloudflare

by joaquinsoza

Integrations

  • Enables deployment of the MCP server on Cloudflare Workers infrastructure, providing a serverless environment for hosting the MCP service with OAuth authentication capabilities.

Cloudflare 上的远程 MCP 服务器

让我们在 Cloudflare Workers 上启动并运行一个远程 MCP 服务器,并完成 OAuth 登录!

本地开发

# clone the repository git clone git@github.com:cloudflare/ai.git # install dependencies cd ai npm install # run locally npx nx dev remote-mcp-server-bearer-auth

您应该能够在浏览器中打开http://localhost:8787/

将 MCP 检查器连接到您的服务器

要探索新的 MCP api,您可以使用MCP 检查器

  • 使用npx @modelcontextprotocol/inspector启动
  • 在检查器中,将传输类型切换为SSE ,并输入http://localhost:8787/sse作为要连接的 MCP 服务器的 URL。
  • 添加承载令牌并点击“连接”
  • 点击“列出工具”
  • 运行“getToken”工具,它应该返回您在检查器中设置的授权标头

将 Claude Desktop 连接到您的本地 MCP 服务器

{ "mcpServers": { "remote-mcp-server-bearer-auth": { "command": "npx", "args": [ "mcp-remote", "http://localhost:8787/sse", "--header", "Authorization: Bearer ${AUTH_TOKEN}" ] }, "env": { "AUTH_TOKEN": "..." } } }

部署到 Cloudflare

npm run deploy

从远程 MCP 客户端调用新部署的远程 MCP 服务器

就像上面在“本地开发”中所做的那样,运行 MCP 检查器:

npx @modelcontextprotocol/inspector@latest

然后在检查器中输入您的 Worker 的workers.dev URL(例如: worker-name.account-name.workers.dev/sse )作为要连接的 MCP 服务器的 URL,然后点击“连接”。

现在,您已从远程 MCP 客户端连接到 MCP 服务器。您可以像上面提到的那样传入一个 bearer token

调试

如果出现任何问题,重新启动 Claude 或尝试使用以下命令在命令行上直接连接到 MCP 服务器会有所帮助。

npx mcp-remote http://localhost:8787/sse

在极少数情况下,清除添加到~/.mcp-auth的文件可能会有所帮助

rm -rf ~/.mcp-auth

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

在 Cloudflare Workers 上运行且具有 OAuth 登录的模型上下文协议服务器,允许 Claude Desktop 等客户端连接到它以进行工具增强的 AI 交互。

  1. 本地开发
    1. 将 MCP 检查器连接到您的服务器
      1. 将 Claude Desktop 连接到您的本地 MCP 服务器
        1. 部署到 Cloudflare
          1. 从远程 MCP 客户端调用新部署的远程 MCP 服务器
            1. 调试

              Related MCP Servers

              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server that runs on Cloudflare Workers with OAuth login, allowing AI assistants like Claude to execute tools remotely through HTTP connections.
                Last updated -
                TypeScript
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server implementation that runs on Cloudflare Workers with OAuth login, allowing Claude and other AI models to access tools via the MCP standard.
                Last updated -
                TypeScript
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server for Cloudflare Workers that integrates with Claude AI, enabling tool usage through OAuth login and SSE connections.
                Last updated -
                14
                TypeScript
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server implementation that runs on Cloudflare Workers, providing tool integration for AI assistants like Claude with OAuth login capability.
                Last updated -
                14
                TypeScript

              View all related MCP servers

              ID: hzc8oovcof