Crewai mcpadapter creating issues

Hey all,
I have a local mcp which have bunch of tools (converted from custom crewai to mcp tools) which uses external api’s. Working fine on individual execution.

I have tasks and agents (5 each) which together creates a coding workflow.
Before when the tools were crewai custom tools the workflow/crew was working properly.

Now that i have converted the tool to mcp tools and am serving them through my mcp locally ‘stdio’ the crew hallucinates a lot and the failure rate is almost 80%.

What it does now after mcp integration,

  • loads the tools correctly.
  • hallucinates and gives wrong outputs or creates output based on tasks not using tools.
  • dosen’t use tools even though explictly prompted in the tasks and agents prompts.

What I have tried.

  • Cleaned the prompts. Make it directive.
  • give proper names and descriptions to mcp tools.
  • explicitly called tools in the tasks and agents prompt.
  • Tested tools and mcp with claude, no issues with them.

I run the agent using two crews the first crew has 3 agents and the latter two. Tools are equal no in both crews. Both crew fails and gives hallucinated outputs and not from tools. Sometimes invoke tools , sometimes doesn’t.
Why is this happening and how can i resolve it?

Can you share your code?

HI @tonykipkemboi thanks a lot for replying.

The code is too large to share.

some context on code :

  • I am using enter() and exit() from MCPServerAdapter to start the mcp as my code is very modular with tasks and agents in different modules so with context manager was not working properly.

  • mcp is starting after increasing timeout to 60 sec.

  • Tools are loaded properly in agents.

  • Proper context passing is happening in b/w tasks.

  • mcp is tested with claude and is working.

  • Tasks are wrapped under function with agent as arguments which are then imported.

  • Agents are wrapped under build_agents() function to provide mcp tools.

  • both agents and tasks are then imported in main file which are then passed to the crew for execution.

when i run the same setup with 2 agents it working but as I increase the number of agents it begins to fail. Currenlty number of agents is 5.