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.
Dynamic tool loading is off by default:
dynamic_tools defaults to False, so every schema is sent on every request until you turn it on. This page shows how to turn it on, see it working, and when to leave 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
Inspect the catalog
Building the LLM is what pulls the server’s tools into the catalog. The agent already did that when it was constructed; rebuilding it is harmless and makes the step explicit: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 leave 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'
Your
swarms predates mcp 2.x support, which renamed that function. Upgrade with pip install -U swarms; 15.0.1 and later work with both mcp 1.x and 2.x.Timeouts on slow tools
Timeouts on slow tools
A single tool call may run for
tool_timeout seconds, 120 by default. Raise it with mcp_config=MCPConnection(url=MCP_SERVER, tool_timeout=300). mcp_timeout only bounds connecting and sending requests.Next
- Dynamic tool usage — the same mechanism for local Python tools.
- Several servers at once — where deferral matters most.