Deploy a custom remote MCP server on Cloudflare Workers without authentication for AI tool integration
This example allows you to deploy a remote MCP server that doesn't require authentication on Cloudflare Workers.
A Remote MCP Server provides an interface for AI applications, such as Claude Desktop, Continue, and Cursor, to interact with various tools and data sources through the Model Context Protocol. This protocol standardizes interactions between the AI application and external contexts like databases or APIs, ensuring seamless integration and flexibility.
The Remote MCP Server offers several key features that enhance its compatibility and utility across different AI applications:
init()
method in src/index.ts
via this.server.tool(...)
.The Model Context Protocol operates by establishing a connection between the AI application (MCP client) and the remote server, through which commands are issued and responses are received. Here is how it works:
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 architecture of the Remote MCP Server is built around Cloudflare Workers, which provides a scalable and reliable environment for running the server. The key components are:
src/index.ts
, tools can be added to theserver using the this.server.tool()
method.Follow this link to deploy your server directly from the console:
This will guide you through deploying the server at a URL like: remote-mcp-server-authless.<your-account>.workers.dev/sse
.
Alternatively, you can set up and run the server locally using the command line:
npm create cloudflare@latest -- my-mcp-server --template=cloudflare/ai/demos/remote-mcp-authless
Suppose you need to perform real-time data analysis on stock market data using an API endpoint that provides live updates. Here's how you could set up the server:
src/index.ts
:
this.server.tool({
name: "stockMarket",
description: "Fetches live stock prices from the API.",
execute: async (request) => {
const response = await fetch("https://api.example.com/stockmarket");
return response.json();
}
});
Another use case is fetching weather data from a weather API:
this.server.tool({
name: "weather",
description: "Returns current weather conditions.",
execute: async (request) => {
const response = await fetch("https://api.example.com/weather");
return response.json();
}
});
tools.weather
in any connected MCP client.The Remote MCP Server supports integration with several popular AI applications, such as:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ | ✅ | ❌ |
The remote architecture ensures high performance and reliability, leveraging the strengths of Cloudflare Workers. The server's SSE implementation supports real-time data updates, making it ideal for applications requiring immediate feedback.
To configure your MCP server:
{
"mcpServers": {
"calculator": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-calculator"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
While the server is designed for public access, it's essential to implement proper security measures such as rate limiting and IP whitelisting.
npm create cloudflare@latest --
to set up a local instance.To contribute to the Remote MCP Server project:
The community is encouraged to suggest features, report issues, and improve documentation.
For more information on the Model Context Protocol and other related projects:
This comprehensive guide aims to provide a robust foundation for developers looking to integrate AI applications with remote MCP servers, ensuring flexibility and scalability in their development processes.
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Learn to connect to MCP servers over HTTP with Python SDK using SSE for efficient protocol communication
Python MCP client for testing servers avoid message limits and customize with API key
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants
Analyze search intent with MCP API for SEO insights and keyword categorization