Tool Search for AI Agents: How Much Context Tool Definitions Take, When to Load Tools on Demand, and What Breaks

Context EngineeringMCP & Agent ProtocolsGaurav Dadhich5 December 202616 min read
Tool Search for AI Agents: How Much Context Tool Definitions Take, When to Load Tools on Demand, and What Breaks
On this page
  1. How much context do tool definitions take?
  2. When to load every tool and when to search
  3. How tool search works
  4. Building your own tool retrieval
  5. Does tool search break prompt caching?
  6. What the savings and accuracy evidence actually shows
  7. Where tool search fails
  8. How to test tool retrieval before you ship
  9. Smaller fixes worth trying first or alongside
  10. Tools are not memory
  11. Frequently asked questions

Published 5 December 2026. Every figure below was read or measured on 5 December 2026, and each one names its source.

Tool definitions are often the largest fixed block in an agent's prompt, and they are sent again on every model call whether the task needs one tool or none. We counted the 96 tool schemas that GitHub publishes for its GitHub MCP server and got 23,975 tokens, before the system prompt or the user's first message. The fix that providers now ship is tool search: you keep the full catalogue on the server side, the model starts with a search tool and a handful of core tools, and it loads the few definitions it needs when it needs them. Anthropic's tool search tool and OpenAI's tool_search both work this way, and the MCP client best practices draft recommends the same pattern under the name progressive discovery.

Tool search is the right default once your definitions pass roughly 10,000 tokens or a few dozen tools, and the wrong one below about ten tools that are all used on most turns. It adds a search step, it can miss the tool the model needed, and done carelessly it breaks your prompt cache. Whether it pays off for your agent comes down to one measurement you can take quickly, the token count of what your client actually sends, and one test you should run before shipping, which is whether the search finds the right tool for your real requests.

How much context do tool definitions take?

A typical MCP server's tools cost somewhere between a few hundred and a few tens of thousands of tokens, and the spread comes from schema verbosity far more than from tool count. Three sets of numbers, each with its setup stated:

Our count of the GitHub MCP server (5 December 2026). GitHub's README lists 100 tools; 96 of them have a published schema snapshot in the repository (the other four, Copilot and support-docs tools, have no snapshot). We serialised each tool as the three fields a client sends to the model (name, description and the input schema) in compact JSON and counted tokens with OpenAI's o200k_base tokenizer through tiktoken.

Slice of the GitHub MCP serverToolsTokens (o200k_base)
All 96 published schemas9623,975
Default toolsets (context, repos, issues, pull_requests, users)4510,661
Repositories toolset203,975
Issues toolset103,139
Pull Requests toolset103,020
Largest single tool (projects_write)11,567
Median tool1187

The mean tool is 250 tokens and the median is 187, but four tools that take an enum of methods or a large nested object (projects_write, custom_properties_write, issue_write and repository_ruleset_read) cost 3,962 tokens between them, about a sixth of the whole server. Two caveats apply. Claude uses a different tokenizer from o200k_base, so a Claude count of the same schemas will differ, and providers add their own tool-use instructions on top of your definitions, so the real prompt is larger than the raw schema count.

Anthropic's five-server example. Anthropic's engineering post introducing advanced tool use (24 November 2025) gives GitHub at 35 tools and roughly 26,000 tokens, Slack at 11 tools and roughly 21,000, Sentry, Grafana and Splunk at roughly 3,000, 3,000 and 2,000, for 58 tools and roughly 55,000 tokens, and says Jira alone uses roughly 17,000 and that Anthropic has seen tool definitions reach 134,000 tokens before optimisation. Their GitHub figure is a different server version, a different tool selection and a Claude tokenizer, which is exactly why our count does not match it. The Slack line is the more useful lesson: 11 tools costing almost as much as 35.

Client documentation. The Claude Agent SDK docs say 50 tools can use 10,000 to 20,000 tokens, and GitHub Copilot CLI's docs say a few dozen tool definitions can eat 10,000 to 20,000 tokens before the agent has done any work.

How to measure your own

Count what the model actually receives, not what your config file lists. For each connected server, call tools/list, keep name, description and inputSchema for every tool, serialise them the way your client does, and count tokens with your provider's token counter or the tokenizer your model uses. Then sort by size. In most catalogues a few tools with long enums, nested objects or pasted documentation dominate the total, and trimming those is cheaper than any retrieval system. Repeat the count whenever a server updates, because tool lists change without anyone on your team touching them.

