Cloudflare's MCP server makes agents write code to avoid 2M-token specs
This MCP server exposes Cloudflare's entire API to your agent without feeding it the 2-million-token OpenAPI spec.

What it does
Cloudflare’s MCP server exposes the company’s full API—2,500 endpoints covering Workers, R2, D1, DNS, and more—through a single hosted URL. Instead of registering thousands of tools and dumping their schemas into the agent’s context window, it provides two tools: search and execute. The agent writes JavaScript to query the OpenAPI spec and call endpoints; the server runs that code in isolated Cloudflare Workers and returns only the results.
The interesting bit
The server uses a “Code Mode” pattern that keeps the 2-million-token API spec on the server side rather than in the agent’s prompt. This shrinks the context cost from roughly 244,000 tokens (native MCP with minimal schemas) down to about 1,000 tokens—about half a percent of a 200K context window.
Key highlights
- Two tools cover 2,500 endpoints:
searchqueriesspec.pathsfor matching operations, whileexecutefirescloudflare.request()calls. - Agent-generated JavaScript runs inside isolated Workers via Cloudflare’s Dynamic Worker Loader API, so arbitrary code executes remotely, not locally.
- Supports OAuth delegation or API tokens, with automatic
account_idresolution when a single account is detectable. - Can fall back to standard MCP tool-per-endpoint mode via
?codemode=false, though this inflates token usage by roughly two orders of magnitude. - Automatically detects and routes requests to Cloudflare’s GraphQL Analytics API through the same
executetool.
Caveats
- API tokens with Client IP Address Filtering enabled are not currently supported.
- Disabling code mode to compose with other code-mode servers raises token usage from ~1K to ~244K, so interoperability requires planning.
Verdict
Use this if you manage Cloudflare infrastructure through an LLM agent and prefer spending context on your data rather than API schemas. Avoid it if you need static, individually enumerated tools for every endpoint or rely on IP-filtered API tokens.
Frequently asked
- What is cloudflare/mcp?
- This MCP server exposes Cloudflare's entire API to your agent without feeding it the 2-million-token OpenAPI spec.
- Is mcp open source?
- Yes — cloudflare/mcp is open source, released under the Apache-2.0 license.
- What language is mcp written in?
- cloudflare/mcp is primarily written in TypeScript.
- How popular is mcp?
- cloudflare/mcp has 659 stars on GitHub.
- Where can I find mcp?
- cloudflare/mcp is on GitHub at https://github.com/cloudflare/mcp.