Skip to content

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

Open
thakoreh wants to merge 1 commit intocrewAIInc:mainfrom
thakoreh:fix-mcp-tools-none-handling
Open

fix: MCP tools not loading when tools is None#4587
thakoreh wants to merge 1 commit intocrewAIInc:mainfrom
thakoreh:fix-mcp-tools-none-handling

Conversation

@thakoreh
Copy link

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')]
)

@cursor
Copy link

cursor bot commented Feb 25, 2026

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on February 28.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@greysonlalonde greysonlalonde changed the title Fix MCP tools not loading when tools is None fix: MCP tools not loading when tools is None Feb 25, 2026
@greysonlalonde
Copy link
Contributor

Please remove the context window management logic from this pr and install pre-commit hooks

@thakoreh thakoreh force-pushed the fix-mcp-tools-none-handling branch from 0992490 to e380023 Compare February 25, 2026 22:09
@thakoreh
Copy link
Author

Thanks for the feedback @greysonlalonde!

I've cleaned up this PR:

  • Removed the context window management logic
  • Reset the branch to only include the MCP tools fix (single commit)
  • Only 1 file changed: lib/crewai/src/crewai/agent/core.py

The pre-commit hooks are already configured in the repo (.pre-commit-config.yaml). Ruff checks pass on the changed file.

Fixes crewAIInc#4568

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

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

Solution: Initialize  to an empty list when it's None and
MCP/platform tools are provided.
@thakoreh thakoreh force-pushed the fix-mcp-tools-none-handling branch from e380023 to 00bf7f8 Compare February 28, 2026 13:22
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

2 participants