Skip to main content

Centralized MCP Gateway for Cloudflare services

Project description

Cloudflare MCP Gateway

A centralized MCP (Model Context Protocol) gateway that aggregates multiple Cloudflare MCP services into a single unified server. Configure which services you need via environment variables and access them all through one MCP connection.

Features

  • Unified Access: Single MCP server for multiple Cloudflare services
  • Configurable Services: Enable only the services you need via ENABLED_SERVICES
  • Dual Transport Support: Works with both stdio (Claude Desktop) and streamable HTTP (web clients)
  • Tool Namespacing: Automatic prefixing prevents tool name collisions (e.g., kv_get, r2_list)
  • Graceful Degradation: Continues operating if some upstream services are unavailable

Supported Services

Service ID Name Description
docs Documentation Cloudflare documentation reference and search
bindings Workers Bindings Storage, AI, and compute primitives for Workers
builds Workers Builds Deployment insights and management
observability Observability Logs and analytics debugging
radar Radar Internet traffic insights and URL scanning
browser Browser Rendering Web page fetching, markdown conversion, screenshots
ai-gateway AI Gateway Prompt/response log search and analysis
d1 D1 Serverless SQL database operations
kv KV Key-value storage operations
r2 R2 Object storage operations

Installation

# Using pip
pip install cf-mcp-gateway

# Using uv
uv pip install cf-mcp-gateway

Quick Start

1. Get Cloudflare Credentials

You'll need:

  • API Token: Create one at Cloudflare Dashboard
  • Account ID: Found in your Cloudflare dashboard URL or account settings

2. Configure Environment

Create a .env file or set environment variables:

# Required
CLOUDFLARE_API_TOKEN=your-api-token
CLOUDFLARE_ACCOUNT_ID=your-account-id
ENABLED_SERVICES=docs,kv,r2

# Optional
TRANSPORT=stdio  # or streamable-http
LOG_LEVEL=info

3. Run the Gateway

# Using the CLI
cf-mcp-gateway

# Or as a Python module
python -m cf_mcp_gateway

Usage with MCP Clients

Claude Desktop

Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "cloudflare": {
      "command": "python",
      "args": ["-m", "cf_mcp_gateway"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "your-api-token",
        "CLOUDFLARE_ACCOUNT_ID": "your-account-id",
        "ENABLED_SERVICES": "docs,kv,r2,d1",
        "TRANSPORT": "stdio"
      }
    }
  }
}

Cursor

Add to your Cursor MCP settings:

{
  "mcpServers": {
    "cloudflare": {
      "command": "cf-mcp-gateway",
      "env": {
        "CLOUDFLARE_API_TOKEN": "your-api-token",
        "CLOUDFLARE_ACCOUNT_ID": "your-account-id",
        "ENABLED_SERVICES": "docs,bindings,observability"
      }
    }
  }
}

Streamable HTTP (Remote/Web Access)

Start the gateway with HTTP transport:

CLOUDFLARE_API_TOKEN=xxx \
CLOUDFLARE_ACCOUNT_ID=yyy \
ENABLED_SERVICES=docs,kv,r2 \
TRANSPORT=streamable-http \
GATEWAY_HOST=0.0.0.0 \
GATEWAY_PORT=3000 \
cf-mcp-gateway

The server exposes:

  • POST /mcp - MCP JSON-RPC endpoint
  • GET /health - Health check endpoint

Configuration Reference

Required Environment Variables

Variable Description
CLOUDFLARE_API_TOKEN Your Cloudflare API token
CLOUDFLARE_ACCOUNT_ID Your Cloudflare account ID
ENABLED_SERVICES Comma-separated list of service IDs to enable

Optional Environment Variables

Variable Default Description
TRANSPORT stdio Transport mode: stdio or streamable-http
GATEWAY_HOST 0.0.0.0 HTTP bind host (streamable-http only)
GATEWAY_PORT 3000 HTTP port (streamable-http only)
CORS_ORIGINS `` Allowed CORS origins, comma-separated
LOG_LEVEL info Logging level: debug, info, warning, error

Tool Naming Convention

Tools from upstream services are prefixed with their service ID to avoid collisions:

  • kv_get - Get value from KV
  • kv_put - Put value to KV
  • r2_list - List R2 objects
  • r2_get - Get R2 object
  • docs_search - Search Cloudflare documentation

Architecture

┌─────────────────┐     ┌─────────────────────────────────┐
│   MCP Client    │────▶│   Cloudflare MCP Gateway        │
│ (Claude, etc.)  │     │                                 │
└─────────────────┘     │  ┌─────────────────────────┐    │
                        │  │   Tool Aggregator       │    │
                        │  │   - Namespacing         │    │
                        │  │   - Request routing     │    │
                        │  └─────────────────────────┘    │
                        └──────────────┬──────────────────┘
                                       │
           ┌───────────────────────────┼───────────────────────────┐
           ▼                           ▼                           ▼
┌──────────────────┐      ┌──────────────────┐      ┌──────────────────┐
│ docs.mcp.cf.com  │      │  kv.mcp.cf.com   │      │  r2.mcp.cf.com   │
└──────────────────┘      └──────────────────┘      └──────────────────┘

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cf_mcp_gateway-0.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cf_mcp_gateway-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file cf_mcp_gateway-0.1.0.tar.gz.

File metadata

  • Download URL: cf_mcp_gateway-0.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for cf_mcp_gateway-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7b6f2efa573b1299b8c80aea13cba6174968c48e8c46f42cccd9ed6165b18c99
MD5 73046c90c8f2bd4956ac83fa1a7bc7bd
BLAKE2b-256 282c7199b88acca144ba206a320d4989c754aa37f2272e94f91d0024629897d7

See more details on using hashes here.

File details

Details for the file cf_mcp_gateway-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cf_mcp_gateway-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c0105b7c3ad4c0758ccb51217fa1329cf2bf4c2ffa49176b4fc934c97feebc1
MD5 32eb8ebbd903cf7ec82a373808cea655
BLAKE2b-256 838daceb1b9b86f8e71552f4e6cdea171db8c133a2713b1b5a65be558b144bb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page