Skip to main content
Glama

Cloudflare 上的远程 MCP 服务器

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

本地开发

# clone the repository git clone https://github.com/cloudflare/ai.git # Or if using ssh: # git clone git@github.com:cloudflare/ai.git # install dependencies cd ai # Note: using pnpm instead of just "npm" pnpm install # run locally npx nx dev remote-mcp-server

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

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

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

  • 使用npx @modelcontextprotocol/inspector启动

  • 在检查器中,将传输类型切换为SSE ,并输入http://localhost:8787/sse作为要连接的 MCP 服务器的 URL,然后点击“连接”

  • 您将导航到(模拟)用户/密码登录屏幕。输入任意电子邮件地址并登录。

  • 您应该被重定向回 MCP 检查器,现在您可以列出并调用任何定义的工具!

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

MCP 检查器很棒,但我们更想把它连接到 Claude!按照Anthropic 的快速入门指南操作,在 Claude Desktop 中,前往“设置”>“开发者”>“编辑配置”找到你的配置文件。

在文本编辑器中打开该文件并将其替换为以下配置:

{ "mcpServers": { "math": { "command": "npx", "args": [ "mcp-remote", "http://localhost:8787/sse" ] } } }

这将运行本地代理并让 Claude 通过 HTTP 与您的 MCP 服务器通信

打开 Claude 后,会打开一个浏览器窗口并允许您登录。您会在右下角看到可用的工具。输入正确的提示后,Claude 会要求调用该工具。

部署到 Cloudflare

  1. npx wrangler kv namespace create OAUTH_KV

  2. 按照指南将 kv 命名空间 ID 添加到wrangler.jsonc

  3. 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 服务器。

将 Claude Desktop 连接到远程 MCP 服务器

更新 Claude 配置文件以指向您的workers.dev URL(例如: worker-name.account-name.workers.dev/sse )并重新启动 Claude

{ "mcpServers": { "math": { "command": "npx", "args": [ "mcp-remote", "https://worker-name.account-name.workers.dev/sse" ] } } }

调试

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

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

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

rm -rf ~/.mcp-auth
-
security - not tested
F
license - not found
-
quality - not tested

Related MCP Servers

  • -
    security
    -
    license
    -
    quality
    A Model Context Protocol server deployment on Cloudflare Workers that enables tool usage in Claude and other AI models with OAuth authentication support.
  • -
    security
    F
    license
    -
    quality
    A Cloudflare Workers-based Model Context Protocol server that enables AI assistants like Claude to access external tools via OAuth authentication.
    Last updated -
    14
  • -
    security
    -
    license
    -
    quality
    A Cloudflare Workers implementation of a Model Context Protocol server with OAuth login that enables AI assistants like Claude to access external tools.
  • -
    security
    -
    license
    -
    quality
    A Cloudflare Workers-based implementation of Model Context Protocol server that enables integration with Claude AI through OAuth login, allowing Claude to access and execute custom tools.
    Last updated -

View all related MCP servers

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kkdai/remote-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server