Set up and deploy remote MCP servers on Cloudflare Workers with OAuth and connect to Claude Desktop
A Remote MCP Server on Cloudflare enables the seamless integration of various AI applications, such as Claude Desktop and Continue, with custom data sources and tools through the Model Context Protocol (MCP). By serving as an intermediary between these applications and external resources, this server enhances functionality and interoperability. The setup involves developing and deploying a server locally or remotely on Cloudflare Workers, followed by connecting relevant MCP clients.
The core features of the Remote MCP Server on Cloudflare include:
npm
commands to test and debug.This architecture utilizes the Model Context Protocol (MCP) to provide a standardized way for AI applications to interact with various data sources and tools. The implementation involves:
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
nx dev remote-mcp-server
to start the development server.Clone the repository:
git clone [email protected]:cloudflare/ai.git
Navigate into the project directory and install dependencies:
cd ai
npm install
Run the server locally with:
npx nx dev remote-mcp-server
To explore your new MCP API, you can use the MCP Inspector.
Start it by running:
npx @modelcontextprotocol/inspector
Within the inspector, switch the Transport Type to SSE
and enter http://localhost:8787/sse
as the URL of the MCP server.
Log in with any email and password.
Developers can connect a financial dataset tool to analyze stock prices or market trends within any AI application that supports MCP. For instance, integrating an API for fetching real-time cryptocurrency data allows Claude Desktop to perform complex financial calculations and data analysis.
AI applications can use custom extraction, transformation, and loading (ETL) processes by connecting to database servers or APIs. This enables more efficient and tailored data processing workflows.
The Remote MCP Server on Cloudflare is compatible with various MCP clients:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
For advanced users, there are additional configuration options and security measures:
Deploy to Cloudflare:
npx wrangler kv namespace create OAUTH_KV
# Follow the guidance to update wrangler.jsonc with the namespace ID
npm run deploy
Remote Connection: Connect the MCP Inspector or Claude Desktop to your remote deployment:
npx @modelcontextprotocol/inspector
, use the workers.dev
URL (https://worker-name.account-name.workers.dev/sse
).Clear Cache and Authentication:
In some cases, clearing files in ~/.mcp-auth
might help resolve authentication issues or force re-login.
rm -rf ~/.mcp-auth
What if I need to update the server frequently? Use Cloudflare Workers for deployments, which enables hot reloading and easy updates.
How do I know if a server is down or experiencing issues? Monitor worker logs using the Cloudflare dashboard or command-line tools.
Can I deploy this on other cloud platforms besides Cloudflare? Yes, but you may need to adapt configuration steps for different deployment environments.
Is there any performance impact from going through the MCP server? Generally minimal; however, network latency and processing overhead should be considered when working with remote servers.
What if I have issues connecting multiple tool APIs? Check the status of individual tools in isolation and ensure compatibility between different clients and servers.
For developers wishing to contribute to this project:
CONTRIBUTING.md
document.Explore additional resources and community contributions related to the Model Context Protocol:
By leveraging the Remote MCP Server on Cloudflare, developers can significantly enhance the capabilities of their AI applications through seamless tool and resource integration.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration