crewAIInc/crewAI · error · ImportError
`mcp` package not found, please run `uv add crewai-tools[mcp
Error message
`mcp` package not found, please run `uv add crewai-tools[mcp]`
What it means
ImportError raised when mcp is not installed and the user declined the interactive install prompt. It is the explicit, expected 'missing dependency' signal for the MCP server adapter and tells you the exact command to fix it (uv add crewai-tools[mcp]).
Source
Thrown at lib/crewai-tools/src/crewai_tools/adapters/mcp_adapter.py:173
self._tool_names = (
[sanitize_tool_name(name) for name in tool_names] if tool_names else None
)
if not MCP_AVAILABLE:
import click
if click.confirm(
"You are missing the 'mcp' package. Would you like to install it?"
):
import subprocess
try:
subprocess.run(["uv", "add", "mcp crewai-tools'[mcp]'"], check=True) # noqa: S607
except subprocess.CalledProcessError as e:
raise ImportError("Failed to install mcp package") from e
else:
raise ImportError(
"`mcp` package not found, please run `uv add crewai-tools[mcp]`"
)
try:
self._serverparams = serverparams
self._adapter = MCPAdapt(
self._serverparams, CrewAIToolAdapter(), connect_timeout
)
self.start()
except Exception as e:
if self._adapter is not None:
try:
self.stop()
except Exception as stop_e:
logger.error(f"Error during stop cleanup: {stop_e}")
raise RuntimeError(f"Failed to initialize MCP Adapter: {e}") from e
View on GitHub (pinned to 754d7323be)
Solutions
- Install the extra: uv add 'crewai-tools[mcp]' (or pip install 'crewai-tools[mcp]').
- Add crewai-tools[mcp] to requirements/pyproject so environments are provisioned correctly from the start.
- For non-interactive deployments, always pre-install — never rely on the runtime prompt.
Example fix
# before MCPServerAdapter(serverparams) # prompt declined -> ImportError # after # uv add 'crewai-tools[mcp]' MCPServerAdapter(serverparams=...)
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec("mcp") is None:
raise RuntimeError("dependency missing: uv add 'crewai-tools[mcp]' or pip install 'crewai-tools[mcp]'") Try / catch
try:
MCPServerAdapter(serverparams=...)
except ImportError as e:
if "mcp` package not found" in str(e):
subprocess.check_call(["uv", "add", "crewai-tools[mcp]"])
raise Prevention
- Add the [mcp] extra to the environment manifest so construction never prompts.
- Run services non-interactively with all dependencies preinstalled.
- Catch ImportError around MCPServerAdapter construction and surface the install hint to operators.
When it happens
Trigger: Constructing MCPServerAdapter(serverparams) with MCP_AVAILABLE=False and answering 'no' (or running non-interactively where confirm defaults to no) to the click.confirm prompt.
Common situations: CI/non-interactive runs where click.confirm aborts or auto-declines; team members who skipped the mcp extra; Docker images built without the extra.
Related errors
- Failed to install mcp package
- async is not supported by the CrewAI framework.
- Failed to initialize MCP Adapter: {e}
- MCP server not started, run `mcp_server.start()` first befor
- The 'linkup-sdk' package is required to use the LinkupSearch
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/fa5d52d5e99aef43.
Report an issue: GitHub.