Load everything when the catalogue is small and used broadly; search when the catalogue is large, grows over time, or most tools sit idle on most turns. Every source that publishes a threshold puts it in the same region:

SourceLoad everything whenSwitch to tool search when
Anthropic tool search docsFewer than 10 tools, every tool used in every request, or definitions under 100 tokens in total10 or more tools, definitions over 10,000 tokens, selection accuracy dropping, or 200+ tools from several MCP servers
Claude Agent SDKFewer than about 10 tools that fit comfortablyOn by default; ENABLE_TOOL_SEARCH=auto switches at 10% of the context window, auto:N at N%
Copilot CLIBelow roughly 30 toolsAbove that, on supported models, automatically
MCP client best practices (draft)Definitions take a small part of the windowA threshold of 1% to 5% of the context window

Token count is only half of the decision. Anthropic's docs state that Claude's ability to pick the right tool degrades once you exceed 30 to 50 available tools, so a large catalogue hurts selection even when you can afford the tokens. The other half runs the opposite way: each search is an extra model round trip, and the Agent SDK docs say that with fewer than about ten tools, loading everything up front is typically faster.

A rule that holds up across all four sources: measure your definitions, and if they are over 10,000 tokens or over roughly 30 tools, try tool search with your three to five most-used tools left always loaded. Below that, trim schemas instead.

How tool search works

Tool search changes when a definition enters the model's context, not what you send in the request. The flow is the same across providers:

  1. You declare every tool, and mark most of them as deferred (defer_loading: true in both the Anthropic and OpenAI APIs).
  2. The model starts with a search tool, the non-deferred tools, and a short indication of what is searchable.
  3. When it needs a capability it does not have, it calls the search tool with a query.
  4. The search returns a few matching tools, and their full definitions are added to the conversation.
  5. The model calls the discovered tool as normal, and your code runs it and returns the result.

On Anthropic's API you still send every definition, deferred or not, on every request, because the search runs server-side over the definitions in that request. There are two built-in variants: a regex variant, where Claude writes Python regular expressions of up to 200 characters, and a BM25 variant, where it writes natural-language queries of up to 500 characters. Both search tool names, descriptions, argument names and argument descriptions. A search returns up to five tools by default (Claude can set a limit from 1 to 10,000), a request can carry up to 10,000 deferred tools, at least one tool must stay non-deferred, and the docs recommend keeping your three to five most-used tools non-deferred. Discovered tools stay usable in later turns without another search. Tool search is not metered as a separate server tool; the definitions it loads count as ordinary input tokens.

OpenAI's version, available in the Responses API on gpt-5.4 and later according to its tool search guide, comes in two forms: hosted, where OpenAI searches the deferred tools you declared, and client-executed, where the model emits a tool_search_call and your application does the lookup. OpenAI recommends grouping deferred functions into namespaces or MCP servers with clear descriptions, ideally fewer than ten functions each, because for a lone deferred function the model still sees its name and description and the saving is mostly the parameter schema. In OpenAI's Agents API, MCP tools are deferred automatically when the model supports tool search.

Building your own tool retrieval

Build your own when your provider has no tool search, when you route between providers, or when retrieval has to respect something only your application knows, such as which tools a tenant is allowed to call. Anthropic supports this directly: your custom search tool returns tool_reference blocks in a normal tool_result, and the API expands them into full definitions, as described in the custom tool search section. OpenAI's client-executed mode does the same job.

The MCP draft lists four retrieval strategies, and each has a place:

  • Keyword (BM25 or regex). Cheap and predictable, and good when tool names and descriptions use the words people type.
  • Embeddings. Embed each tool's name, description and argument descriptions once, embed the model's search query at call time, and return the top-k by similarity. Better with synonyms ("refund" finding create_credit_note).
  • A small model as selector. A fast model reads the request and picks tools. The MCP draft says this usually works very well but costs more than the other two.
  • Hybrid. Score with keyword and embedding rankings together, which is what we would start with for a catalogue of a few hundred tools.

