Cloudflare Worker MCP

Cloudflare Worker MCP

Cloudflare Worker MCP is a toolkit that enables you to expose functions from your Cloudflare Workers as MCP tools, allowing seamless integration between your deployed Workers and AI agent clients like Claude Desktop, Cursor, or any MCP-compatible system. It provides command-line utilities and runtime logic to bridge local or remote Cloudflare Workers with the Model Context Protocol ecosystem, making your Worker functions programmable and accessible to LLM agents.

Author: cloudflare


View Protocol

What is Cloudflare Worker MCP?

Cloudflare Worker MCP is a package that allows you to connect your Cloudflare Workers to MCP clients such as Claude Desktop. It translates your TypeScript or JavaScript Worker methods into callable tools via the Model Context Protocol, which agents and AI applications can use to execute logic, call APIs, and interact with services running on Cloudflare's global platform.

How to Configure

  1. Generate a new Cloudflare Worker using npx create-cloudflare@latest your-worker-name and navigate to the project directory.
  2. Install the workers-mcp package: npm install workers-mcp
  3. Run the setup command: npx workers-mcp setup
  4. Deploy your Worker after changes using npm run deploy, which keeps both your Worker and the metadata for MCP updated.
  5. If integrating with clients like Cursor or custom MCP agents, configure your .json or project config to point at your server using a combined command/args string as appropriate.

How to Use

  1. Create and deploy your Cloudflare Worker as usual. Export your functions (such as API endpoints or computational logic) from your Worker using standard class methods.
  2. With workers-mcp installed and initialized, these methods are exposed as MCP tools, making them discoverable and callable by clients like Claude Desktop.
  3. Run a local Node.js proxy server (if needed) with workers-mcp run ..., which connects to your deployed Worker and registers your functions for MCP clients.
  4. Use compatible clients' built-in MCP features to list, invoke, and interact with your Worker-exposed tools.

Key Features

  • Seamlessly expose any Cloudflare Worker function as an MCP tool, enabling remote procedure calls from AI-enabled agents.
  • Automatic translation of Worker method signatures (with documentation) into MCP's tool interface.
  • Real-time updates: redeploy Worker code to update tool logic and metadata without extra configuration.
  • CLI support for setup, running a local proxy, and integrating into various MCP-compatible clients.
  • Supports both local and remote Worker connectivity, with secure, configurable setup.

Use Cases

  • Providing LLM agents with dynamic serverless APIs, such as randomness generation, data fetching, or domain-specific application logic.
  • Enabling automated workflows where Claude or other AI agents invoke Worker functions for integration with downstream APIs or cloud services.
  • Building agent-driven applications with real-world effects, such as image generation, data processing, or even browser rendering.
  • Rapid prototyping of new APIs or functions that are instantly accessible to AI-enabled coding tools.

FAQ

Q1: Do I need to redeploy after code changes?
Yes, if you modify your Worker’s code, run npm run deploy to update the Worker instance and its function metadata for MCP tools. If you change function names, parameters, or add/remove methods, you may need to restart the MCP client.

Q2: How do I connect to my Worker from different clients?
You can use the CLI with the right command or configure your MCP-compatible client (such as Cursor, Claude Desktop, or custom setups) by pointing to your MCP server entry in the configuration file. The command is typically /path/to/workers-mcp run <name> <worker-url> <project-path>.

Q3: Can I expose any function or API on Cloudflare Workers?
Yes, you can expose virtually any function, from simple helpers to advanced integrations with Cloudflare services or external APIs. Your Worker methods automatically become callable MCP tools.

Q4: How do I troubleshoot installation?
If setup fails, run npx workers-mcp help for diagnostic commands and double-check CLI output for configuration hints. Rerunning npx workers-mcp install:claude is safe if you suspect a config issue.