Set up and connect remote MCP servers on Cloudflare Workers with OAuth integration and developer tools
The Remote MCP Server deployed on Cloudflare Workers provides a robust, scalable infrastructure for bridging AI applications with external data sources and tools through the Model Context Protocol (MCP). This server enables developers to integrate various AI models like Claude Desktop, Continue, and Cursor into their workflows by acting as an intermediary that converts application-specific commands and data formats into standardized MCP requests. By leveraging Cloudflare's global network and seamless deployment capabilities, this remote server ensures low latency, high availability, and secure access to a wide array of tools and data sources.
This Remote MCP Server is designed with key functionalities that ensure compatibility and performance across multiple AI applications:
mcp-remote
CLI tools to enable local development environments and remote execution of MCP clients.The architecture of the Remote MCP Server is built around a modular design, ensuring that it can easily scale to incorporate new data sources and tools. The protocol implementation leverages MCP's standardized API endpoints for seamless communication with various AI applications.
Figure 1: MCP Protocol Flow Diagram
The server follows the guidelines of the Model Context Protocol, which allows for clear and consistent data flows between clients and servers. The data architecture is designed as a layered network:
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
The Remote MCP Server is compatible with the following clients:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
Clone the repository from GitHub:
git clone [email protected]:cloudflare/ai.git
Install necessary dependencies and navigate to the project directory:
cd ai
npm install
Start the development server locally:
npx nx dev remote-mcp-server
You can access the server at http://localhost:8787/
.
npx @modelcontextprotocol/inspector
http://localhost:8787/sse
.Imagine an AI application needing rapid access to financial data for real-time analysis tasks. The Remote MCP Server can integrate with various financial APIs, providing on-demand data retrieval and processing capabilities. This setup enables the AI app to query specific datasets (e.g., stock prices, market trends) through MCP commands.
In a medical scenario, an AI application might need access to patient records for diagnostic purposes. The server can connect with EHR systems via MCP protocols, allowing the application to retrieve and interpret patient data securely and efficiently. This setup is particularly useful in scenarios requiring quick access to critical information.
To integrate with MCP clients like Claude Desktop:
Open the configuration file (usually located at ~/.mcp-auth/config.json
).
Replace the existing configuration with:
{
"mcpServers": {
"math": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:8787/sse"
]
}
}
}
Restart Claude to apply the configuration changes.
The Remote MCP Server supports multiple data sources and tools, offering broad compatibility across various AI applications:
Create a new key-value namespace for OAuth:
npx wrangler kv namespace create OAUTH_KV
Update wrangler.jsonc
with the namespace ID.
Deploy the server to Cloudflare:
npm run deploy
For debugging purposes, you can use the following command:
npx mcp-remote http://localhost:8787/sse
In case of authentication issues, clear persisted files in ~/.mcp-auth
:
rm -rf ~/.mcp-auth
The server supports SSL/TLS for secure communication between clients and servers.
Yes, any tool or resource that can be integrated via MCP protocol can be supported.
OAuth is recommended but not mandatory. Basic authentication can also be used.
The server uses a load-balancing approach to handle multiple concurrent requests, ensuring performance even at high request volumes.
While most clients are fully compatible, some advanced features like custom prompts may require additional configuration.
Contributions are welcome! To get started, make sure to familiarize yourself with the project's coding standards and best practices. Follow these steps:
npm install
For more information on the Model Context Protocol and its applications, refer to the official documentation:
Join the community for discussions and support:
By leveraging the Remote MCP Server, developers can unlock new capabilities for their AI applications, ensuring seamless integration with diverse data sources and tools.
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