tool_search tool up front. When the model needs something, it searches, the matching schemas are loaded, and they are included from the next request onwards.
This is the default for MCP agents —
dynamic_tools=True unless you say otherwise. This page shows how to see it working and when to turn it off.Build it
1
Install and set your key
2
Create the agent
max_loops="auto" lets the agent decide when it is done — a good fit here, because searching for a tool and then using it takes an unknown number of turns.3
Force the connection and inspect the catalog
Building the LLM is what pulls the server’s tools into the catalog, so do it explicitly when you want to look:The catalog holds the server’s tools; the request carries
tool_search and nothing else. That gap is the saving, repeated on every call of the run.4
Run a task and watch what gets loaded
loaded_names shows the handful of tools the task actually needed — everything else stayed out of the context window.The complete script
How the model knows to search
Two things are added when deferral is on:- A
tool_searchtool, which takes a keyword query and loads the matching schemas. - A system prompt notice telling the model that most of its tools are not loaded, that any tool list it has seen describes what exists rather than what it can call, and that it should load everything it expects to need for a subtask in one search.
When to turn it off
Troubleshooting
The model says it has no tools
The model says it has no tools
It has
tool_search and needs to use it. Check that the system prompt notice survived — if you passed your own system_prompt, swarms appends the notice, but a prompt that insists “you have exactly these tools” fights it.tools in catalog: 0
tools in catalog: 0
The server was unreachable and the agent carried on without those tools by design. Check the URL and any credential; run with
verbose=True to see the fetch error.cannot import name 'streamablehttp_client'
cannot import name 'streamablehttp_client'
mcp 2.x renamed it. Pin the 1.x line: pip install 'mcp>=1.28.1,<2.0.0'.Timeouts on tools that return a lot of text
Timeouts on tools that return a lot of text
Raise
mcp_timeout on the agent. The default of 30 seconds is short for tools like read_wiki_contents.Next
- Dynamic tool usage — the same mechanism for local Python tools.
- Several servers at once — where deferral matters most.