Three design choices matter more than the retrieval algorithm. Keep a small always-on core (the tools used on most turns, plus the search tool itself) so common work never pays for a search. Return names and one-line descriptions first and full schemas only for the tool the model picks, which is the catalog, inspect and execute layering the MCP draft describes. And group tools by server or namespace with consistent prefixes (github_, slack_), which Anthropic recommends so that one search can pull a whole related group.

Does tool search break prompt caching?

Built-in tool search does not, because discovered definitions are appended to the conversation instead of rewriting the tools block; changing the tool list yourself does. Anthropic's page on tool use with prompt caching states that deferred tools are not included in the system-prompt prefix and that a discovered tool is appended inline as a tool_reference block, so the prefix is untouched. The same page says that modifying tool definitions invalidates the entire cache (tools, system and messages), and the tool search docs add that a deferred tool cannot carry cache_control, so the cache breakpoint goes on a non-deferred tool. OpenAI's guide says tool search is designed to preserve the cache, with newly discovered tools injected at the end of the context window.

The trap is the home-built version that swaps the tools array per turn. The MCP draft warns that adding or removing tool definitions mid-conversation invalidates the cached prefix, and that the resulting miss can cost more tokens than the definitions you removed. Its two fixes are to append newly discovered definitions after the cache breakpoint instead of re-sorting the array, or to route every call through one stable call_tool meta-tool so the array never changes, and to treat disconnecting a server as a conversation-boundary event. We cover how coding agents keep the prefix stable in prompt caching in coding agent harnesses.

What the savings and accuracy evidence actually shows

The evidence for tool search is consistent in direction and thin in method, so treat every published figure as indicative.

  • Anthropic, token use. The advanced tool use post compares about 77,000 tokens of context consumed before any work (about 72,000 of it tool definitions for 50+ MCP tools) with about 8,700 tokens using tool search, and calls it an 85% reduction. The tool search docs say tool search typically reduces the five-server example by over 85%, loading three to five tools per request. Both are Anthropic measuring its own feature.
  • Anthropic, accuracy. The same post reports that on Anthropic's internal MCP evaluations Opus 4 went from 49% to 74% and Opus 4.5 from 79.5% to 88.1% with tool search enabled. The post does not state the number of tasks, the evaluation set or the scoring method, and it is self-measured.
  • Redis Iris, a vendor-made demo. Avi Chawla said on X on 30 November 2026, in a post made with Redis, that he tested Redis Iris's Context Gateway with 90 synthetic tools across support, CRM and billing, using the same model, question and backend data for both paths. The direct path sent 241.7 KB of tool definitions per model call; the gateway started with two tools (search_tools and run_tool) totalling 1.1 KB. Across the complete turn, direct tools used 90,941 input tokens and the gateway 28,606, which he gives as 70% fewer including discovery and tool results. The post does not name the model, and it is one question on a synthetic catalogue built for the demo.

None of these tell you what your agent will save. Your own number depends on how many tools a typical task touches out of the whole catalogue, and on how often the model has to search more than once.

Where tool search fails

Tool search moves the hard problem from "the model picks from 90 tools" to "the search returns the right five", and that second problem has its own failure modes:

  • The right tool is not retrieved. The model searches with words that do not appear in the tool's name or description, gets plausible near-misses, and calls the wrong tool or gives up. Anthropic's troubleshooting advice is to put the keywords users actually say into descriptions; Copilot CLI's docs say the same.
  • Description drift. A server update renames a tool or rewrites its description, and queries that used to find it stop matching. Re-index when a server signals a change (the MCP draft says to refresh on notifications/tools/list_changed) and re-run your retrieval tests after every server upgrade.
  • Near-duplicate tools. Two servers expose search or create_issue, and retrieval returns the wrong one with full confidence. Namespacing by server fixes most of it.
  • Search loops and extra latency. Each search costs a round trip. Copilot CLI keeps discovered tools for the rest of the conversation so each lookup happens once; the Claude Agent SDK keeps them until it compacts the messages where they were discovered, then searches again.
  • Over-trusting injected schemas. OpenAI's guide warns that if your client-executed search returns tools that were not in the original request, you should validate the schemas and expose only trusted definitions. A tool description is text the model reads and follows, so a catalogue fed from many servers needs the same review as any other prompt input.

How to test tool retrieval before you ship

