Danielle Scantling5 pieces · 7 min
Two Ways to Cut MCP Token Costs, and When to Use Each (2026)
So now we have all these MCPs. How do we stay efficient and keep our agents lean and sharp?
There are two answers from Anthropic right now: Tool Search and code execution with MCP. They overlap, they are not rivals, and they cost very different amounts of work. Here is what each one does, with code, and how to pick.
01 / 05 · 1 min
Your Agent Is Reading the Manual. All of Them.
MCP is an open standard that connects agents to external systems. It works well, so we keep adding servers. Then we act surprised when the context window fills up.
Anthropic names two causes:
- Tool definitions. Many clients load every one of them up front.
- Tool results. Each one passes through the model, which often writes the same data out again for the next call.
To put a number on the first cause: a setup with GitHub, Slack, Sentry, Grafana and Splunk can use about 55k tokens on definitions. That is before any work happens.
02 / 05 · 2 min
Tool Search: Stop Loading What You Do Not Use
Tool Search keeps definitions out of context until Claude searches for them. By default, a search returns up to five tools. In the API, you add the search tool and mark the others as deferred:
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=2048,
messages=[{"role": "user", "content": "What is the weather in San Francisco?"}],
tools=[
{"type": "tool_search_tool_regex_20251119", "name": "tool_search_tool_regex"},
{
"name": "get_weather",
"description": "Get the weather at a specific location",
"input_schema": {
"type": "object",
"properties": {"location": {"type": "string"}},
"required": ["location"],
},
"defer_loading": True,
},
],
)Three details to know before the API returns a 400 and teaches you:
- At least one tool must not be deferred.
- Never defer the search tool itself.
- A deferred tool cannot have
cache_control.
For MCP servers that use the API's MCP connector, set defer_loading on the mcp_toolset entry, not on each tool. Here is that setup for a whole MCP server, with the search tool included. The URL and token are placeholders:
import anthropic
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-opus-5-5",
max_tokens=1000,
messages=[{"role": "user", "content": "Use tools from mcp-server-2 to complete this task"}],
mcp_servers=[
{
"type": "url",
"url": "https://mcp.example2.com/sse",
"name": "mcp-server-2",
"authorization_token": "TOKEN2",
}
],
tools=[
{"type": "tool_search_tool_regex_20251119", "name": "tool_search_tool_regex"},
{
"type": "mcp_toolset",
"mcp_server_name": "mcp-server-2",
"default_config": {"defer_loading": True},
},
],
betas=["mcp-client-2025-11-20"],
)In the Agent SDK, Tool Search is on by default as of November 2026, with some exceptions. You can also set a threshold. This turns Tool Search on when deferrable definitions reach 5% of the context window:
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Find and run the appropriate database query",
options: {
mcpServers: {
"enterprise-tools": { type: "http", url: "https://tools.example.com/mcp" },
},
allowedTools: ["mcp__enterprise-tools__*"], // pre-approves every tool on this server
env: { ...process.env, ENABLE_TOOL_SEARCH: "auto:5" },
},
})) {
if (message.type === "result" && message.subtype === "success") {
console.log(message.result);
}
}Tool names matter here, because search matches on names and descriptions. search_slack_messages will be found more often than query_slack. Your vague tool names now have consequences.
Anthropic says it typically cuts definition tokens by over 85%. It also helps with choice: accuracy drops past 30 to 50 loaded tools. The price is an extra search step. With fewer than 10 tools, you probably do not need it.
03 / 05 · 2 min
Code Execution: Let the Code Carry the Data
Here the agent writes code that calls your tools. Anthropic's post (November 4, 2025) lays out MCP servers as TypeScript files:
servers/
├── google-drive/
│ ├── getDocument.ts
│ └── index.ts
└── salesforce/
├── updateRecord.ts
└── index.tsEach file is a thin typed wrapper around one MCP tool:
// servers/google-drive/getDocument.ts
import { callMCPTool } from "../../../client.js";
export interface GetDocumentInput {
documentId: string;
}
export interface GetDocumentResponse {
content: string;
}
export function getDocument(input: GetDocumentInput): Promise<GetDocumentResponse> {
return callMCPTool<GetDocumentResponse>("google_drive__get_document", input);
}The agent reads only the files it needs. Then it moves a transcript from Drive to Salesforce like this (adapted from the post):
import * as gdrive from "./servers/google-drive";
import * as salesforce from "./servers/salesforce";
const { content: transcript } = await gdrive.getDocument({ documentId: "abc123" });
await salesforce.updateRecord({
objectType: "SalesMeeting",
recordId: "00Q5f000001abcXYZ",
data: { Notes: transcript },
});The transcript goes from one system to the other without a detour through the model. Filtering works the same way: code can read a 10,000-row sheet and show the model five rows.
// Assumes a getSheet wrapper like getDocument above
import * as gdrive from "./servers/google-drive";
const allRows = await gdrive.getSheet({ sheetId: "abc123" });
const pendingOrders = allRows.filter((row) => row["Status"] === "pending");
console.log(`Found ${pendingOrders.length} pending orders`);
console.log(pendingOrders.slice(0, 5)); // the model sees only this sampleIn the post's example, usage fell from about 150,000 tokens to about 2,000, or 98.7%. It is one example, not a promise.
There is one more part of the post that I like. When code works, the agent can save it as a reusable function. Add a SKILL.md file, and it becomes a skill that the agent can find and use again. So MCP servers are the raw tools, and skills are the tested recipes that use them. I have my own set of skills built this way. More on that another time.
Now the bill: you are running code that an agent wrote. You need a sandbox, resource limits and monitoring. "It worked on my machine" is not a security model.
04 / 05 · 1 min
Which One Do You Need?
Start with Tool Search if definitions are your problem. It is the cheaper fix. Add code execution when large results or long tool chains are eating your context.
How the two compare:
| Question | Tool Search | Code execution with MCP |
|---|---|---|
| Cuts tool definition tokens? | Yes | Yes |
| Cuts tool result tokens? | No | Yes, when code filters the data |
| Setup | Low | Higher: needs a secure sandbox |
| Main cost | Extra round trip per search | Operations and security work |
| Best fit | Many tools | Large data or multi-step chains |
This is not a cage match. The two solve overlapping problems at different levels, and the ideas can work together.
05 / 05 · 1 min
What Is Next
I’m going to run some tests this week and I will post a follow-up. Vendor numbers are interesting. I want to see what happens outside the example.
Have you tried either one? What did you expect, and what did you get?