Get the FREE Ultimate OpenClaw Setup Guide →

mcp

MCP server for the Cloudflare API

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport http cloudflare-mcp https://mcp.cloudflare.com/mcp

How to use

This MCP server provides a token-efficient way to access the full set of Cloudflare APIs. It uses a Code Mode approach: instead of shipping every endpoint as a separate tool, the server keeps the OpenAPI spec on the server and returns the results of code execution to the client. You interact with the server using two main tools: search and execute. Use search to write JavaScript that inspects the spec and locates endpoints you’re interested in, for example all Workers-related endpoints. Then use execute to run code against Cloudflare's API via cloudflare.request() for the discovered endpoints. The server supports both account-scoped tokens and account auto-detection, so you can authenticate with either a user token or an account token and have the account ID resolved for you. The GraphQL Analytics API is also handled through the same execute path, enabling complex queries against the Analytics endpoints.

To get started, configure the MCP URL as shown in the example configuration, then use the search tool to discover endpoints relevant to your task (e.g., Workers, KV, DNS). Once you have a target endpoint, use the execute tool to call cloudflare.request with the appropriate method and path. If you’re using an account token, you’ll typically provide an account_id when required; for account tokens, the server can auto-detect the account. This workflow minimizes token usage while enabling access to a large surface area of the Cloudflare API.

How to install

Prerequisites:

  • Access to the MCP server at the configured URL (https://mcp.cloudflare.com/mcp).
  • Optional: an OAuth flow or a Cloudflare API token (user or account token) depending on your authentication method.

Install/Run options (choose one):

Option A: Run via npx (Node.js/npm)

  • Prerequisites: Node.js and npm/yarn installed locally.
  • Command:
npx -y cloudflare-mcp

Option B: Run via Docker

  • Prerequisites: Docker installed and running.
  • Command:
docker run -i cloudflare-mcp:latest

Option C: Run via other package managers (if available)

  • Prerequisites: respective runtime (e.g., Python or pipx) installed.
  • If a package is published, install and run with the package’s standard CLI, then point to the MCP URL.

Note: If you already use the MCP server via OAuth, you may not need local tooling beyond pointing your agent at the MCP URL. The examples in the README show the core configuration pattern to enable access to the Cloudflare APIs through the Code Mode MCP server.

Additional notes

Tips and gotchas:

  • The server uses Code Mode to minimize token usage. Expect responses to be results from code execution rather than full endpoint payloads.
  • For account-level operations, you may need an account_id. Token types: user tokens and account tokens are supported. Account tokens should include Account Resources: Read so the server can auto-detect the account.
  • GraphQL Analytics API is supported through the same execute tool; you can post GraphQL queries via the code executed by the server.
  • If you encounter authorization errors, verify token scopes and ensure the MCP server has the correct permissions configured for the requested operations.
  • When searching the spec, you can filter by tags (e.g., workers, kv, dns) to quickly locate relevant endpoints before executing requests.

Related MCP Servers

Sponsor this space

Reach thousands of developers