Connect Claude Desktop to Cloudflare Workers with easy setup and deployment for custom serverless functions
workers-mcp
MCP Server: Seamless Integration of AI Applicationsworkers-mcp
MCP Server?workers-mcp
is an essential component that enables seamless connectivity between Cloudflare Workers and various Model Context Protocol (MCP) clients such as Claude Desktop, Continue, and Cursor. By utilizing the workers-mcp
package, developers can create custom workers tailored for hosting AI applications. This server offers a robust environment to interact with different data sources and tools through a standardized protocol, enhancing versatility and integration flexibility across diverse AI ecosystems.
The core feature of workers-mcp
lies in its ability to bridge the gap between AI applications and Cloudflare Workers efficiently. By implementing workers-mcp
, developers can define custom RPC methods for their workers that are callable by MCP clients. These methods allow for complex interactions, including data processing, context management, and more, making it highly adaptable for various use cases.
The protocol implemented within workers-mcp
adheres to the standards outlined by Model Context Protocol (MCP). It supports dynamic method invocation based on client requests, ensuring seamless communication between the MCP clients and the workers. The protocol flow can be visualized as follows:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
This diagram illustrates the flow of requests from an AI application (MCP Client) to a worker running the workers-mcp
protocol, ultimately reaching the desired data source or tool. Each step in this process is meticulously orchestrated to ensure both performance and security.
workers-mcp
supports integration with multiple MCP clients, including:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
This compatibility matrix highlights that while tools and data sources are fully supported by all clients, some may not support prompt-based interactions. Developers can leverage this information to design workflows that align with the capabilities of their chosen MCP client.
workers-mcp
implements a modular architecture designed to handle various types of requests from MCP clients. The key components include:
ProxyToSelf
, ProxyToServiceBinding
, and ProxyToDurableObject
manage client requests efficiently.Below is an example of a Worker Entrypoint implementation:
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.
*
* @return {string} A message containing a super duper random number
*/
async getRandomNumber(): Promise<string> {
return `Your random number is ${Math.random()}`
}
}
To get started with workers-mcp
, follow these steps:
Generate a New Worker:
npx create-cloudflare@latest
Install workers-mcp
and Follow Instructions:
npm install workers-mcp
npx workers-mcp help
Add Docgen to Your Deployment Steps:
Update your package.json
scripts:
"scripts": {
"deploy:worker": "workers-mcp docgen src/index.ts && wrangler deploy"
}
Implement Fetch Handler for RPC Method Proxying:
export class ExampleWorkerMCP extends WorkerEntrypoint<Env> {
// ...
async fetch(request: Request): Promise<Response> {
return new ProxyToSelf(this).fetch(request)
}
}
Generate and Upload the Shared Secret:
npx workers-mcp secret generate
npm run deploy
npx workers-mcp secret upload
Install the Worker in Claude Desktop: Use the URL from your deployment to install it into Claude:
npx workers-mcp install <local-alias> https://<worker-name>.<my-name>.workers.dev
Start Using Claude Desktop!
A developer can create a custom worker that generates personalized blog posts based on user preferences. By defining the appropriate RPC methods, Claude Desktop can invoke these methods to produce content tailored to specific audiences.
workers-mcp
ensures compatibility with various MCP clients by providing standard ProxyToSelf
, ProxyToServiceBinding
, and ProxyToDurableObject
handlers. These handlers simplify the process of integrating different types of workers into an AI workflow. Developers can choose from these options based on their specific requirements.
Feature | Cloudflare Workers | AWS Lambda | GCP Functions |
---|---|---|---|
Performance | High | Medium | Low |
Compatibility | Strong | Moderate | Weak |
Ease of Use | Easy | Difficult | Complex |
This matrix provides a clear view of the performance and compatibility metrics for different cloud providers. Developers can choose the best fit based on their project needs.
SHARED_SECRET
, are properly configured to protect against unauthorized access.workers-mcp
work with any MCP client?
npm run deploy
, which will update both the metadata in Claude and the live worker instance.workers-mcp
handle data encryption?
Contributors are welcome! To get started:
workers-mcp
repository.For more information on the Model Context Protocol (MCP), explore the official documentation and resources:
Join the community for discussions, support, and learning opportunities.
By following these guidelines, developers can effectively integrate workers-mcp
into their AI workflows, enhancing the flexibility and performance of their applications.
Learn to connect to MCP servers over HTTP with Python SDK using SSE for efficient protocol communication
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Python MCP client for testing servers avoid message limits and customize with API key
Analyze search intent with MCP API for SEO insights and keyword categorization
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
Expose Chicago Public Schools data with a local MCP server accessing SQLite and LanceDB databases