Learn to set up and connect a remote MCP server on Cloudflare Workers with OAuth and Claude integration
The Remote MCP Server hosted on Cloudflare Workers provides a robust platform to enable AI applications such as Claude Desktop, Continue, and Cursor through a standardized Model Context Protocol (MCP). This server acts as an intermediary that connects AI applications with specific data sources and tools, allowing for seamless integration and enhanced functionality. By leveraging the flexibility of Cloudflare's worker environment, this server ensures high performance and reliability.
The Remote MCP Server on Cloudflare is designed to support multiple core features essential for integrating with a variety of AI applications:
The architecture of the Remote MCP Server on Cloudflare is built to support the Model Context Protocol (MCP), which facilitates communication between AI applications and external data sources or tools. The server leverages the power of Cloudflare's Workers, enabling rapid development and deployment cycles.
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 server utilizes Cloudflare Worker's capabilities, including serverless functions and HTTP handling, to ensure robust performance. For development purposes, the repository can be cloned and run locally using npm commands.
To get started with setting up the Remote MCP Server on your local machine or deploying it to Cloudflare Workers:
Clone Repository: Clone the GitHub repository by running:
git clone [email protected]:cloudflare/ai.git
Install Dependencies: Navigate into the project directory and install the required dependencies using npm:
cd ai && npm install
Run Locally: Use Nx to start a development environment for the remote MCP server:
npx nx dev remote-mcp-server
You can access the running server at http://localhost:8787/
.
Create KV Namespace: Create an OAuth-secure key-value namespace using Wrangler commands:
npx wrangler kv namespace create OAUTH_KV
Add Namespace ID to Config: Modify the wrangler.jsonc
file to include the created namespace ID.
Deploy to Cloudflare Workers: Run deployment scripts to push your code to the Cloudflare environment:
npm run deploy
The Remote MCP Server on Cloudflare offers several key use cases that enhance the functionality of AI applications:
The Remote MCP Server on Cloudflare supports various MCP clients out of the box:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ | ✅ | ❌ |
To integrate the Remote MCP Server with tools using the MCP protocol, you can use the following configuration sample:
{
"mcpServers": {
"math": {
"command": "npx",
"args": [
"mcp-remote",
"https://worker-name.account-name.workers.dev/sse"
]
}
}
}
This setup ensures that the server can be accessed via a secure HTTPS URL, allowing for seamless integration with various AI applications.
The Remote MCP Server on Cloudflare is designed to offer high performance and compatibility across different environments:
Feature | Performance | Compatibility |
---|---|---|
Response Time | < 500ms | ✅ |
Security | OAuth-based Authentication | ✅ |
Protocol Support | SSE, WebSocket | ✅ |
For advanced configurations and security measures:
Clearing Auth Files: Use the following command to clear cached authentication details:
rm -rf ~/.mcp-auth
Restart Claude: Restarting the AI application may resolve connectivity issues, ensuring a smooth user experience.
Use the MCP Inspector to connect locally or a remote client via the Workers URL.
Create a key-value namespace, update wrangler.jsonc
, and run the deployment command.
Yes, but specific tool integrations may require additional configuration.
Restart the AI application, clear auth files, or check server logs for errors.
It enhances integration capabilities, ensures security, and supports multiple AI applications.
Contributions to improve the Remote MCP Server on Cloudflare are welcome. To contribute:
For further information, explore the Model Context Protocol documentation and community resources:
By leveraging the Remote MCP Server on Cloudflare, developers can streamline their AI workflows and enhance application integration through a standardized protocol.
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