Cloudflare Worker MCP
Cloudflare Worker MCP connects Claude Desktop to Cloudflare Workers, enabling customized API interactions via MCP protocol. It translates Worker methods for remote AI-powered coding and app workflow integration.
How to Install and Use Cloudflare Worker MCP
Cloudflare Worker MCP is a tool that lets you talk to a Cloudflare Worker from Claude Desktop or other MCP clients. It helps you connect your app or service running on Cloudflare’s platform with language models. Here is a simple guide to get started with Cloudflare Worker MCP using clear steps and code examples.
Step 1: Create a New Cloudflare Worker
To begin, you need to generate a new Cloudflare Worker. This step sets up the base project you will use with Cloudflare Worker MCP. Use the command below with create-cloudflare:
npx create-cloudflare@latest my-new-worker
When asked, choose the "Hello World" worker template. This gives you a simple starting point to build from.
Step 2: Install Cloudflare Worker MCP
Now, move into your new worker project folder and install the Cloudflare Worker MCP package. This package contains the tools you need to connect your worker with Claude Desktop or other MCP clients. Run these commands:
cd my-new-worker
npm install workers-mcp
This adds the MCP libraries and CLI tools to your project.
Step 3: Run the Setup Command
Once you have installed Cloudflare Worker MCP, run the setup command provided by the tool. This configures your worker project for working with MCP:
npx workers-mcp setup
If anything goes wrong, you can check the help page with:
npx workers-mcp help
This step sets up necessary files and metadata for MCP integration.
Step 4: Deploy Your Worker and Iterate
After setup, you can start coding your worker to expose functions to MCP clients like Claude Desktop. When you want to update the worker with new code or features, just deploy it again:
npm run deploy
This updates both your live worker and the metadata Claude Desktop uses to understand your worker's capabilities.
If you add or change method names or parameters, Claude Desktop needs a restart to see those updates.
Using Examples
Inside the examples folder of the Cloudflare Worker MCP project, you will find ready-made samples to help you learn:
- 01-hello-world: This example shows the code after initial setup and is a good first step to try.
- 02-image-generation: This example uses Cloudflare Workers AI to run an image generation model, showing how to interact with Claude Desktop for advanced tasks.
Connecting with MCP Clients Outside Claude Desktop
To connect your Cloudflare MCP server with other MCP clients, like Cursor:
- You need to combine the 'command' and 'args' from the configuration into a single command string.
- For example, if your config looks like this:
{
"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": {}
}
}
}
- In Cursor, set up your MCP server entry as:
{
"type": "command",
"command": "/path/to/workers-mcp run your-mcp-server-name https://your-server-url.workers.dev /path/to/your/project"
}
Replace the placeholders with your real paths and URLs to connect successfully.
By following these steps, you can have Cloudflare Worker MCP installed and ready to use. It lets you create powerful connections between Cloudflare Workers and language models like Claude Desktop or other MCP clients, opening up many possibilities for AI-powered workflows in your apps.