Sponsored by Deepsite.site

Workers Mcp

Created By
geelena year ago
Talk to a Cloudflare Worker from Claude Desktop!
Content

# `workers-mcp`

> **Talk to a Cloudflare Worker from Claude Desktop!**

This package provides both the CLI tooling and the in-Worker logic to connect Claude Desktop (or any [MCP Client](https://modelcontextprotocol.io/)) to a Cloudflare Worker on your account, so you can customise it to suit your needs.

Usage

Step 1: Generate a new Worker

Use `npx create-cloudflare@latest` to generate a new Worker.

You could also start with an existing one, as long as you route your `fetch` calls appropriately.

Make a new `WorkerEntrypoint` as your default export, then add [RPC methods](https://blog.cloudflare.com/javascript-native-rpc/), documented with JSDoc, that Claude can call:

```ts export class ExampleWorkerMCP extends WorkerEntrypoint<Env> { /** * 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()}` } } ```

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

Step 2: Install `workers-mcp` & run `help` for instructions

``` npm install workers-mcp npx workers-mcp help ```

Step 3: Add `workers-mcp docgen` to your `deploy` step

```json "scripts": { "deploy:worker": "workers-mcp docgen src/index.ts && wrangler deploy" } ```

Step 4: Add a `fetch` handler to proxy events to your WorkerEntrypoint

Your Worker must (for now) be available on a public URL for Claude to access it. So we need a fetch handler that both handles auth (we're using simple shared-key auth) and proxies events to the right RPC method.

At the moment, only `ProxySelf` is provided, but `ProxyToServiceBinding` and `ProxyToDurableObject` are planned.

```ts export class ExampleWorkerMCP extends WorkerEntrypoint<Env> { // ...

async fetch(request: Request): Promise<Response> { return new ProxyToSelf(this).fetch(request) } } ```

> Note, you may get a TS error as your `Env` doesn't contain the `SHARED_SECRET` variable. We'll add that in the next step.

Step 5: Generate the secret & do the first deployment

Generate a secret in `.dev.vars` for use locally, then upload it once we have a Worker to attach it to:

```sh

Generate the secret

npx workers-mcp secret generate

(Optional) Update Env to include SHARED_SECRET

npx wrangler types

Generate docs and deploy your Worker

npm run deploy

Set the secret on our newly created Worker

npx workers-mcp secret upload ```

Step 6: Install it into Claude

Use the URL from your successful deployment in step 5, and any local alias you choose.

```sh npx workers-mcp install <local-alias> https://<worker-name>.<my-name>.workers.dev ```

Step 7: Start Claude Desktop!

Prompt Claude with something that causes it to invoke the function in your Worker:

![image](https://github.com/user-attachments/assets/c16b2631-4eba-4914-8e26-d6ccea0fc578)

Step 8..♾️: 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.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Playwright McpPlaywright MCP server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Tavily Mcp
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
WindsurfThe new purpose-built IDE to harness magic
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
ChatWiseThe second fastest AI chatbot™
Amap Maps高德地图官方 MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
DeepChatYour AI Partner on Desktop
CursorThe AI Code Editor
Serper MCP ServerA Serper MCP Server