Treat tool search as a retrieval system and test it like one. Take 50 to 100 real requests from your logs, label each with the tool or tools a correct run would call, and run your search over the full catalogue. Record whether the right tool lands in the top five (recall at 5), whether the model then calls it, and how many searches the run needed. Run the same set with all tools loaded and compare task success, input tokens and latency, which is the comparison OpenAI's Agents API guide recommends before choosing a default. Log which tools the model discovers in production, as Anthropic suggests, and investigate any tool that never gets found: it is either unused or undiscoverable, and both are worth knowing.

Smaller fixes worth trying first or alongside

Tool search is not the only lever, and on a modest catalogue it may not be the best one:

  • Load fewer toolsets. The GitHub MCP server's --toolsets flag exists for this; its README says enabling only the toolsets you need can help the model with tool choice and reduce context size. In our count, the default toolsets are 10,661 tokens against 23,975 for everything.
  • Trim the heaviest schemas. Long enums and embedded documentation in a handful of tools often account for a large share of the total.
  • Load whole servers on demand. The MCP draft describes keeping a registry of servers and connecting one only when the model asks for its capability.
  • Programmatic tool calling. Letting the model write code that calls tools keeps intermediate results out of context, which Anthropic and the MCP draft both describe as a complement to tool search.
  • Subagents. Give a subagent a narrow tool set for one job and return only its answer to the main agent.

For background on how MCP servers expose tools in the first place, see MCP servers explained, and for why the harness around the model decides most of this bill, see what an agent harness is.

Tools are not memory

A tool catalogue describes what an agent can do; memory records what happened and what is true about a particular user, tenant or project. Tool search retrieves capabilities and starts fresh every conversation, and that is correct, because the catalogue is the same for everyone and is already stored in full on your side.

Some past tool use is worth remembering, though, and it belongs in memory rather than in the catalogue. In our view the useful items are which tool resolved which kind of request for this user or tenant (a team whose "billing" questions always end in the same two finance tools), parameters the user always passes (their default repository, their region), and tools that failed for this account and why. Fed back at the start of a session, those memories can bias retrieval toward the tools a user actually needs or let you keep them always loaded for that user. Raw tool traces are not memory on their own; the distilled facts are. If you expose memory to the agent as an MCP tool, it is a natural member of the always-on core, since an agent that has to search for its own memory tool will sometimes not find it. Our guide to MCP memory servers covers what such a server should and should not do, and Maximem Synap offers a hosted MCP endpoint alongside its SDKs and REST API.

Frequently asked questions

How many tokens does an MCP server's tool list use?

It ranges from a few hundred tokens to tens of thousands. We counted 23,975 tokens (OpenAI o200k_base tokenizer) for the 96 published GitHub MCP server tool schemas on 5 December 2026, and 10,661 for its default toolsets. Anthropic's example puts Slack's 11 tools at roughly 21,000 tokens. Measure your own with tools/list and your provider's token counter.

When should I use tool search instead of loading all tools?

Use it when your tool definitions exceed roughly 10,000 tokens, when you have more than about 30 tools, or when you aggregate several MCP servers. Anthropic's docs recommend standard tool calling below 10 tools, and Copilot CLI skips tool search below roughly 30.

Does tool search break prompt caching?

Anthropic's and OpenAI's built-in tool search are designed not to: discovered definitions are appended to the conversation and the cached prefix stays intact. Changing the tools array yourself mid-conversation invalidates the cache, which is the common mistake in home-built versions.

Is tool search the same as RAG?

It is retrieval applied to tool definitions instead of documents: tool descriptions are indexed, the model's query is matched against them, and the top few are loaded. The difference is that a missed tool fails a task outright, so recall at k matters more than it does for a document passage.

Do I still send every tool definition on each request?

With Anthropic's tool search, yes: every definition goes in the tools array on every request, and defer_loading only controls what enters the model's context. With a client-executed search (OpenAI's client mode or your own search tool), your application holds the catalogue and returns only the matches.

From the team at Maximem

Stop rebuilding agent memory from scratch

Maximem Synap is the context management layer we built after hitting every problem in this post ourselves. Persistent recall across sessions, entity resolution and conscious forgetting, in Python, TypeScript and REST.

Looking for more to read? See our directory of the best engineering blogs to follow.