home / mcp / cloudflare mcp server

Cloudflare MCP Server

Hosts an MCP server on Cloudflare Workers with OAuth for remote clients and local development workflows.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "neil-props-remote-mcp-server": {
      "url": "https://worker-name.account-name.workers.dev/sse"
    }
  }
}

You can run a remote MCP server on Cloudflare Workers, enabling OAuth login and remote access for MCP clients. This setup lets you host the MCP server in the cloud, connect via HTTP or local stdio, and integrate with clients like the MCP Inspector and Claude Desktop.

How to use

To use your MCP server, connect through an MCP client such as the MCP Inspector or Claude Desktop. You can run the inspector locally to explore and exercise the available tools, then configure Claude Desktop to talk to either your local server or the deployed cloud server.

How to install

Prerequisites you need before installation:

  • Node.js installed (recommended current LTS)
  • pnpm installed if you prefer using pnpm for dependencies

Develop locally

# 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

Connect the MCP inspector to your server

Use the MCP Inspector to explore your MCP API. Start the inspector, switch to SSE transport, and point it at your local server endpoint.

npx @modelcontextprotocol/inspector
```

Then configure the inspector to connect to your MCP server:

- Transport Type: SSE
- URL: http://localhost:8787/sse
- Connect

You’ll see a mock login screen. Enter any email and password to proceed. You can then list and call defined tools.

Connect Claude Desktop to your local MCP server

To enable Claude Desktop to talk to your local MCP server, adjust the configuration file used by Claude. In Claude Desktop, go to Settings > Developer > Edit Config and replace the content with the configuration below.

{
  "mcpServers": {
    "math": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:8787/sse"
      ]
    }
  }
}
```

This runs a local proxy so Claude can communicate with your MCP server over HTTP. When you open Claude, a browser window should login and you will see the tools available in the bottom right; with the right prompt Claude will ask to call a tool.

Deploy to Cloudflare

Deploy your remote MCP server to Cloudflare Workers and enable OAuth by creating a KV namespace for OAuth data.

npx wrangler kv namespace create OAUTH_KV
```

Then follow the prompts to add the KV namespace ID to wrangler.jsonc, and finally deploy:

```
npm run deploy
```

After deployment, note the workers.dev URL for your deployed MCP server. This is the remote endpoint you will use from MCP clients.

Call your newly deployed remote MCP server from a remote MCP client

From an MCP client, start the MCP Inspector and point it to your deployed Cloudflare Worker URL. Use the SSE endpoint on the deployed server.

npx @modelcontextprotocol/inspector@latest
```

Enter the remote URL in the inspector, for example:

```
https://worker-name.account-name.workers.dev/sse
```

Connect and you will access the remote MCP server from a remote client.

Connect Claude Desktop to your remote MCP server

Update Claude Desktop to point to your deployed remote MCP server by modifying the configuration file to reference the workers.dev URL.

{
  "mcpServers": {
    "math": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://worker-name.account-name.workers.dev/sse"
      ]
    }
  }
}
```

Restart Claude to apply the new server configuration.

Debugging

If something goes wrong, restart Claude and try connecting directly to your MCP server from the command line. You can test the remote endpoint with the following command.

npx mcp-remote http://localhost:8787/sse
```
```
rm -rf ~/.mcp-auth

Available tools

MCP Inspector

A development tool you run with npx @modelcontextprotocol/inspector to explore your MCP server. Switch to SSE transport, connect to /sse, login, and list or call defined tools.

Claude Desktop integration

Configure Claude Desktop to communicate with your MCP server by editing the MCP config to point to either a local http proxy or the deployed workers.dev URL.