I Measured My MCP Server's Context Tax Before Adding a Third Tool
I Measured My MCP Server's Context Tax Before Adding a Third Tool The loudest argument on DEV this week is about MCP servers quietly eating context windows — the top post on the subject in our weekly scan pulled 57 com
I Measured My MCP Server's Context Tax Before Adding a Third Tool
The loudest argument on DEV this week is about MCP servers quietly eating context windows — the top post on the subject in our weekly scan pulled 57 comments, and most of them were people discovering the cost only after stacking five or six servers.
The mechanism is simple, and it's worth stating plainly: a tool doesn't sit idle until it's called. For a model to know a tool exists, the host sends the tool's full definition — name, description, and the complete JSON schema for its inputs — with every request. Every tool you register is a standing charge on every turn, whether it fires or not.
So before our own MCP server grows, I measured it. Not a benchmark of somebody else's stack — our actual build.
The server, as it stands
nova-ops-nim-mcp is a small MCP server for video generation work. At v1.0.0 it exposes exactly two tools:
-
nim_generate_image— generate an image (Flux Pro / Flux Realism) -
nim_generate_video— turn an image into a video, with a duration and a motion style
Two tools. That smallness turns out to be the whole story — but I didn't want to assert it, I wanted to measure it.
The audit (30 lines, no dependencies)
Token counts depend on the tokenizer, so this script estimates two ways — at 4 characters per token and at 3.6 — and reports the serialized size, which is exact. It runs on any modern Node:
const tools = [ /* your tool definitions, as your host sends them */ ];
for (const t of tools) {
const s = JSON.stringify(t);
console.log(t.name, "chars=", s.length,
"estTokens@4cpt=", Math.ceil(s.length / 4),
"[email protected]=", Math.ceil(s.length / 3.6));
}
const all = JSON.stringify(tools);
const perTurn = Math.ceil(all.length / 4);
console.log("TOTAL tools=", tools.length, "chars=", all.length,
"estTokensPerTurn@4cpt=", perTurn);
console.log("10-turn cumulative @4cpt=", perTurn * 10);
console.log("Share of a 200k window @4cpt=",
(perTurn / 200000 * 100).toFixed(3) + "%");
The full runnable version, with our tool definitions copied in verbatim, is in our dev.to working repo (audit-tools.js). Here is what it printed for our server, unedited:
nim_generate_image chars= 309 estTokens@4cpt= 78 [email protected]= 86
nim_generate_video chars= 478 estTokens@4cpt= 120 [email protected]= 133
TOTAL tools= 2 chars= 790 estTokensPerTurn@4cpt= 198
10-turn cumulative @4cpt= 1980
Share of a 200k window @4cpt= 0.099%
Reading those numbers honestly
Our whole server costs roughly 200 tokens per turn — about a tenth of one percent of a 200k context window. Across a 10-turn agent loop, the model has attended to roughly 2,000 tokens of our schema in total. That's not zero, but it's close enough to zero that tool selection stays obvious: with two dissimilar tools, there is nothing to confuse.
Two caveats, because estimates deserve them:
- These are estimates, not tokenizer counts. The real figure moves with the model. The serialized size — 790 characters for both tools — is the hard number; argue with the conversion factor, not the size.
- Prompt caching changes the dollar cost, not the attention cost. A cached prefix is cheaper to bill, but the model still reads every schema you send, on every turn, and every schema still competes with your actual work for attention.
Where the tax actually comes from
Our two tools average about 100 estimated tokens each. That's the useful unit. Run the arithmetic forward — labelled as arithmetic, not as a benchmark: a server whose tools average the same ~100 tokens, but which exposes 50 of them, is sending roughly 5,000 tokens of schema before you've typed a word, and a stack of several such servers multiplies from there. The tax isn't any single tool. It's the habit of registering an entire API surface "just in case."
The rule we adopted before adding tool #3
Every new tool for this server now has to pass three checks before it merges:
- Measure it. Run the audit with the new definition included. If the per-turn total moves, the PR says by how much.
- Budget it. The server's total schema stays under 1,000 estimated tokens per turn — roughly five tools at our current average. A tool that would break the budget has to replace one, not join.
- Earn the description. Property descriptions are the fattest part of most schemas. Ours run one short line each. If a parameter needs a paragraph, the tool is probably doing too much.
None of this is anti-MCP. The protocol is how our agent reaches real tools at all. It's anti-unmeasured MCP. The audit takes a minute, the script is above, and the cheapest time to run it is before your server — like ours, right now — grows its third tool.
Questions I expect, answered up front: the estimates use characters-per-token heuristics (4 and 3.6), not a model-specific tokenizer; the server measured is v1.0.0 on the public repo linked above, commit 5cd2dd3; the audit script was run on Node v24.22.1 and its output is reproduced exactly.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.