Skip to content

Journal / Technical

Code mode and MCP: what replaces what, with the numbers

17 min read

MCP turns two on 25 November 2026. It is the protocol that lets an AI plug into tools: a calendar, a customer file, a code repository. For some months now, a newer technique, “code mode”, has been said to be replacing it. That is not what the sources say. Code mode does not replace MCP: it replaces the way MCP was being used. The distinction matters, because it changes the bill and the security of any project that connects an AI to a company’s tools.

This article reads in two parts. First, what to remember if you are commissioning such a project. Then the history, which starts long before MCP, and the figures, for those who want the detail.

The essentials in three points

  • MCP is the socket, not the way you use it. It says how a tool declares itself, connects, and checks who is allowed to do what. It remains the standard: adopted by OpenAI and Google in 2025, handed to a foundation in December 2025, rebuilt in July 2026.
  • What changes is how the AI uses the tools. Before, it called them one at a time, and everything passed through its memory. In code mode, it writes a small program that calls the tools, and reads only the result. It is a return to the oldest way of making two pieces of software talk, except that the AI writes the program.
  • The gain is real, but it is not the one in the headlines. Published figures run from a 99.9% saving in an extreme case to an 8% extra cost in an unfavourable one. And it has a price: you need a safe place to run that program.

In the beginning, the API

It all starts with the API. An API, or application programming interface, is a piece of software’s front desk: the list of what you can ask it, and how to ask. When a website shows a map, takes a payment or sends an email, it calls another service’s API. Software has talked this way on the web since the 2000s: REST, the style that became the reference, was described by Roy Fielding in a dissertation defended in 2000.

For twenty years the pattern did not move. A developer reads an API’s documentation, then writes the code that calls it. In November 2015 that documentation gained a common format, OpenAPI, placed under the Linux Foundation: a description a machine can read, not only a person. That detail comes back at the end of the story.

2023: the AI enters the loop

In 2023, the aim becomes having the AI call those APIs itself. OpenAI opens two paths in the same year.

On 23 March, ChatGPT plugins: a service introduces itself to the AI with a manifest file and its OpenAPI description. The same announcement includes a “code interpreter”: an isolated Python environment, with no internet access, where the AI runs code.

On 13 June, function calling: the developer describes functions to the model, and the model answers with a filled-in form saying which function to call and with which values. It calls nothing itself: the program around it makes the call.

The second path is the one that wins, under the name tool calling. Each piece of an API becomes a tool, described to the AI. Anthropic opens it to all its models on 30 May 2024.

2024: MCP, a common socket

At that point every application described its tools in its own way, and everything had to be rewritten for each AI. On 25 November 2024, Anthropic publishes MCP to put an end to that. Cloudflare gives the clearest definition: a uniform way to expose an API, with the documentation an AI needs to understand it, and authorisation handled separately. The tools of an MCP server, Cloudflare also writes, are really just a remote call interface with documentation attached.

In other words, MCP did not replace the API: it wrapped it for the AI.

The problem: an AI’s memory is paid for by the word

A language model works with a limited memory, its context window. Everything it needs in front of it goes in there: your question, your documents, and the description of every tool it is allowed to use. That memory is counted in tokens, which are fragments of words. Every token read is paid for, on every question.

This is where MCP’s success created its own problem. The more tools you plug in, the more room their descriptions take, before the first question is even asked. Anthropic, which created MCP, gives an example: five services connected (GitHub, Slack, Sentry, Grafana, Splunk), 58 tools, about 55,000 tokens of descriptions. The company says it has seen up to 134,000 tokens in its own use. Cloudflare did the sum for its own API, which has more than 2,500 endpoints: describing it tool by tool would take 1.17 million tokens, more than the entire memory of the most advanced models.

What tools weigh before the first question

