Optimize tools (MCP)
Use this guide when you want to optimize tool signatures (descriptions + parameter descriptions) separately from prompt text or agent logic.
What this covers
- Optimize MCP tool descriptions without touching prompt content.
- Keep system/assistant/user messages fixed while improving tool calling behavior.
- Target only specific tools when a server exposes many tools.
Separate from prompt or agent optimization
Tool optimization updates tool signatures. Prompt optimization updates system/user/assistant content. Agent optimization focuses on multi-step agent logic. Keep these runs separate to isolate changes.
Quickstart: tool-only optimization
Tool optimization is supported by all optimizers except FewShotBayesianOptimizer,
ParameterOptimizer, and GepaOptimizer (for now).
Tool calling + MCP formats
You can define tools in one of the supported formats. Tool optimization will normalize them to function-calling tools while preserving the original MCP config for reproducibility.
Supported formats
OpenAI MCP tool entries (local/remote)
Cursor MCP config (JSON) → tools
Cursor vs OpenAI ChatPrompt styles
ChatPrompt.tools accepts OpenAI-style MCP entries directly. Cursor configs use a different
shape (mcpServers) and must be converted first:
After normalization, both styles execute the same way during evaluation and optimization.
Mixed function + MCP tools
Target only specific tools
When a server exposes many tools, pass a dict to select the subset you want:
Tool optimization limits
To keep runs manageable, optimize_tools=True is limited by
DEFAULT_TOOL_CALL_MAX_TOOLS_TO_OPTIMIZE (default: 3). If you need more, pass a dict
to select a smaller subset of tools.
Disable tool use while optimizing tools
If you want to optimize tool descriptions without executing tools during evaluation, set
allow_tool_use=False:
What changes
- Tool descriptions are updated.
- Tool parameter descriptions are updated.
- Prompt text stays unchanged when
optimize_prompts=False.
Where the optimized tool signature is stored
The optimized tools are returned in result.prompt.tools. History entries include both the resolved tools and the original MCP config for reproducibility.
When to use tool optimization
Limitations
- Tool optimization only supports single prompts.
- Not supported in
FewShotBayesianOptimizer,ParameterOptimizer, orGepaOptimizer.
Troubleshooting
See tool-calling debug logs
Set the optimizer log level to surface tool calls:
You’ll see tool call lines like:
I get “MCP remote server missing url”
Make sure your tool entry includes server_url (OpenAI MCP format) or url (Cursor config).
Tools are not showing up
- Verify the MCP server is reachable.
- If using
allowed_tools, confirm the names match the server’s tool list. - For remote servers, confirm auth headers are correct.
Tool calls are slow or failing during evaluation
- Set
allow_tool_use=Falseto optimize descriptions without running tools. - Reduce dataset size while iterating on tool descriptions.