fix: load MCP tools even when agent's tools is None#4615
Open
Anandesh-Sharma wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix: load MCP tools even when agent's tools is None#4615Anandesh-Sharma wants to merge 1 commit intocrewAIInc:mainfrom
Anandesh-Sharma wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
…rm tools (crewAIInc#4568) When an agent has `mcps` configured but `self.tools` is `None`, MCP tools were silently dropped because of the `self.tools is not None` guard. Initialize `self.tools` to an empty list when it is `None` before extending, so that MCP (and platform) tools are always loaded. The same defensive fix is applied to the `platform_tools` code path which had the identical bug pattern. Closes crewAIInc#4568 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
self.toolsisNoneon an agentself.toolsto an empty list before extending with MCP/platform toolsplatform_toolscode path which had the identical bug patterntoolsisNoneCloses #4568
Changes
In
lib/crewai/src/crewai/agent/core.py, the_prepare_kickoffmethod had:When a user creates an Agent with
mcpsbut doesn't explicitly passtools(ortoolsends up asNone), this condition fails silently and MCP tools never get added. The fix initializesself.tools = []when it isNonebefore calling.extend().Test plan
test_agent_mcp_tools_loaded_when_tools_is_nonethat verifies MCP tools are loaded whenself.toolsisNonetest_lite_agent.pycontinue to pass🤖 Generated with Claude Code
Note
Low Risk
Low risk, targeted defensive change in kickoff tool preparation plus a regression test; main impact is tool list initialization where
toolswas unexpectedlyNone.Overview
Ensures
_prepare_kickoffno longer silently skips adding platform or MCP tools whenAgent.toolsisNoneby initializing it to an empty list before extending.Adds a regression test (
test_agent_mcp_tools_loaded_when_tools_is_none) to verify MCP tools are appended andtoolsbecomes non-Nonein this scenario.Written by Cursor Bugbot for commit 0d7c896. This will update automatically on new commits. Configure here.