Anthropic’s engineering team argued in a post on 4 November 2025 that an agent should use MCP tools by writing code, not by asking the model for one tool call at a time. Its worked example, copying a meeting transcript from Google Drive into Salesforce, falls from 150,000 tokens to 2,000, which the post calls a time and cost saving of 98.7%.1 A year on, the same idea sits inside Claude Code’s experimental Code Mode and Anthropic’s API. This is what the post says, what it leaves out and where the idea went.
The short version
MCP, the Model Context Protocol, is the open standard Anthropic launched in November 2024 for connecting AI agents to tools and data. The post is an engineering note, not a research paper. It names two problems, proposes one fix and works through a single example. It publishes no benchmark.
150,000 to 2,000
tokens in the Drive-to-Salesforce example
98.7%
time and cost saving the post reports
50,000
extra tokens a 2-hour transcript could add when it passes through the model
10,000 to 5
spreadsheet rows the model reads after the code filters them
The two problems it names
The post says developers now build agents with access to hundreds or thousands of tools across dozens of MCP servers. Two things then crowd the context window, which is the amount of text a model can hold in view at once.
- Tool definitions. Most MCP clients load every definition up front. With thousands of tools, the post says an agent processes hundreds of thousands of tokens before it reads the request.
- Intermediate results. Ask an agent to download a meeting transcript from Google Drive and attach it to a Salesforce lead, and the transcript flows into the model, then out again as the model writes it into the Salesforce call. For a 2-hour sales meeting, Anthropic says that could mean an additional 50,000 tokens. Larger documents can exceed the context window and break the workflow, and models may be more likely to make mistakes copying data between calls.

The fix: tools become files, and the agent writes the glue
Anthropic’s answer is to present MCP servers as code APIs instead of direct tool calls. One approach in the post generates a file tree with one TypeScript file per tool:
servers
├── google-drive
│ ├── getDocument.ts
│ ├── ... (other tools)
│ └── index.ts
├── salesforce
│ ├── updateRecord.ts
│ ├── ... (other tools)
│ └── index.ts
└── ... (other servers)
Each file is a thin wrapper that calls the MCP tool. The agent lists the ./servers directory to see what exists, opens only the files it needs and writes a short script that joins them. The post’s version of the transcript job looks like this:
// Read transcript from Google Docs and add to Salesforce prospect
import * as gdrive from './servers/google-drive';
import * as salesforce from './servers/salesforce';
const transcript = (await gdrive.getDocument({ documentId: 'abc123' })).content;
await salesforce.updateRecord({
objectType: 'SalesMeeting',
recordId: '00Q5f000001abcXYZ',
data: { Notes: transcript }
});
The transcript moves from Drive to Salesforce inside the execution environment, and the model never reads it. Anthropic says this takes the example from 150,000 tokens to 2,000.

What else it buys
The post lists five benefits beyond the headline number. Here they are with the example Anthropic gives for each.
| Benefit | Anthropic’s example |
|---|---|
| Progressive disclosure | The agent opens tool files on demand, or calls a search_tools tool with a detail level: name only, name and description, or the full schema. |
| Context-efficient results | Fetch a 10,000-row sheet, filter it to pending orders in code and show the model five rows. |
| Control flow | A while loop polls a Slack channel for “deployment complete”, instead of alternating tool calls and sleeps through the agent loop. Letting the sandbox evaluate conditionals also cuts time to first token. |
| Privacy | Intermediate results stay in the execution environment unless the code logs them. The client can swap emails and phone numbers for placeholders before the model sees them. |
| State and skills | Agents write files such as ./workspace/leads.csv to resume work, and save working code as reusable functions in ./skills, which ties to Agent Skills. |
How the privacy placeholders work
In Anthropic’s example, an agent imports contact details from a spreadsheet into Salesforce. The MCP client intercepts the data and replaces it with placeholders such as [EMAIL_1], [PHONE_1] and [NAME_1] before the model sees it. When the data goes into another MCP tool call, the client looks up the real values. The real addresses and numbers flow from Sheets to Salesforce without passing through the model. Anthropic adds that the same mechanism can set deterministic rules about where data may flow.
What the 150,000 figure is, and isn’t
It’s one worked example in a design note. The post doesn’t name the model, the number of tools, the number of runs or how it counted tokens. It gives no latency or dollar figure, though it calls the 98.7% a time and cost saving.
The post is plain about the price of the approach:
Running agent-generated code requires a secure execution environment with appropriate sandboxing, resource limits, and monitoring. These infrastructure requirements add operational overhead and security considerations that direct tool calls avoid.
Anthropic, Code execution with MCP
Anthropic’s later numbers are smaller and tied to named workloads. In its 24 November 2025 post on advanced tool use, a Tool Search Tool took a setup with more than 50 MCP tools from about 77K tokens of context before any work to about 8.7K. Programmatic Tool Calling cut average usage on complex research tasks from 43,588 to 27,297 tokens, a 37% reduction.

From blog post to product
The post credits Cloudflare, which had published a similar approach and called it Code Mode. Anthropic says the core insight is the same: LLMs are adept at writing code, so developers should use that strength when agents talk to MCP servers. Cloudflare’s post, dated 26 September 2025, puts it more bluntly.
LLMs are better at writing code to call MCP, than at calling MCP directly.
Cloudflare, Code Mode: the better way to use MCP
Anthropic then shipped the pattern as product. The advanced tool use post introduced the Tool Search Tool, Programmatic Tool Calling and Tool Use Examples, and says Claude for Excel uses Programmatic Tool Calling to read and modify spreadsheets with thousands of rows without overloading the model’s context window. On 12 November 2026, Claude Code added an experimental Code Mode in which Claude writes JavaScript that makes several tool calls in one step. Two earlier reports on this site cover how Claude Code and OpenCode took it up.
When to use it, and when to skip it
Anthropic’s own guidance, from the advanced tool use post, says calling tools from code is most useful when:
- you process large datasets and need only aggregates or summaries
- a workflow has three or more dependent tool calls
- you filter, sort or transform results before the model sees them
- intermediate data shouldn’t influence the model’s reasoning
- you run parallel operations across many items
It helps less when the work is a simple single-tool call, a quick lookup with a small response, or a task where the model should see and reason about every intermediate result. Programmatic Tool Calling adds a code execution step, and Anthropic says the extra overhead pays off when the token savings, latency gains and accuracy gains are substantial.

The recipe, in five steps
These steps follow the post’s own example. It gives code snippets in TypeScript and no reference implementation.
- Generate one typed wrapper file per MCP tool, grouped by server, each calling a single
callMCPToolfunction. - Let the agent list the directory and open only what it needs, or give it a
search_toolstool with a detail-level parameter. - Run the code it writes in a sandbox with resource limits and monitoring.
- Log only what the model should see, such as a count, the first five rows or a status line.
- Save code that works as a skill, with a
SKILL.mdfile beside it.
Plain-English glossary
- MCP
- The Model Context Protocol, an open standard for plugging tools and data sources into AI agents.
- Tool definition
- The description of a tool an agent is given: its name, what it does and what inputs it takes.
- Context window
- The amount of text a model can hold in view at once.
- Token
- A small chunk of text. Models read, and are billed for, tokens.
- Sandbox
- A sealed area where code runs with only the access it has been given.
- Progressive disclosure
- Showing the model a tool’s details only when it needs them.
- 150,000 minus 2,000 is 148,000, which is 98.7% of 150,000. ↩︎
Discover more from Sulat AI & Tech News
Subscribe to get the latest posts sent to your email.






