Every MCP server you connect costs context before you call a single tool. The server’s tool names, descriptions and schemas all take space in the window. This guide shows you how to measure that cost for your own setup, and how to decide which servers stay.
Our context budgeting guide covers the whole ledger: system prompt, memory files, skills and messages. This page goes deeper on one line of it. It is a working audit: measure, attribute, decide, fix.
What you’ll learn
- How MCP tool definitions reach the context window, with and without tool search
- A short audit loop that finds the servers that do not earn their cost
- What
ENABLE_TOOL_SEARCHandalwaysLoadchange - A rule for when a plain CLI beats an MCP server
- How to scope servers so they only load where you need them
- How to build a server that is cheap to carry
Prerequisites
- A current Claude Code build, with at least one MCP server connected
- Basic knowledge of
.mcp.jsonand theclaude mcpcommands - We checked every setting and limit below against the Claude Code MCP docs on 2026-11-23. Defaults change between versions, so check your own
/contextoutput.
How MCP servers cost context
Without tool search, Claude Code puts every tool definition from every connected server into context when the session starts. A definition is the tool name, its description and its input schema. You pay for it whether or not Claude calls the tool.
Tool search is on by default now. With it, only tool names and server instructions load at the start. Claude finds a tool when it needs one through a ToolSearch tool, and only then does the full schema enter context. The MCP docs say adding more servers then has “minimal impact” on the window.
Anthropic gives one example of the size of the effect. In its advanced tool use post, a setup of 50-plus MCP tools used about 77K tokens before any work began. With the Tool Search Tool it used about 8.7K, which Anthropic calls an 85% reduction. That example is about the API tool, not a Claude Code measurement. Your own numbers will differ, so measure them.
Deferral lowers the cost and moves it. It does not remove it. Two costs stay:
- Names and server instructions still load, for every connected server.
- Each search is an extra tool-use step in the middle of the task.
When tool search is off
Tool search does not run everywhere. Check these first if your MCP line looks too big:
ENABLE_TOOL_SEARCH=falseis set.- The model is older than Opus 4 or Sonnet 4. Claude Code loads all MCP tools upfront on earlier models.
- You are on Microsoft Foundry deployments hosted on Azure, which reject tool search.
- You are on an older model on Google Cloud’s Agent Platform.
ANTHROPIC_BASE_URLpoints at a gateway that does not forward the tool search fields. Claude Code expects the gateway to passdefer_loadingandtool_referenceblocks. On v2.1.305 or later it can retry without tool search after a rejected request, so MCP tools load upfront instead.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETASis set. You cannot override it withENABLE_TOOL_SEARCH.
The audit loop
Profile before you remove anything. Do this in a project where you use MCP servers every day.
- 01
Measure the full cost
Start a session with deferral off, so you see the full definitions:
ENABLE_TOOL_SEARCH=false claude. Run/contextbefore you type anything else. Write down the MCP tools line. This is the most your servers can cost. - 02
Measure the deferred cost
Start a normal session with
claude, with no variable. Run/contextagain. The MCP tools should now be marked as deferred, and the line is much smaller. This is what your servers cost today. - 03
Attribute cost to servers
Run
/mcp. It lists each connected server with its tool count, and flags servers that advertise tools but expose none. A server with 40 tools costs more than a server with 4, in both modes. - 04
Check what you actually use
On Pro, Max, Ultra, Team and Enterprise plans,
/usageshows a breakdown of recent usage by skill, subagent, plugin and individual MCP server. A server with a high tool count and a low share is your first candidate. - 05
Remove or disable one server, then re-measure
Toggle the weakest server off in
/mcp, or runclaude mcp remove <name>. Run/contextagain and compare. Repeat until every server left earns its place.
/context shows the real numbers for your build, so we do not print sample output here. The format changes between versions.
One more check helps. If /context labels tools as deferred and the total is small, your cost is names and instructions. In that case the biggest saving is usually not another setting. It is removing servers you rarely use.
A one-off audit goes stale as you add servers. To track the number over time, see instrument your Claude Code usage.
Tool search settings that matter
Claude Code reads the ENABLE_TOOL_SEARCH environment variable. You can also put it in the env field of settings.json.
| Value | What happens |
|---|---|
| unset | All MCP tools are deferred and loaded on demand. Tools load upfront in the cases listed above. |
true | MCP tools are deferred, with the same fallbacks as unset. |
auto | Threshold mode. Tools load upfront while their definitions total under 10% of the context window. At 10% or more, tool search turns on. |
auto:N | Same, with your own percentage from 0 to 100, for example auto:5. |
false | All MCP tools load upfront. Use it for measuring, rarely for daily work. |
You can also stop tool search by denying the ToolSearch tool in permissions.deny. MCP tools then load upfront.
Keep a few tools always visible
If Claude needs one server’s tools on almost every turn, skip the search step for that server. Set alwaysLoad in its entry:
{
"mcpServers": {
"docs": {
"type": "http",
"url": "https://mcp.example.com/mcp",
"alwaysLoad": true
}
}
}
All tools from that server then load at the start, whatever ENABLE_TOOL_SEARCH says. Startup also waits for the server’s tools, up to the 5-second connect timeout. Use this only for a small server, because every upfront tool takes context from your conversation.
The reverse also exists. Set "alwaysLoad": false to keep all of a server’s tools deferred, including tools whose author marked them to load upfront. This needs Claude Code v2.1.287 or later.
When a plain CLI beats an MCP server
A CLI adds no per-tool listing to context. Claude calls it through the Bash tool and reads --help output only when it needs it. The Claude Code costs docs say this directly: tools like gh, aws, gcloud and sentry-cli are more context-efficient than MCP servers.
Here is a simple rule:
| Situation | Choice |
|---|---|
| A good CLI exists and Claude knows it | Use the CLI |
| The service needs an OAuth flow that a CLI cannot do | Keep the MCP server |
| No CLI exists for the service | Keep the MCP server |
| The environment has no shell | Keep the MCP server |
| You want the server’s tools, not its raw API | Keep the MCP server, scoped narrowly |
Make the choice standing policy. A line in your CLAUDE.md contract, such as “use gh, not the GitHub MCP server”, settles it for every session. With tool search on, the gap is smaller, but a deferred server still costs names, instructions and a search step.
Side idea: the CLI is not always the winner. A CLI has no schema, so Claude may guess flags wrong and spend turns on retries. If you see that, a typed MCP tool can be cheaper overall. Measure the whole task, not only the startup line.
The CLI-or-MCP question is one row of a bigger table. See choosing the right extension point for when a skill, hook or subagent fits better than either.
Scope servers to where they are used
Claude Code has three MCP scopes:
- Local is the default. The server loads only in the project where you added it, and stays private to you.
- Project is shared through a
.mcp.jsonfile in the repository. - User loads in every project you open.
A user-scoped database server therefore appears in every session, including repositories with no database. Add each server at the narrowest scope that covers its real use:
# see what is configured, with a health status for each server
claude mcp list
# remove a server you no longer use
claude mcp remove old-server
# add a server for this project only (local scope is the default)
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
You can also toggle a server off in /mcp without losing its configuration. Claude Code remembers the choice per project.
Headless runs
A claude -p run should load only what the job needs. Pass a config file with --mcp-config and add --strict-mcp-config. Claude Code then loads only the servers in that file and skips the ones in .mcp.json, ~/.claude.json and plugins.
{
"mcpServers": {
"sentry": {
"type": "http",
"url": "https://mcp.sentry.dev/mcp"
}
}
}
claude -p "Summarize the top three new Sentry errors since the last release" \
--mcp-config ci-mcp.json --strict-mcp-config \
--output-format json
A claude -p run cannot open the OAuth sign-in flow. For a server that needs sign-in, authenticate first in an interactive session, with /mcp or claude mcp login <name>. For the full pipeline, see headless Claude Code in CI and cron.
For interactive work there is a similar move. When one task needs a heavy server that the rest of the session does not, hand it to a subagent. Subagents as context firewalls shows how that keeps tool results out of your main thread.
Build a server that is cheap to carry
If you ship an MCP server, you set the price for everyone who connects it.
Write server instructions like a skill description. With tool search on, Claude decides whether to look at your server from tool names and server instructions. Say what category of tasks the tools handle, when Claude should search for them, and the key capabilities.
Know the limits. Claude Code cuts text that runs past these defaults, and Claude sees only what comes before the cut:
| Text | Limit |
|---|---|
| Server instructions, and a tool description loaded upfront | 4,096 characters |
| A tool description loaded through tool search | 16,384 characters |
Tool search matches against the shorter limit, so put the words Claude would search for near the start. These limits changed in recent versions (the shorter one was 2,048 characters before v2.1.296), so older articles may quote a different number. CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH changes both.
Do not multiply tools. Many near-identical tools make search noisy and cost names. Merge related operations behind a parameter, for example one search tool with a provider argument instead of four search tools.
Control result size. The tool result is the other half of the cost. These are the documented defaults:
- The transcript viewer warns when a tool result passes 10,000 tokens.
- The default maximum output is 25,000 tokens.
MAX_MCP_OUTPUT_TOKENSchanges it. - A text result over 50,000 characters is saved to a file, and Claude gets the file path instead.
- A tool can declare its own limit with
anthropic/maxResultSizeCharsin its_meta.
If you need to raise any of these, first ask whether the tool should filter and paginate on the server side.
Mark only a few tools as always loaded. Set "anthropic/alwaysLoad": true in the _meta of the two or three tools that nearly every task needs, and let tool search defer the rest. The person who adds your server can override this with their own alwaysLoad setting.
Where this is heading
Anthropic’s code execution with MCP post describes another direction. The agent writes code against MCP servers presented as a file tree of tools, and loads only the definitions it needs. In one example in that post, token use fell from 150,000 to 2,000. That is an Agent SDK and platform pattern, not a Claude Code setting, but the idea is the same: definitions on demand and results filtered in code.
Next steps
- Context window management in Claude Code: the rest of the ledger, from memory files to file reads.
- Instrument your Claude Code usage: turn this one-off audit into ongoing measurement.
- Claude Code extension points: the matrix: choose between an MCP server, a skill, a hook and a subagent.
- Studying for an exam? The lesson on integrating MCP servers covers scopes and tool search for CCAR-F, and MCP server development covers the server side for CCDV-F.