3.0.0
When a server exposes hundreds or thousands of tools, sending the full catalog to an LLM wastes tokens and degrades tool selection accuracy. Search transforms solve this by replacing the tool listing with a search interface, letting the LLM discover tools on demand.
When you add a search transform, list_tools() returns just two synthetic tools instead of the full catalog:
search_toolsfinds tools matching a query and returns their full definitionscall_toolexecutes a discovered tool by name
list_tools, and calls them through the proxy.
Choosing a Search Strategy
FastMCP provides two search transforms with different tradeoffs:RegexSearchTransform matches tools against a regex pattern. Zero overhead, no index to build, works well when the LLM knows roughly what it’s looking for. Searches tool names, descriptions, parameter names, and parameter descriptions.
BM25SearchTransform ranks tools by relevance using the BM25 Okapi algorithm. Better for natural language queries like “tools for working with databases.” Builds an in-memory index that auto-rebuilds when the catalog changes.
Both are self-contained with no external dependencies.
Basic Usage
Add the transform to your server. The search tools appear automatically.Search Results
The search tool returns tool definitions in the same format aslist_tools — each result includes the tool’s name, description, and full input schema. This means an LLM (or a human intercepting the output) can treat search results exactly like a list_tools response.
Pinning Tools
Some tools should always be visible regardless of search. Usealways_visible to pin them in the listing alongside the search tools:
Customizing Tool Names
The default namessearch_tools and call_tool can be changed to avoid conflicts:
Auth and Visibility
Search transforms respect the full authorization pipeline. Tools filtered by middleware, visibility transforms, or component-level auth checks will not appear in search results. This works because the search tool queries the server’slist_tools() through the complete pipeline at search time — the same filtering that controls what a client sees in list_tools also controls what they can discover through search.
ctx.disable_components()) are also reflected immediately in search results.
