Set up and connect remote MCP servers on Cloudflare Workers with OAuth for seamless integration
Remote MCP Server, developed and maintained by Cloudflare Workers, provides a robust foundation to integrate scalable Model Context Protocol (MCP) features into your AI applications. This server acts as an intermediary between your AI tools and external data sources or APIs, enabling seamless communication through the standardized MCP protocol.
Remote MCP Server supports essential features such as OAuth 2.0 authentication for secure user sessions, real-time notifications via Server-Sent Events (SSE), and dynamic tool invocation based on user inputs. These capabilities ensure that both local and remote clients can efficiently interact with the AI application's computational resources.
The server leverages Cloudflare Workers to host MCP-compliant APIs, which are compatible with a wide range of MCP clients. The protocol flow ensures secure and reliable communication between the client and server by implementing JSON-based message exchanges and HTTP requests for state updates.
To understand how Remote MCP Server functions, let's visualize its protocol flow using a Mermaid diagram:
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
This diagram illustrates that an AI application uses the MCP client to communicate with the server, which in turn interacts with data sources or tools. The protocol ensures smooth and secure data flow.
To get started locally, 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
Navigate to http://localhost:8787/
in your browser to ensure everything is set up correctly.
To explore and test the server, use the MCP Inspector. Follow these steps to connect it:
npx @modelcontextprotocol/inspector
SSE
and enter:
http://localhost:8787/sse
Here are some screenshots illustrating these steps:
Imagine an AI application aimed at assessing financial risk for loans. By integrating Remote MCP Server, the application can connect seamlessly with external APIs to fetch credit scores and historical data from banks or fintech services.
{
"mcpServers": {
"financialRiskAssessment": {
"command": "npx",
"args": ["mcp-remote", "http://localhost:8787/sse"]
}
}
}
An application that assists in diagnosing patients based on their symptoms can leverage Remote MCP Server to access a database of medical records and symptom analyses from a trusted health service.
{
"mcpServers": {
"medicalDiagnosis": {
"command": "npx",
"args": ["mcp-remote", "https://example.health.cloud/sse"]
}
}
}
Remote MCP Server is compatible with the following MCP clients:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | 🆑 |
Continue | ✅ | ✅ | 🆑 |
Cursor | ❌ | ✅ | ❌ |
Ensure that your remote server runs smoothly with the specified configuration:
npx nx dev remote-mcp-server
For advanced usage and security, consider these configurations:
# Example for OAuth integration
export OAUTH_CLIENT_ID="your-client-id"
export OAUTH_CLIENT_SECRET="secret"
# Example for API key authentication
export API_KEY="your-api-key"
Clear the .mcp-auth
folder if issues arise:
rm -rf ~/.mcp-auth
How do I integrate Remote MCP Server with Continue?
wrangler.jsonc
and ensure OAuth setup for seamless integration.What tools are supported by Remote MCP Server?
Can I use this server with multiple clients simultaneously?
How do I secure the data exchanged between clients and the server?
What is the expected response time when using Remote MCP Server with AI applications?
If you wish to contribute to or develop upon this server, please follow these guidelines:
README
.Explore more about MCP and its capabilities:
For additional help or support, reach out to the community forums or Cloudflare's support channels.
By following these guidelines, developers can leverage Remote MCP Server as a powerful tool for integrating AI applications with external data sources and tools while ensuring seamless user experience through MCP protocols.
Explore Security MCP’s tools for threat hunting malware analysis and enhancing cybersecurity practices
Browser automation with Puppeteer for web navigation screenshots and DOM analysis
Analyze search intent with MCP API for SEO insights and keyword categorization
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants
Discover seamless cross-platform e-commerce link conversion and product promotion with Taobao MCP Service supporting Taobao JD and Pinduoduo integrations
Learn how to try Model Context Protocol server with MCP Client and Cursor tools efficiently