crewai - ✅(Solved) Fix [BUG]When I use mcps but tools is None, it will not load mcp tools [5 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#4568Fetched 2026-04-08 00:41:13
View on GitHub
Comments
2
Participants
2
Timeline
21
Reactions
0
Author
Participants
Timeline (top)
referenced ×10cross-referenced ×7commented ×2closed ×1

when I use mcp like this

sandbox_agent = Agent(
role="…",
goal="…",
backstory="…",
mcps=[
        MCPServerHTTP(
            url="http://localhost:8022/mcp",  
        )
    ],
)

mcp will not load. I check the source code at crewai/agent/core.py ,

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

Root Cause

when I use mcp like this

sandbox_agent = Agent(
role="…",
goal="…",
backstory="…",
mcps=[
        MCPServerHTTP(
            url="http://localhost:8022/mcp",  
        )
    ],
)

mcp will not load. I check the source code at crewai/agent/core.py ,

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

Fix Action

Fixed

PR fix notes

PR #4570: Fix #4568: Initialize tools list when None before extending with MCP/platform tools

Description (problem / solution / changelog)

Summary

Fixes #4568. When an agent is created with mcps but without tools (or tools=None), MCP tools were silently dropped in _prepare_kickoff because the condition self.tools is not None failed before extend() could be called. The same issue affected platform apps tools.

The fix initializes self.tools to [] when it is None before extending, for both the MCP and platform apps code paths.

Before:

if mcps and self.tools is not None:  # silently skips when tools is None
    self.tools.extend(mcps)

After:

if mcps:
    if self.tools is None:
        self.tools = []
    self.tools.extend(mcps)

Review & Testing Checklist for Human

  • Tests duplicate inline logic rather than calling _prepare_kickoff directly — the 4 new tests replicate the conditional pattern manually instead of exercising the actual method. Consider whether an integration-level test through _prepare_kickoff is needed for stronger regression coverage.
  • Verify with a real MCP server — create an agent with only mcps=[MCPServerHTTP(url="...")] (no tools kwarg) and confirm the MCP tools are actually discovered and usable during kickoff().
  • The apps (platform tools) path has the same fix applied but no corresponding test was added.

Notes

Changed files

  • lib/crewai/src/crewai/agent/core.py (modified, +6/-2)
  • lib/crewai/tests/mcp/test_mcp_config.py (modified, +127/-0)

PR #4584: fix: load MCP tools when agent has no explicit tools

Description (problem / solution / changelog)

Problem

When an agent is configured with mcps but no explicit tools, self.tools is None. The condition on line 1702:

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

…skips extending because self.tools is not None evaluates to False. MCP tools are silently ignored.

Fixes #4568

Fix

Initialize self.tools to [] when it is None before extending with MCP tools.

Changes

  • lib/crewai/src/crewai/agent/core.py: Changed the mcps loading block to initialize self.tools = [] when None
<!-- CURSOR_SUMMARY -->

[!NOTE] Low Risk Small, localized change to tool list initialization during kickoff; low chance of side effects beyond ensuring expected tools are available.

Overview Fixes standalone agent kickoff tool loading so platform apps and MCP tools are appended even when self.tools is None.

_prepare_kickoff() now initializes self.tools to an empty list before extending, preventing silently skipped tool integration when only apps/mcps are configured.

<sup>Written by Cursor Bugbot for commit 84738fc837fb3e1e63ab6bb6cfe47a3c11cd1d21. This will update automatically on new commits. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

Changed files

  • lib/crewai/src/crewai/agent/core.py (modified, +6/-2)

PR #4587: fix: MCP tools not loading when tools is None

Description (problem / solution / changelog)

Description

Fixes #4568 - When I use mcps but tools is None, it will not load mcp tools

Problem

When using the mcps parameter without setting tools, the MCP tools were not being loaded because the code checked:

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

This means users who only want to use MCP tools (without any other tools) couldn't do so.

Solution

Initialize self.tools to an empty list when it's None and MCP/platform tools are provided:

if mcps:
    if self.tools is None:
        self.tools = []
    self.tools.extend(mcps)

Changes

  • Modified lib/crewai/src/crewai/agent/core.py to initialize self.tools = [] when None and tools need to be added

Testing

Now this works:

agent = Agent(
    role='...',
    goal='...',
    backstory='...',
    mcps=[MCPServerHTTP(url='http://localhost:8022/mcp')]
)

Changed files

  • lib/crewai/src/crewai/agent/core.py (modified, +6/-2)

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

Description (problem / solution / changelog)

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

<!-- CURSOR_SUMMARY -->

[!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.

<sup>Written by Cursor Bugbot for commit 0d7c896a96ec3487ad261fd4f30c1d9235f57732. This will update automatically on new commits. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

Changed files

  • lib/crewai/src/crewai/agent/core.py (modified, +6/-2)
  • lib/crewai/tests/agents/test_lite_agent.py (modified, +48/-0)

PR #4617: fix: initialize tools list when None before extending with MCP tools

Description (problem / solution / changelog)

Summary

  • Fixes a bug where MCP tools are not loaded when tools parameter is not explicitly passed to Agent
  • The condition self.tools is not None prevented MCP tools from being added when self.tools defaults to None
  • Initializes self.tools to an empty list before extending with MCP/platform tools

Fixes #4568

Test plan

  • Create an Agent with mcps but without tools parameter and verify MCP tools are loaded
  • Create an Agent with both mcps and tools=[] and verify both are loaded
  • Create an Agent with tools=[some_tool] and mcps and verify both are present

🤖 Generated with Claude Code

Changed files

  • lib/crewai/src/crewai/agent/core.py (modified, +6/-2)

Code Example

sandbox_agent = Agent(
role="…",
goal="…",
backstory="…",
mcps=[
        MCPServerHTTP(
            url="http://localhost:8022/mcp",  
        )
    ],
)

---

if mcps and self.tools is not None:
        self.tools.extend(mcps)
RAW_BUFFERClick to expand / collapse

Description

when I use mcp like this

sandbox_agent = Agent(
role="…",
goal="…",
backstory="…",
mcps=[
        MCPServerHTTP(
            url="http://localhost:8022/mcp",  
        )
    ],
)

mcp will not load. I check the source code at crewai/agent/core.py ,

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

Steps to Reproduce

use mcps but tools is None

Expected behavior

can just use mcps

Screenshots/Code snippets

above

Operating System

macOS Ventura

Python Version

3.10

crewAI Version

1.7.2

crewAI Tools Version

1.7.2

Virtual Environment

Venv

Evidence

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

Possible Solution

when tools is None, let it []

Additional context

no more

extent analysis

Fix Plan

To fix the issue, we need to modify the Agent class to handle the case when tools is None. We can do this by initializing tools as an empty list if it is None.

Code Changes

if mcps:
    if self.tools is None:
        self.tools = []
    self.tools.extend(mcps)

Alternatively, you can modify the __init__ method of the Agent class to initialize tools as an empty list:

def __init__(self, ...):
    ...
    self.tools = self.tools if self.tools is not None else []
    ...

Verification

To verify that the fix worked, you can create an instance of the Agent class with mcps and check if tools is populated correctly:

sandbox_agent = Agent(
    role="…",
    goal="…",
    backstory="…",
    mcps=[
        MCPServerHTTP(
            url="http://localhost:8022/mcp",  
        )
    ],
)
print(sandbox_agent.tools)  # Should print a list containing the MCP

Extra Tips

Make sure to update the crewai library to the latest version if available, as this issue might be fixed in a newer version. Additionally, you can add a check to ensure that mcps is not None before trying to extend tools.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

can just use mcps

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING