Remote MCP Server on Cloudflare
@Laity624
Overview
What is Remote MCP Server on Cloudflare?
A reference implementation for running a remote MCP (Model Context Protocol) server on Cloudflare Workers, complete with OAuth login. It is intended for developers who want to expose MCP tools over the internet and connect clients like Claude Desktop or the MCP Inspector via SSE transport.
How to use Remote MCP Server on Cloudflare?
Clone the repository, install dependencies with npm install, then run locally with npx nx dev remote-mcp-server. Deploy to Cloudflare using wrangler kv namespace create OAUTH_KV and npm run deploy. Connect clients by pointing them to the server’s /sse endpoint.
Key features of Remote MCP Server on Cloudflare
- Runs on Cloudflare Workers with SSE transport
- Includes OAuth login flow for authentication
- Connects to MCP Inspector and Claude Desktop
- Supports local development on port 8787
- Uses Cloudflare KV for OAuth state storage
Use cases of Remote MCP Server on Cloudflare
- Deploy a remote MCP server for AI assistants like Claude
- Test MCP tools locally before deploying to production
- Add OAuth-protected tool access via Cloudflare Workers
FAQ from Remote MCP Server on Cloudflare
How do I connect Claude Desktop?
Edit the Claude Desktop config file to add an mcpServers entry with command npx and args ["mcp-remote", "http://localhost:8787/sse"] for local, or the Workers URL for remote access.
What transport protocol does it use?
It uses Server-Sent Events (SSE) over HTTP as the transport protocol.
How do I deploy to Cloudflare?
Run npx wrangler kv namespace create OAUTH_KV, add the KV namespace ID to wrangler.jsonc, then run npm run deploy.
How do I debug connection issues?
Restart Claude or test the connection directly with npx mcp-remote http://localhost:8787/sse. In rare cases, clear the auth cache with rm -rf ~/.mcp-auth.
Where is the OAuth state stored?
OAuth state is stored in a Cloudflare KV namespace configured via wrangler.jsonc.