Files
crewAI/lib
Devin AI 50d2e4c1b0 fix: inject MCP tools during delegation (fixes #4571)
When an agent with MCP servers configured is used as a sub-agent via
delegation, its MCP tools were not loaded because the Crew's
_prepare_tools() is not called for the delegated-to agent.

This fix adds _inject_mcp_tools() to agent/utils.py and calls it from
prepare_tools(), which is invoked by both execute_task() and
aexecute_task(). MCP tools are now loaded on-demand when the agent has
mcps configured, with deduplication and graceful error handling.

Also adds 11 tests covering:
- MCP tool injection with/without mcps
- Deduplication of existing tools
- Graceful failure handling
- prepare_tools integration
- Full delegation flow

Co-Authored-By: João <joao@crewai.com>
2026-02-23 15:49:58 +00:00
..