In tokens: the word fragments the model reads, and that you pay for.

  • 55,000

    tokens to describe 58 tools from five services, in Anthropic’s example

    Anthropic, 24 Nov 2025
  • 134,000

    tokens of tool descriptions seen at Anthropic, before optimisation

    Anthropic, 24 Nov 2025
  • 1.17 million

    tokens to describe the whole Cloudflare API, tool by tool

    Cloudflare, 20 Feb 2026
  • 1,000

    tokens for the same API in code mode, with two tools

    Cloudflare, 20 Feb 2026

Sources: Anthropic, “Introducing advanced tool use”; Cloudflare, “Code Mode: give agents an entire API in 1,000 tokens”, which says it counted with the tiktoken tool.

The second cost is less visible. When the AI chains calls, every intermediate result goes back through its memory. Anthropic takes the example of an expenses check: twenty people, so twenty calls, more than 2,000 expense lines to read, to find the two or three people who went over budget. The model reads everything, when only the answer matters to it.

The idea: write code instead of calling tools

On 26 September 2025, Kenton Varda and Sunil Pai, of Cloudflare, publish a post with a blunt title: “Code Mode: the better way to use MCP”. Its finding fits in one sentence: we have all been using MCP wrong.

Their proposal: instead of showing the AI a list of tools to call one at a time, present those tools as the functions of a programming language, and ask it to write a program that uses them. Their explanation: during training, a model has read enormous amounts of real code, and very few “tool calls”, a format invented for it. The post compares the situation to asking Shakespeare to write a play in Mandarin after a month of lessons.

Back to the expenses. In code mode, the AI writes a loop: for each person, fetch the expenses, add them up, compare with the budget. The program runs apart, in an isolated space called a sandbox. The 2,000 lines never enter the model’s memory: according to Anthropic, 200 kilobytes of data become one kilobyte of result.

Classic API Tool calling, with MCP Code mode
Who decides what to call The developer, in advance The AI, at each step The AI, by writing the program
Who writes the call The developer The AI fills in a form, the application calls The AI writes the code, a sandbox runs it
What the AI has in front of it Nothing: it is not in the loop The description of every tool One or two tools: search, run code
Where intermediate results go Into the program Into the model’s memory Into the sandbox; only the result comes back
What it takes A developer for every need Nothing more A safe sandbox

A return to the API, with three differences

Writing code that calls an API is the oldest way of doing it, the way of the 2000s. Letting an AI write that code is not new either. The code interpreter dates from 2023. In February 2024, a research team shows, under the name CodeAct, that a model which acts by writing code succeeds more often than a model which fills in forms: up to 20% higher success rate, across 17 models tested. On 31 December 2024, Hugging Face publishes smolagents, a library of agents that write their actions in code.

In February 2026, Cloudflare takes the logic to its end. Its server now shows the AI only two tools. The first lets it search, with code, through the OpenAPI description of its API: the 2015 format. The second has it call the API, with code. The circle is closed.

So what has changed between then and now? Three things.

  1. Who writes the code. Then, a developer, once and for all. Now, the model, on every request, for that request.
  2. Where it runs, and with what rights. The 2023 interpreter was cut off from everything: it computed, but could not reach your tools. The sandbox Cloudflare describes still has no internet and no keys, but it has a door: the MCP socket, which holds the rights and lets the planned calls through. Bringing the two together is what is new.
  3. Its place in products. Then, a laboratory idea. Now, a setting: on by default on Cloudflare’s MCP portals since March 2026, described as a best practice by MCP’s documentation since July 2026, offered as a stable feature by Anthropic to developers. In Claude Code it remains experimental and off by default.

From the API to code mode, in dates

