/context may over-state MCP token cost
A developer measured a server that `/context` reported at 45,018 tokens as costing 15,282 tokens in a single batched `count_tokens` call, and attributed the gap to per-tool summation re-counting the ~313-346-token tool-use preamble once per tool.
Reported by people who use Claude Code heavily. We have not reproduced it, and it may be version-specific or plain wrong.
What this costs you if it is wrong
This is one person's measurement of one server (XcodeBuildMCP) at one point in time, and nobody here has reproduced it. Acting on it means keeping an MCP server you might otherwise have disconnected — cheap to undo, but if the arithmetic has since been fixed, dividing the reported figure by three understates your real context cost and you will hit compaction sooner than you planned. Measure your own setup before you trust the ratio.
You run /context, see a five-figure number next to an MCP server, and reach for /mcp to disable it. That reflex is worth a second's hesitation: at least one careful measurement says the number you are reacting to may be several times the tokens that server actually costs per request.
The measurement
A developer measured one MCP server three different ways and got three different answers:
| How it was measured | Result |
|---|---|
| Local tokenizer run over the tool JSON | 14,081 tokens |
One batched count_tokens call with all tools attached | 15,282 tokens |
Summing a per-tool count_tokens call for each tool | 45,018 tokens |
The third row is reportedly how /context arrives at its MCP figure. The proposed explanation: every count_tokens request that carries tool definitions also carries a hidden tool-use preamble of roughly 313-346 tokens. Measure one tool, you pay it once. Measure sixty tools one at a time and add the results, and you have counted that preamble sixty times — about 20k tokens of pure double-count on top of the real ~15k.
A separate write-up on a four-server setup with tool search deferral active reported roughly 7,077 tokens of steady-state overhead for 37 tools, against roughly 20k with deferral off. Neither figure is nothing. Neither is "half your context window" either.
Why this matters less than it used to
Since tool search became the default, MCP tool definitions are deferred: only tool names and server instructions load at session start, and Claude fetches a full schema on demand when it decides to use that tool. The docs describe the mechanism in Scale with MCP tool search, and the context window walkthrough lists MCP tools as a deferred line item with a small startup cost.
So on a default setup the /context MCP line is already small, and the over-count question is mostly academic. It stops being academic in every case where tools load upfront instead:
ENABLE_TOOL_SEARCH=false, orauto/auto:Nwhile the definitions still fit under the thresholdANTHROPIC_BASE_URLpointing at a non-first-party host, where tool search is off by default because most proxies do not forwardtool_referenceblocksCLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS, which stripsdefer_loadingand cannot be overridden by settingENABLE_TOOL_SEARCHyourself- Microsoft Foundry deployments hosted on Azure, and Google Cloud Agent Platform models earlier than the 4.5 generation
- Individual servers you exempted with
alwaysLoad: true
Those are exactly the setups where a big MCP number appears and someone starts disconnecting servers.
What to do instead of trusting the number
Measure it yourself, once, for your own configuration:
# 1. See what Claude Code reports
claude
# then: /context — note the MCP tools figure
# 2. Force the interesting case, where tools load upfront
ENABLE_TOOL_SEARCH=false claude
# then: /context — note the figure againThen compare against a single count_tokens API call carrying the same tool definitions in one request. One call, all tools, one preamble. If your single-call number lands far below the /context figure, the summation hypothesis holds for your version. If the two agree, either the arithmetic changed or it never applied to your setup, and you can stop worrying about it.
What is actually unverified here
Being specific about the gaps, because that is the whole value of this entry:
- The mechanism is inferred, not confirmed. No official source states that
/contextsums per-tool measurements. The author reverse-engineered it from the arithmetic lining up. - The version is unknown. The measurement predates tool search being on by default. If the summation has since been corrected, this tip is stale.
- The sample is one server. The 3x ratio is a property of tool count and average schema size, not a constant. A server with six tools would show a far smaller gap; the preamble is charged per measurement, so the error scales with how many tools you have.
count_tokensis itself an approximation of what a live request costs, since it does not model caching or the rest of your conversation.
The cheap, correct posture: before you disconnect a server on the strength of a /context number, spend two minutes measuring it in one batched call. If the server is genuinely costing you 15k rather than 45k, that is often the difference between "cut it" and "keep it and turn deferral back on."
Checkpoint
-
Under the default configuration, what does the MCP line in
/contextactually represent — full tool schemas, or something smaller?Show answerAnswer
Something smaller. Since tool search became the default, only tool names and server instructions load at session start and Claude fetches a full schema on demand — the docs describe that under Scale with MCP tool search, and the context-window walkthrough lists MCP tools as a deferred line item with a small startup cost. That much is documented.
The tip's further claim — that even the number you see may be roughly three times what the server costs per request — is a different matter. It rests on one developer's measurement of one server at one version, nobody here has reproduced it, and no official source qualifies the
/contextfigure at all. -
Name two configurations in which MCP tool definitions load upfront rather than deferred.
Show answerAnswer
Any two of:
ENABLE_TOOL_SEARCH=false, orauto/auto:Nwhile the definitions still fit under the threshold;ANTHROPIC_BASE_URLpointing at a non-first-party host, where tool search is off by default because most proxies do not forwardtool_referenceblocks;CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS, which stripsdefer_loadingand cannot be overridden by settingENABLE_TOOL_SEARCHyourself; a Microsoft Foundry deployment hosted on Azure, or a Google Cloud Agent Platform model earlier than the 4.5 generation; or individual servers you exempted withalwaysLoad: true. Those are the setups where a big MCP figure actually shows up — which is exactly where the over-count question stops being academic and someone starts disconnecting servers. -
Why would the claimed over-count be larger for a 60-tool server than for a 6-tool one?
Show answerAnswer
Because the proposed error is charged per tool, not per server. Every
count_tokensrequest carrying tool definitions also carries a hidden tool-use preamble of roughly 313-346 tokens; if/contextsums one call per tool, that preamble is counted once for each, which across 60 tools is about 20k of pure double-count on top of a real ~15k and across six is a fraction of it. The 3x ratio is therefore a property of tool count and average schema size, not a constant.Treat that as a hypothesis about where a number comes from. No official source says
/contextsums per-tool measurements — the author reverse-engineered it from the arithmetic lining up, and one batchedcount_tokenscall carrying all your tools at once is what would confirm or kill it for your version.