home / mcp / remote mcp server on cloudflare

Remote MCP Server on Cloudflare

Remote MCP server with OAuth support and Cloudflare integration to enable MCP clients to access tools via a managed Worker endpoint.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "craigsdennis-govee-cf-mcp": {
      "url": "http://localhost:8787/sse"
    }
  }
}

You can run a remote MCP server on Cloudflare Workers and connect it to MCP clients like Claude Desktop or the MCP Inspector. This setup lets you expose an MCP API locally or remotely, authenticate users, and call defined tools from your own environment.

How to use

Connect to your MCP server from an MCP client to explore and use the available tools. For a local setup, start the server and point your client to the local SSE endpoint. You can then log in with any email and password to access mock tools and test interactions.

To connect Claude Desktop to your local MCP server, update the configuration to point to the local SSE URL and restart Claude. You will see the available tools in the bottom-right corner, and Claude can prompt you to call a tool when appropriate.

To test remotely, first deploy the server to Cloudflare. After deployment, configure your remote MCP client to connect to the worker URL’s SSE endpoint (the /sse path) and authenticate as needed. You can then call the tools exposed by your MCP server from any compatible client.

How to install

Prerequisites: you need Node.js and a package manager. You also use pnpm for dependencies in this workflow.

# clone the repository
git clone https://github.com/cloudflare/ai.git
# Or if using ssh:
# git clone [email protected]:cloudflare/ai.git
# install dependencies
cd ai
# Note: using pnpm instead of just "npm"
pnpm install
# run locally
npx nx dev remote-mcp-server
```

You should be able to open `http://localhost:8787/` in your browser

Deploy to Cloudflare

Deploying the MCP server to Cloudflare requires creating a Cloudflare KV namespace for OAuth state and then deploying the Worker.

1. `npx wrangler kv namespace create OAUTH_KV`
2. Follow the guidance to add the kv namespace ID to `wrangler.jsonc`
3. `npm run deploy

Connect to a remote MCP client

After you deploy, connect the MCP Inspector or Claude Desktop to the remote MCP server using the Worker’s SSE URL.

In the MCP Inspector, switch the Transport Type to SSE and enter the worker URL followed by /sse (for example, https://your-workspace.workers.dev/sse). Connect, then log in when prompted to access tools.

Debugging

If something goes wrong, you can restart Claude or connect directly to your MCP server from the command line to diagnose issues.

npx mcp-remote http://localhost:8787/sse
```

If you ever need to reset authentication data, you can remove the MCP auth files from your home directory.

Available tools

MCP API

Expose and access MCP endpoints through the inspector to list and call defined tools.