Skip to main content

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.

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.ts

Each 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 sample

In 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.

Keep reading → Which One Do You Need?

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.

Keep reading → What Is Next

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?

Share this thread

References

  1. 01Code execution with MCP: Building more efficient agents (Anthropic, November 4, 2025)
  2. 02Tool search tool (Claude API docs)
  3. 03MCP connector (Claude API docs)
  4. 04Scale to many tools with tool search (Claude Agent SDK docs)