Date What happens
2000 Roy Fielding describes REST, the style that became the reference for web APIs
November 2015 OpenAPI: a common format for describing an API, under the Linux Foundation
23 March 2023 OpenAI announces ChatGPT plugins, described in OpenAPI, and an isolated code interpreter
13 June 2023 OpenAI launches function calling: the model fills in a form, the program makes the call
1 February 2024 The CodeAct study: have a model act by writing code
30 May 2024 Anthropic opens tool calling to all its models
25 November 2024 Anthropic publishes MCP
31 December 2024 Hugging Face publishes smolagents, agents that write their actions in code
March and April 2025 OpenAI, then Google, adopt MCP
26 September 2025 Cloudflare publishes “Code Mode”
4 November 2025 Anthropic describes the same approach and cites Cloudflare
24 November 2025 Anthropic adds it to its developer offering, along with on-demand tool search
9 December 2025 MCP is handed to a foundation hosted by the Linux Foundation
20 February 2026 Cloudflare puts its whole API behind two tools
17 and 28 February 2026 Nx removes most of its MCP tools; the post “MCP is dead. Long live the CLI” appears
26 March 2026 Cloudflare turns code mode on by default on its MCP portals
1 May 2026 Arize publishes a comparative test: MCP against the command line
28 July 2026 MCP is rebuilt; its documentation describes code mode
12 November 2026 Claude Code gets an experimental Code Mode
30 March 2027 Next announced version of MCP

What the figures really say

The headlines keep two numbers: 99.9% and 98.7% saved. They are accurate, and they describe chosen cases. The first comes from Cloudflare and measures one thing only: the room taken by tool descriptions, for an API of 2,500 endpoints that almost nobody has. The second comes from an Anthropic example, given without a measurement protocol.

As soon as a whole task is measured, the order of magnitude changes. Anthropic’s documentation gives its own results: 38% fewer billed tokens for a project-management agent with 75 tools, with no loss of accuracy; 20 to 40% on real traffic, when a request carries between 10 and 49 tools; 24% fewer on web research, with results 11% better. And a counter-example: on a customer-service benchmark where each turn needs only one or two calls, scores do not move and the bill rises by 8%.

Code mode: what is left of the usage

Calling tools directly counts as 100%. Tokens or cost, depending on what each source publishes.

On tool descriptions, or on an example

  • The whole Cloudflare APICloudflare, February 2026

    −99.9%2,500 endpoints

  • An agent wired to many toolsAnthropic, November 2025, example

    −98.7%150,000 → 2,000 tokens

On tasks carried through to the end

  • Project management, 75 toolsAnthropic, documentation

    −38%accuracy unchanged

  • Complex researchAnthropic, November 2025

    −37%43,588 → 27,297 tokens

  • Real traffic, 10 to 49 toolsAnthropic, documentation

    −20 to −40%depending on the task

  • Web researchAnthropic, documentation

    −24%results: +11%

  • Customer service, one or two calls per turnAnthropic, documentation

    +8%scores unchanged

Sources: Cloudflare (20 February 2026); Anthropic, “Code execution with MCP” (4 November 2025), “Introducing advanced tool use” (24 November 2025) and the programmatic tool calling documentation, read on 25 November 2026. All these figures come from the vendors themselves.

Three reservations. All these figures come from the vendors themselves: we found no independent measurement of code mode. Cloudflare publishes no results on whole tasks. And Anthropic gives no figure for the Code Mode added to Claude Code on 12 November 2026: it is off by default and, according to its documentation, may change or be removed in any release.

The rule that emerges is simple. Code mode pays when there are many tools, a lot of data to sort or many calls to chain. For one question, one tool and one answer, it costs more than it saves.

“MCP is dead”: what the case was worth

Code mode was not the only answer to the cost of tools. In February 2026, some developers concluded that MCP should be done without.

On 17 February, the software company Nx announces that it has removed most of its MCP tools. It replaces them with skills: how-to sheets the AI loads only when it needs them. Its rule: skills for knowledge, MCP for connectivity. On 28 February a post by Eric Holmes appears, “MCP is dead. Long live the CLI”. Its argument: models already know how to use the command line, and MCP servers add flaky start-ups, endless re-authentication and all-or-nothing permissions. The post concedes that MCP remains the right choice when a tool has no command-line equivalent. In March, several websites report that Perplexity’s technical leadership announced it was dropping MCP internally; we found neither a recording nor a transcript of those remarks.

