Provides comprehensive access to the complete Cloudflare API, allowing agents to search for specific endpoints within the OpenAPI spec and execute requests to manage Cloudflare services and configurations.
Enables the management and querying of Cloudflare Workers, including searching for worker-related endpoints and executing scripts to retrieve or update worker resources via the Cloudflare API.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Cloudflare MCPlist all the cloudflare workers in my account"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
cloudflare-mcp
A smol MCP server for the complete Cloudflare API.
Uses codemode to avoid dumping too much context to your agent.
Get Started
Create API Token
Create a Cloudflare API token with the permissions you need.
Both user tokens and account tokens are supported:
Token Type | Description | Requirements |
User Token | Created at user level, can access multiple accounts | Requires |
Account Token | Scoped to single account |
|
For account tokens, include the Account Resources : Read permission so the server can auto-detect your account ID.
Add to Agent
MCP URL: https://cloudflare-mcp.mattzcarey.workers.dev/mcp
Bearer Token: Your Cloudflare API Token
Claude Code
OpenCode
Set your API token as an environment variable:
Then add to your opencode.json:
The Problem
The Cloudflare OpenAPI spec is 2.3 million tokens in JSON format. Even compressed to TypeScript endpoint summaries, it's still ~50k tokens. Traditional MCP servers that expose every endpoint as a tool, or include the full spec in tool descriptions, leak this entire context to the main agent.
This server solves the problem by using code execution in a codemode pattern - the spec lives on the server, and only the results of queries are returned to the agent.
Tools
Two tools where the agent writes code to search the spec and execute API calls. Akin to ACI.dev's MCP server but with added codemode.
Tool | Description |
| Write JavaScript to query |
| Write JavaScript to call |
Token usage: Only search results and API responses are returned. The 6MB spec stays on the server.
Supported Products
Workers, KV, R2, D1, Pages, DNS, Firewall, Load Balancers, Stream, Images, AI Gateway, Vectorize, Access, Gateway, and more. See the full Cloudflare API schemas.
Usage
Once configured, just ask your agent to do things with Cloudflare:
"List all my Workers"
"Create a KV namespace called 'my-cache'"
"Add an A record for api.example.com pointing to 192.0.2.1"
The agent will search for the right endpoints and execute the API calls. Here's what happens behind the scenes:
Token Comparison
Content | Tokens |
Full OpenAPI spec (JSON) | ~2,352,000 |
Endpoint summary (TypeScript) | ~43,000 |
Typical search result | ~500 |
API response | varies |
Architecture
Code execution uses Cloudflare's Worker Loader API to run generated code in isolated workers, following the codemode pattern.