Set up and connect remote MCP servers on Cloudflare Workers with OAuth, Claude integration, and deployment tips
A Remote MCP Server on Cloudflare enables AI applications to connect to specific data sources and tools through a standardized protocol, much like how USB-C allows various devices to communicate with one another. This server is designed to facilitate seamless integration between AI frameworks such as Claude Desktop, Continue, Cursor, and more. By adhering to the Model Context Protocol (MCP), this setup ensures a consistent interface for diverse AI applications, making it easier for developers to build robust and interconnected workflows.
The Remote MCP Server harnesses several key capabilities of Cloudflare Workers to provide reliable and scalable integration with AI tools. It supports features like OAuth login for secure authentication, real-time communication through Server-Sent Events (SSE), and seamless proxying to facilitate interaction between local and remote clients.
Central elements include:
The architecture of the Remote MCP Server is built on a robust framework designed for seamless integration with various AI clients. It leverages Cloudflare Workers for low-latency, global deployment capabilities, ensuring quick response times and wide reach. The server follows the MCP protocol to define methods for interaction between the client and backend, encapsulating complex operations behind simple APIs.
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[System Gateway Worker]
C --> D[SSE Endpoint]
D --> E[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
This diagram illustrates the flow of communication between an AI application, using a MCP client to interact with the protocol, then through the system gateway worker and SSE endpoint before processing data requests from or responses to external tools.
Setting up this Remote MCP Server is straightforward. Follow these steps:
git clone [email protected]:cloudflare/ai.git
cd ai
npm install
npx nx dev remote-mcp-server
You will be able to access it at http://localhost:8787/
.
The Remote MCP Server can revolutionize various workflows by enabling AI tools to collaborate seamlessly. Some key use cases include:
Imagine a scenario where an AI-driven financial analyst needs real-time data from multiple sources and must quickly perform complex calculations using specialized tools. The Remote MCP Server acts as the central hub, allowing the analyst's application to smoothly integrate with these tools via MCP protocol.
In a creative workspace, designers might use an AI-driven solution for generating custom prompts based on user preferences or previous designs. These prompts are then sent to external tools for response generation, all orchestrated by the Remote MCP Server over MCP protocol.
To leverage the capabilities of the Remote MCP Server, different MCP clients need to be configured to communicate via the established protocol. For instance:
Follow Anthropic's Quickstart and update your configuration file to point to the server as follows:
{
"mcpServers": {
"math": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:8787/sse"
]
}
}
}
This setup allows Claude Desktop to call the 'math' tool seamlessly, enhancing its functionality.
The compatibility matrix ensures that various AI tools can efficiently work with the Remote MCP Server. Key features like OAuth and real-time communication support are compatible across multiple clients.
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ (Limited) | ❌ | Partial Support |
Securing the Remote MCP Server requires careful configuration to protect data integrity and user privacy. Key points include:
Ensure robust authentication methods are in place to secure access. The README guide demonstrates setting up OAuth with Cloudflare Workers.
Set appropriate environment variables like API_KEY
to control access levels securely:
"env": {
"API_KEY": "your-api-key"
}
How do I handle authentication issues?
What tools are compatible with this setup?
Can multiple clients connect simultaneously?
How do I troubleshoot connectivity issues?
What are best practices for security?
Contributions to improve this Remote MCP Server are welcome. Developers can join forces by:
Explore the broader MCP ecosystem and other resources to deepen your understanding of its applications:
This comprehensive documentation aims to position the Remote MCP Server as a foundational tool for developers building AI applications, ensuring seamless integration and robust performance across various workflows.
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
Build a local personal knowledge base with Markdown files for seamless AI conversations and organized information.
Integrate AI with GitHub using MCP Server for profiles repos and issue creation
Python MCP client for testing servers avoid message limits and customize with API key
Explore MCP servers for weather data and DigitalOcean management with easy setup and API tools