- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.3k
Description
Description
Summary
The MCPServerAdapter class in crewai_tools attempts to prompt the user with click.confirm() when the mcp package is missing.
This breaks server environments (like FastAPI or CrewAI backend pipelines) where there is no TTY to interact with, leading to:
You are missing the 'mcp' package. Would you like to install it? [y/N]
click.exceptions.Abort
Steps to Reproduce
- 
Install crewai[tools] in a FastAPI server 
- 
Ensure mcp is not installed 
- 
Use this code in an endpoint or pipeline: 
from crewai_tools import MCPServerAdapter
with MCPServerAdapter({"url": "http://10.10.10.10:6006/sse"}) as tools:
    pass
- Observe crash in logs:
 click.exceptions.Abort
Expected behavior
In a server context, if mcp is missing:
- Raise a clean ImportError
- Do not prompt the user with click.confirm()
- Never fail silently or block server startup
Actual Behavior
- click.confirm() is called in init
- This fails in FastAPI/uvicorn since there is no TTY
- Causes click.exceptions.Abort, preventing tool loading
- Message appears: You are missing the 'mcp' package. Would you like to install it? [y/N]
Screenshots/Code snippets
FastAPI or agent pipeline snippet triggering the bug
from crewai_tools import MCPServerAdapter
def get_mcp_tools():
    try:
        server_params = {
            "url": "http://10.10.10.10:6006/sse",
            "transport": "sse"
        }
        with MCPServerAdapter(server_params) as mcp_tools:
            return list(mcp_tools)
    except Exception as e:
        print("MCP tool load error:", e)
        return []
Error thrown in logs when mcp is not installed
Operating System
Other (specify in additional context)
Python Version
3.11
crewAI Version
0.141.0
crewAI Tools Version
latest (>=0.126.0)
Virtual Environment
Venv
Evidence
Logs from FastAPI server running CrewAI with MCPServerAdapter when mcp is not installed:
You are missing the 'mcp' package. Would you like to install it? [y/N]:
2025-07-15 11:12:39,258 - webhook_receiver.py - ERROR: MCP load traceback:
Traceback (most recent call last):
File "/home/crewai/msteamuat/src/msteamuat/webhook_receiver.py", line 51, in get_mcp_tools
with MCPServerAdapter(server_params) as mcp_tools:
File "/home/crewai/msteamuat/.venv/lib/python3.11/site-packages/crewai_tools/adapters/mcp_adapter.py", line 92, in init
if click.confirm(...)
click.exceptions.Abort
Possible Solution
In crewai_tools.adapters.mcp_adapter.py, replace:
if click.confirm(...):
With:
if not MCP_AVAILABLE:
    logger.error("❌ MCP is not available. The 'mcp' package must be installed.")
    raise ImportError(
        "`mcp` package not found. Please install it inside your environment with:\n"
        "  pip install mcp crewai-tools[mcp]"
    )
Additional context
This issue affects non-interactive production environments such as:
- FastAPI apps running under uvicorn
- Dockerized CrewAI microservices
- CI/CD pipelines using agents for automation
- Serverless or scheduled jobs with no stdin
The use of click.confirm() assumes an interactive terminal (TTY), but most CrewAI users deploying agents are running in automated or headless contexts.
In these environments:
- The confirmation prompt is not visible
- There's no way to respond (no stdin)
- The process crashes with click.exceptions.Abort, and tool loading fails silently
This breaks compatibility with CrewAI’s core value: autonomous agents coordinating tasks in automated systems.
We already confirmed that:
- The mcppackage is installed
- The traceback stems directly from the interactive prompt inside MCPServerAdapter.__init__()
Replacing this prompt with a clean ImportError and a helpful log message would fully resolve the issue without breaking existing CLI workflows.
This was validated in:
- A live CrewAI pipeline on FastAPI
Operating System: Red Hat Enterprise Linux 9.5 (Plow)