mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-12 22:12:37 +00:00
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>