CW

cloudflare/workers-mcp

开发工具官方

本页由 AI 翻译,技术细节请以原文为准。 查看原文

649 stars 67 forks 质量 76 趋势 0Apache-2.0

与Claude Desktop的Cloudflare工作人员交流吧!

概览

你应该从这里开始——搭建一个MCP服务器。你可以通过Claude Desktop、Cursor和其他客户端通过mcp-remote连接到远程MCP服务器。 该软件包既包含了CLI工具,也支持Worker内部逻辑,将Claude Desktop(或任何MCP客户端)连接到你账户上的Cloudflare Worker,这样你可以根据需要进行定制。它通过构建步骤实现,可以像这样翻译Worker的TypeScript方法: ...集成到本地Node.js服务器可以向MCP客户端展示的MCP工具中。Node.js服务器作为代理,本地处理stdio传输,并调用运行在Cloudflare上的Worker的相关方法。这允许你将应用中的任何函数或API,或Cloudflare开发者平台中的任何服务,暴露回你的编码代理、Claude Desktop或其他MCP客户端中的LLM。 是的,我知道那个数学。

概述(AI 翻译)

与Claude Desktop的Cloudflare工作人员沟通!

[!警告] 你应该从这里开始——搭建一个远程MCP服务器

你可以通过 mcp-remote 从 Claude Desktop、Cursor 及其他客户端连接到远程 MCP 服务器。

什么是workers-mcp?

该软件包既包含了CLI工具,也支持Worker内部逻辑,将Claude Desktop(或任何MCP客户端)连接到你账户上的Cloudflare Worker,这样你可以根据需要进行定制。它通过构建步骤实现,可以像这样翻译Worker的TypeScript方法:

…集成到本地Node.js服务器可以向MCP客户端展示的MCP工具中。Node.js服务器作为代理,本地处理stdio传输,并调用运行在Cloudflare上的Worker的相关方法。这允许你将应用中的任何函数或API,或Cloudflare开发者平台中的任何服务,暴露回你的编码代理、Claude Desktop或其他MCP客户端中的LLM。

是的,我知道 Math.random() 在 Worker 上和你本地机器上的工作方式一样,但别告诉 Claude 🤫

用途

步骤1:生成新工人

使用 create-cloudflare 生成一个新的工人。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

workers-mcp

Talk to a Cloudflare Worker from Claude Desktop!

[!WARNING]
You should start here instead — and build a remote MCP server

You can connect to remote MCP servers from Claude Desktop, Cursor, and other clients using mcp-remote.

What is workers-mcp?

This package provides both the CLI tooling and the in-Worker logic to connect Claude Desktop (or any MCP Client) to a Cloudflare Worker on your account, so you can customise it to suit your needs. It works via a build step that can translate TypeScript methods of your Worker like this:

export class ExampleWorkerMCP extends WorkerEntrypoint {
  /**
   * Generates a random number. This is extra random because it had to travel all the way to
   * your nearest Cloudflare PoP to be calculated which... something something lava lamps?
   *
   * @return {string} A message containing a super duper random number
   * */
  async getRandomNumber() {
    return `Your random number is ${Math.random()}`
  }
  
  // ...etc
}

…into MCP tools that a local Node.js server can expose to MCP clients. The Node.js server acts as a proxy, handling stdio transport locally, and calling the relevant method of your Worker running on Cloudflare. This allows you to expose any function or API in your app, or any service in Cloudflare’s developer platform, back to a LLM in your coding agent, Claude Desktop or other MCP client.

Yes, I know that Math.random() works the same on a Worker as it does on your local machine, but don’t tell Claude 🤫

Usage

Step 1: Generate a new Worker

Use create-cloudflare to generate a new Worker.

npx create-cloudflare@latest my-new-worker

I suggest choosing a Hello World worker.

Step 2: Install workers-mcp

cd my-new-worker # I always forget this bit
npm install workers-mcp

Step 3: Run the setup command

npx workers-mcp setup

Note: if something goes wrong, run npx workers-mcp help

Step 4…♾️: Iterating

After changing your Worker code, you only need to run npm run deploy to update both Claude’s metadata about your function and your live Worker instance.

However, if you change the names of your methods, or their parameters, or add or remove methods, Claude will not see the updates until you restart it.

You shouldn’t ever need to rerun npx workers-mcp install:claude, but it’s safe to do so if you want to rule out Claude config as a source of errors.

Using with Other MCP Clients

Cursor

在 GitHub 查看完整 README

安装

npx create-cloudflare@latest my-new-worker
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "your-mcp-server-name": { "command": "/path/to/workers-mcp", "args": [ "run", "your-mcp-server-name", "https://your-server-url.workers.dev", "/path/to/your/project" ], "env": {} } } }