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:
- Run BigQuery queries based on user requests and generate results.
- Plot the results using the MCP server (charts).
- 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!

