MCP Server Integration Issue in CrewAI (Works Fine in Cursor AI)

Hi everyone,

I have an MCP server (for plotting) running on Docker that works perfectly when used in Cursor AI.

However, when I integrate the same MCP server into CrewAI, the MCP tools don’t seem to be invoked properly.

Workflow:

  1. Run BigQuery queries based on user requests and generate results.
  2. Plot the results using the MCP server (charts).
  3. Aggregate the results and produce the final response.

The issue is that the MCP tool is not being called, even though it runs fine in Cursor AI with Docker running in the background.

Here’s the relevant section from crew.py:

import sys
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from crewai.tasks.task_output import TaskOutput
import os
from crewai import LLM
from crewai.tools import tool
from langchain_google_community import BigQueryLoader
from crewai_tools import CodeInterpreterTool
from crewai_tools import DirectoryReadTool
from dotenv import load_dotenv
from google.cloud import storage
from datetime import timedelta, datetime
from pathlib import Path
from typing import Optional
from pydantic import BaseModel
from crewai_tools import MCPServerAdapter
from mcp import StdioServerParameters

sys.path.append(str(Path(file).resolve().parent.parent.parent))

from src.models.chat_models import AnalyticsResponse

load_dotenv()

code_interpreter = CodeInterpreterTool(unsafe_mode=True)

llm = LLM()

code_interpreter = CodeInterpreterTool(unsafe_mode=True)

directory_tool = DirectoryReadTool(directory=‘’)

@tool(“Big Query Execution”)
def my_simple_tool(query: str) → str:
“”“Tool for executing queries on Big Query.”“”
BASE_QUERY = query
loader = BigQueryLoader(BASE_QUERY)
data = loader.load()
return data

@CrewBase
class CisInsights():
“”“CisInsights crew”“”

    # MCP Server configuration as per CrewAI documentation
    mcp_server_params = [
        {
            "url": "http://localhost:1122/sse", # Replace with your actual SSE server URL
            "transport": "sse" 
        }
    ]
    with MCPServerAdapter(server_params) as tools:
        print(f"Available tools from SSE MCP server: {[tool.name for tool in tools]}")

    agents_config = 'config/agents.yaml'
    tasks_config = 'config/tasks.yaml'
    
    @agent
    def retrieval_agent(self) -> Agent:
            return Agent(
                    config=self.agents_config['retrieval_agent'],
                    tools = [my_simple_tool]
                    verbose=True,
                    llm = llm,
                    memory=False,
                    max_iter=5
            )

    
    @agent
    def analysis_agent(self) -> Agent:
            return Agent(
                    config=self.agents_config['analysis_agent'],
                    verbose=True,
                    llm = llm,
                    tools=self.get_mcp_tools()
                    max_iter=5,
                    memory=False
            )


    @agent
    def report_aggregation(self) -> Agent:
          return Agent(
					config=self.agents_config['report_aggregation'],
					verbose=True,
					llm = llm,
					max_iter=5,
                                            memory=False
			)		


    @task
    def retrieval_task(self) -> Task:
            return Task(
                    config=self.tasks_config['retrieval_task'],
            )



    @task
    def analysis_task(self) -> Task:
            return Task(
                    config=self.tasks_config['analysis_task'],
            )
  

    @task
    def report_aggregation_task(self) -> Task:
           return Task(
		config=self.tasks_config['report_aggregation_task'],
                    output_json=AnalyticsResponse,
		)

    @crew
    def crew(self) -> Crew:
            """Creates the CisInsights crew"""

            return Crew(
                    agents=self.agents, # Automatically created by the @agent decorator
                    tasks=self.tasks, # Automatically created by the @task decorator
                    process=Process.sequential,
                    verbose=True,
                    planning=False,
                    chat_llm=llm

            )

This is how it runs on Cursor AI.

Any guidance or suggestions on resolving this would be greatly appreciated.

Thanks in advance!

Have you looked at Tony’s video? It looks like how the agent is trying to call the tool might be incorrect?

From the docs:

MCP Servers as Tools in CrewAI - CrewAI

Hi ,

Yes I had referred that video and coded along the similar lines.

Any suggestions to the above?

Best,
Manjunath

Maybe something like:

  1. Remove the with MCPServerAdapter(...) section entirely
  2. In your agents, call self.get_mcp_tools(). CrewAI will auto-manage the adapter lifecycle for you.

Hi,

How do we define MCP SSE server if the adapter is removed?

We need the server adapter as per the docs that you had shared earlier.

Best,
Manju