Set up and connect remote MCP servers on Cloudflare Workers with OAuth for seamless integration
The Remote MCP Server on Cloudflare is an essential component in the Model Context Protocol (MCP) ecosystem, designed to facilitate seamless integration between AI applications and data sources or tools through a standardized protocol. By deploying this server, users can empower their chosen AI application, such as Claude Desktop, Continue, or Cursor, to interact with external resources via MCP endpoints.
The Remote MCP Server on Cloudflare leverages Cloudflare Workers to provide a scalable and reliable interface for developers building AI applications. Key features include:
Internally, the Remote MCP Server is structured to efficiently handle requests from various AI applications. It uses Cloudflare Workers for backend processing and leverages WebSocket (SSE) for real-time data transmission. The implementation details include:
To set up a local development environment or deploy the server on Cloudflare, follow these steps:
# Clone the repository
git clone [email protected]:cloudflare/ai.git
# Install dependencies
cd ai
npm install
# Run locally
npx nx dev remote-mcp-server
You should be able to access your local server via http://localhost:8787/
in a browser.
Use the MCP Inspector for server exploration:
npx @modelcontextprotocol/inspector
.SSE
and enter http://localhost:8787/sse
as the URL.Imagine a scenario where Claude Desktop needs to perform complex mathematical operations that exceed its built-in capabilities. By integrating with an MCP server running this Remote MCP Server, Claude can call external tools for precise calculations.
graph TD
A[AI Application (Claude Desktop)] -->|Invoke External Tool| B[Internal Server]
B --> C[External Math Tool]
In another use case, an AI application might need to retrieve and analyze data from a remote database. By connecting through the Remote MCP Server, data can be fetched in real-time, allowing for dynamic and interactive analysis.
graph TD
A[AI Application (Claude Desktop)] -->|Request Data| B[Internal Server]
B --> C[Database/External API]
B --> D[Data Analysis Tool]
To enable interaction between Claude Desktop and the Remote MCP Server, follow these steps:
npx mcp-remote [http://localhost:8787/sse]
to set up a local proxy.{
"mcpServers": {
"math": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:8787/sse"
]
}
}
}
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ | ✅ | ❌ |
If anything goes wrong, restart Claude or try connecting directly to the server with:
npx mcp-remote http://localhost:8787/sse
To clear authentication files, run:
rm -rf ~/.mcp-auth
Simply create a namespace for OAUTH keys with npx wrangler kv namespace create OAUTH_KV
, follow the guidance to add it to wrangler.jsonc
, and then run npm run deploy
.
Yes, the server is designed to handle concurrent connections from various clients.
The server supports a wide range of tools, including mathematical operations, database queries, and more. Check the official documentation for detailed lists.
Ensure strong API key management and regularly review permissions to prevent unauthorized access.
Absolutely, you can modify the protocol behavior by updating the server code according to your specific needs.
To contribute to this project or enhance its functionality:
git checkout -b [new-branch]
.git commit -m '[Your commit message]'
.git push origin [your-branch]
.Explore the broader MCP ecosystem:
By integrating this Remote MCP Server, developers can significantly enhance their AI application's capabilities, enabling more sophisticated interactions and workflows.
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
Analyze search intent with MCP API for SEO insights and keyword categorization
Connects n8n workflows to MCP servers for AI tool integration and data access
Learn to connect to MCP servers over HTTP with Python SDK using SSE for efficient protocol communication