One test brings measurements. On 1 May 2026, Arize compares several ways of having the same AI work on a code repository: GitHub’s official MCP server, two skills that go through the command line, and the AI alone. Twenty-five tasks, 500 runs. Correctness is almost the same everywhere, between 0.83 and 0.85 out of 1. But on the hardest tasks, MCP costs more than six times as much and takes five times longer, with about twelve calls where the skills make five. The post qualifies its own result: one model, one repository, an MCP server that merely wraps an existing interface, and command-line tools made for developers. Its conclusion: MCP isn’t dead.

The case was right on one point: the old way of using MCP cost too much. It aimed at the wrong target on the other. The command line assumes a machine, a terminal and a developer in front of it. An online service used by several people, each with different rights, has none of those: that is where the socket remains necessary.

What MCP has become

During that debate, the protocol changed status three times.

It no longer belongs to its creator. On 9 December 2025, Anthropic hands it to the Agentic AI Foundation, co-founded with Block and OpenAI within the Linux Foundation, with support from Google, Microsoft, AWS, Cloudflare and Bloomberg.

It has been rebuilt. The version of 28 July 2026 removes sessions: every request stands on its own, which makes an MCP server much simpler to host. What is being retired stays in service for at least twelve months. What comes next is dated: a version every six months, the next on 30 March 2027.

It has absorbed the criticism. The protocol’s official documentation now describes code mode, under the name programmatic tool calling, as a best practice. It also recommends loading tools only on demand once their descriptions weigh too much. The August 2026 roadmap says it plainly: connecting to a server with a hundred tools means paying for its whole catalogue before the user has asked a single question.

MCP, two years on

The figures published by the protocol’s team.

  • 5 billion

    downloads of its development kits since the start, more than 4.5 billion of them in one year

    MCP, 24 Nov 2026
  • 700 million

    downloads in thirty days, against just over 90 million a year earlier

    MCP, 24 Nov 2026
  • 10,000

    active servers announced when it moved to the foundation

    MCP, 9 Dec 2025
  • 2,500

    contributors at least, since the project’s first day

    MCP, 24 Nov 2026

Sources: the protocol’s blog, “Two Years of MCP Builders” (24 November 2026) and “MCP joins the Agentic AI Foundation” (9 December 2025). Figures stated by the team, not checked by a third party.

Cloudflare, which gave code mode its name, makes no mistake about it: its code mode server is an MCP server. It says it has served billions of calls since February 2026.

The price of code mode: a sandbox

Having an AI write code means agreeing to run it. The three main sources each say so in their own way.

  • Anthropic: these requirements add operational overhead and security questions that direct calling avoids.
  • MCP’s documentation: approving a program is not approving every call it will make.
  • Cloudflare: running code does not replace authorisation.

Cloudflare’s answer is a sandbox with no internet access, where the program can reach only the planned tools, and where access keys stay outside: the code the AI writes never sees them. Not every product is there yet. The documentation of Claude Code’s Code Mode specifies that the sandbox applies to the commands the program launches, but that the program itself, and its calls to MCP tools, run outside it. To isolate it, the documentation points to a container or a virtual machine.

What it changes for your project

If you are having an AI connected to your tools, your mailbox or your customer file, four questions are enough to know where you stand.

  1. How many tools does the AI have in front of it on each question, and how many tokens is that? MCP’s documentation advises changing method once descriptions exceed a few per cent of the model’s memory.
  2. Who chains the calls: the model, or a program it writes? If it is a program, ask where it runs, what it can reach, and where the keys are kept.
  3. Does a sensitive action still require authorisation, even in the middle of a program? Sending a message, deleting a record, paying: the rule must not depend on how the tool is called.
  4. Has the gain been measured on your tasks? Not on a vendor’s example. Anthropic gives this advice itself: compare billed tokens with and without, on a sample of your real usage.

And one piece of good news: nothing has to be redone. A tool plugged in through MCP today stays plugged in tomorrow. Code mode sits on top.

These questions apply to any automation that relies on an AI: what it is allowed to see, what it is allowed to do, and what each question costs. If you are preparing a project of this kind, tell us about it.

The figures quoted were read at their source on 25 November 2026. They come from the vendors and describe their own products: none has been verified by us.

Sources