Optimize tools (MCP)
Optimize tools (MCP)
Optimize tools (MCP)
Use this guide when you want to optimize tool signatures (descriptions + parameter descriptions) separately from prompt text or agent logic.
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.
Tool optimization is supported by all optimizers except FewShotBayesianOptimizer,
ParameterOptimizer, and GepaOptimizer (for now).
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.
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.
When a server exposes many tools, pass a dict to select the subset you want:
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.
If you want to optimize tool descriptions without executing tools during evaluation, set
allow_tool_use=False:
optimize_prompts=False.The optimized tools are returned in result.prompt.tools. History entries include both the resolved tools and the original MCP config for reproducibility.
FewShotBayesianOptimizer, ParameterOptimizer, or GepaOptimizer.Set the optimizer log level to surface tool calls:
You’ll see tool call lines like:
Make sure your tool entry includes server_url (OpenAI MCP format) or url (Cursor config).
allowed_tools, confirm the names match the server’s tool list.allow_tool_use=False to optimize descriptions without running tools.