Skip to content

fix: load MCP tools even when agent's tools is None#4615

Open
Anandesh-Sharma wants to merge 1 commit intocrewAIInc:mainfrom
Anandesh-Sharma:fix/mcp-tools-none-check-4568
Open

fix: load MCP tools even when agent's tools is None#4615
Anandesh-Sharma wants to merge 1 commit intocrewAIInc:mainfrom
Anandesh-Sharma:fix/mcp-tools-none-check-4568

Conversation

@Anandesh-Sharma
Copy link

@Anandesh-Sharma Anandesh-Sharma commented Feb 26, 2026

Summary

  • Fixes the bug where MCP tools are silently dropped when self.tools is None on an agent
  • Initializes self.tools to an empty list before extending with MCP/platform tools
  • Applies the same defensive fix to the platform_tools code path which had the identical bug pattern
  • Adds a regression test to verify MCP tools load correctly when tools is None

Closes #4568

Changes

In lib/crewai/src/crewai/agent/core.py, the _prepare_kickoff method had:

if mcps and self.tools is not None:
    self.tools.extend(mcps)

When a user creates an Agent with mcps but doesn't explicitly pass tools (or tools ends up as None), this condition fails silently and MCP tools never get added. The fix initializes self.tools = [] when it is None before calling .extend().

Test plan

  • Added regression test test_agent_mcp_tools_loaded_when_tools_is_none that verifies MCP tools are loaded when self.tools is None
  • All 30 existing tests in test_lite_agent.py continue 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 tools was unexpectedly None.

Overview
Ensures _prepare_kickoff no longer silently skips adding platform or MCP tools when Agent.tools is None by 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 and tools becomes non-None in this scenario.

Written by Cursor Bugbot for commit 0d7c896. This will update automatically on new commits. Configure here.

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]When I use mcps but tools is None, it will not load mcp tools

1 participant