remote-mcp-server

remote-mcp-server

3.4

This document provides a guide to setting up a remote Model Context Protocol (MCP) server on Cloudflare Workers, including local development, connection to MCP Inspector, and integration with Claude Desktop.

The Remote MCP Server on Cloudflare guide details the process of setting up a Model Context Protocol server using Cloudflare Workers. It includes instructions for local development, connecting to the MCP Inspector, and integrating with Claude Desktop. The guide also covers deployment to Cloudflare and provides troubleshooting tips. The MCP server allows for OAuth login and can be accessed remotely, enabling users to explore and utilize defined tools through the MCP Inspector or Claude Desktop. The setup involves cloning a repository, installing dependencies, and running the server locally before deploying it to Cloudflare. Users can connect to the server using the MCP Inspector or Claude Desktop by configuring the appropriate settings and URLs.

Features

  • Local Development: Instructions for setting up and running the MCP server locally.
  • MCP Inspector Connection: Steps to connect and explore the MCP API using the MCP Inspector.
  • Claude Desktop Integration: Guide to connect Claude Desktop to the local or remote MCP server.
  • Cloudflare Deployment: Instructions for deploying the MCP server to Cloudflare Workers.
  • Debugging Tips: Provides solutions for common issues during setup and connection.

Usage with Different Platforms

Develop locally

bash
# clone the repository
git clone git@github.com:cloudflare/ai.git

# install dependencies
cd ai
npm install

# run locally
npx nx dev remote-mcp-server

Connect Claude Desktop locally


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

Deploy to Cloudflare

bash
npx wrangler kv namespace create OAUTH_KV
# Follow the guidance to add the kv namespace ID to `wrangler.jsonc`
npm run deploy

Connect Claude Desktop remotely


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

Debugging

bash
npx mcp-remote http://localhost:8787/sse
# In some rare cases it may help to clear the files added to `~/.mcp-auth`
rm -rf ~/.mcp-auth