Free guide
MCP is alive: Cloudflare Code Mode and the whole API in 1,000 tokens
People say MCP is dead. It isn’t: Cloudflare Code Mode shows that only the old way is ending, where a model gets hundreds of tools and calls them one after another. Below you’ll find why that burns tokens, how Code Mode works and how to try it in Claude Code with one command.
Claude Code
cloudflare-api MCP server
You
Show my domains and their DNS records
10:00
search()
Picked the two needed out of more than 2,500 API actions
10:00
execute()
One program, one round trip, returned only the result
10:01
In short
Cloudflare’s MCP server gives access to more than 2,500 actions of its API through two tools, search() and execute(), in about 1,000 tokens. Built the old way, the same server would take up about 1.17 million tokens, more than fits in the context of the largest models. Instead of dozens of calls, the model writes a small program and returns only the answer.
What is MCP and why people say it’s dying
MCP (Model Context Protocol) is a common language through which a model finds tools and calls them: GitHub, Slack, email. Each tool has a description, and the model gets it before it starts working.
- Every description costs tokens. A server with hundreds of tools fills the context before the model takes its first step.
- Every call is a round trip through the model. You want the customer Pepa and his orders: the first tool finds Pepa and the answer goes to the model, the second fetches the orders and it’s back to the model again. That burns both tokens and time.
- Intermediate results flood the context. The model reads everything the tools return, even when it needs one number.
What Code Mode does
2
tools, search() and execute(), give access to more than 2,500 Cloudflare API actions in about 1,000 tokens. Built the old way, the same server would have 2,594 tools and take up about 1.17 million tokens.
Cloudflare, blog and developer docs, 2026 · source
search()searches the API description. The model writes a short piece of JavaScript that goes through the Cloudflare API specification and picks only the actions it needs. The whole specification doesn’t go into the context.execute()runs the program. The model writes a small program that calls the API, goes through the pages of results, checks the responses and returns to the model only what’s needed. All in one round trip.- The program runs in an isolated sandbox (Dynamic Worker): it has no access to files or environment variables and can’t reach other websites on its own.
- A third tool,
docs(), searches Cloudflare’s developer docs.
The old way
2,594 tools in context
About 1.17 million tokens
Every call is a round trip through the model
Code Mode
Two tools: search() and execute()
Roughly 1,000 tokens
One program, one round trip
Why it’s also more accurate: according to Cloudflare, models have seen code from millions of open-source projects, but tool calls only in artificially built examples. That’s why they handle a program better than a long chain of calls.
How to try it in Claude Code
A Cloudflare account is enough, even a free one. You add the MCP server for the whole Cloudflare API to Claude Code with one command in the terminal:
claude mcp add --transport http cloudflare-api https://mcp.cloudflare.com/mcp
Tick off what you’ve done:
- Start Claude Code and type
/mcp. For the cloudflare-api server, choose to sign in: a browser opens where you sign in to Cloudflare. - Choose what the model may do. Cloudflare gives it only the permissions you allow when connecting.
- Ask: “Show my domains and their DNS records.” Or: “How many requests did my Worker get in the past week?” And watch the model write code on its own through search and execute.
The model works with your real account. To start, give it read-only access. Leave changes to DNS and website security rules until you know what it’s doing.
Your own server in Code Mode
Have your own MCP server or an API with dozens of actions? Cloudflare’s guide “Build a Code Mode MCP server” describes two ways:
- One
codetool on top of your existing MCP server. The model gets the descriptions of all the tools as code and calls them from one program (codeMcpServer()). - The
searchandexecutepair for a large API with an OpenAPI specification. The whole API description stays out of the context (openApiMcpServer()).
Code Mode is still an experiment. Cloudflare says it’s experimental and may change, so deploy it to production with care.
Bonus
A brief for your MCP server
Have an MCP server with lots of tools? Give Claude Code this brief:
Go through the MCP server in this project: how many tools it has and how many tokens their descriptions take up. Suggest how to convert it to Code Mode following Cloudflare’s guide “Build a Code Mode MCP server”: either one code tool on top of the existing tools, or search and execute on top of the OpenAPI specification. Write what would change, and don’t change anything until I approve it.
Want AI to work with your programs?
In 30 minutes, free of charge, we’ll go through which of your programs to connect to AI and how, so it doesn’t burn tokens needlessly.
How we connect programs