The Hidden Token Tax on MCP
Expose an API over MCP the usual way and every operation becomes a tool definition, with a name, description, parameters and schema, all loaded into context. At scale that explodes. Cloudflare found that describing its 2,500-endpoint API took 1.17 million tokens, more than most context windows. Code Mode is its fix.
Why Standard Tool Calling Gets Expensive
- The manifest: every tool's definition sits in context before the agent does any work.
- The round trips: each tool call goes back to the model before the next one, and the back-and-forth adds up fast.
Code Mode: Let the Model Write the Loop
Instead of hundreds of tool definitions, Code Mode exposes the tools as a typed TypeScript API and gives the model just two tools: search and execute. The model writes one script that chains everything together and runs it in a sandbox, so the loops, filters and joins never touch the context.
The same job takes about 1,000 tokens, a 99.9% cut. The same idea already ships as Anthropic's Programmatic Tool Calling and in Block's Goose.
When to Use It
This isn't "MCP is dead"; it's still MCP underneath. Code Mode pays off with big tool sets (50+) and chained workflows. With fewer than about 10 tools, plain tool calls are simpler. Also note that review happens on the generated code, not on each individual call.
What's in the Guide
Where MCP's token cost comes from, how Code Mode turns tools into a typed API the model scripts against, the 1.17M-to-1,000 token comparison, when it's worth switching, and a link to Cloudflare's write-up.
The full field guide is in the PDF.
Get the Guide
Drop your email below and we'll send it straight to your inbox.
