BerriAI/litellm · critical · ImportError
MCP SDK is not installed. Please install it with: pip instal
Error message
MCP SDK is not installed. Please install it with: pip install 'litellm[proxy]'
What it means
ImportError from MCPToolRegistry.convert_tools_to_mcp_sdk_tool_type (tool_registry.py:77): the module-level `from mcp.types import Tool` failed at import time (MCPToolSDKTool is None), meaning the `mcp` SDK package is absent from the environment. LiteLLM's proxy MCP server needs that SDK to serialize local registry tools into MCP SDK Tool objects for tools/list responses.
Source
Thrown at litellm/proxy/_experimental/mcp_server/tool_registry.py:77
def unregister_tools_with_prefix(self, prefix: str) -> int:
"""Remove tools whose registered name starts with ``prefix``.
Used when an OpenAPI-backed MCP server leaves the runtime registry so
stale tool handlers cannot be invoked after eviction.
"""
if not prefix:
return 0
removed = 0
for name in list(self.tools.keys()):
if name.startswith(prefix):
del self.tools[name]
removed += 1
verbose_logger.debug("Unregistered MCP tool %s", name)
return removed
def convert_tools_to_mcp_sdk_tool_type(self, tools: list[MCPTool]) -> list["MCPToolSDKTool"]:
if MCPToolSDKTool is None:
raise ImportError("MCP SDK is not installed. Please install it with: pip install 'litellm[proxy]'")
return [
MCPToolSDKTool(
name=tool.name,
description=tool.description,
inputSchema=tool.input_schema,
)
for tool in tools
]
def load_tools_from_config(
self,
mcp_tools_config: dict[str, Any] | None = None,
config_file_path: str | None = None,
) -> None:
"""
Load and register tools from the proxy config
Args:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Install the extra: pip install 'litellm[proxy]' (or pip install mcp), then restart the proxy/process
- Pin the extra in requirements/pyproject: litellm[proxy]>=<version> so CI and images always include mcp
- Rebuild Docker images from a clean layer after adding the extra to flush stale caches
- Verify with python -c "import mcp.types" before starting the proxy
Example fix
# before pip install litellm # mcp missing -> ImportError on tools/list # after pip install 'litellm[proxy]'
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
def mcp_sdk_available() -> bool:
return importlib.util.find_spec("mcp") is not None
assert mcp_sdk_available(), "install the proxy extra: pip install 'litellm[proxy]'" Type guard
def safe_convert(registry, tools):
if getattr(registry, "_MCP_SDK_missing", False):
return None # caller decides to skip or hard-fail
return registry.convert_tools_to_mcp_sdk_tool_type(tools) Try / catch
try:
sdk_tools = registry.convert_tools_to_mcp_sdk_tool_type(tools)
except ImportError as e:
raise RuntimeError("MCP tool listing requires the mcp SDK: pip install 'litellm[proxy]'") from e Prevention
- Declare litellm[proxy] (not bare litellm) in requirements for any deployment exposing MCP
- Add a startup check: import mcp.types before serving traffic
- Rebuild images cleanly after adding extras so stale layers cannot drop mcp
When it happens
Trigger: Listing local mcp_tools via an MCP session when litellm was installed bare (pip install litellm) without the proxy extra; slim Docker images that strip optional deps; a venv built from requirements that pin only litellm; CI environments reusing a cached env created before mcp became required.
Common situations: Embedding litellm in a custom app without litellm[proxy]; upgrading litellm in an env whose mcp pin was dropped; running the proxy from a source checkout without installing extras; dependency resolver removing mcp after a conflict.
Related errors
- OpenTelemetry OTLP HTTP exporter is not available. Install `
- OpenTelemetry OTLP gRPC exporter is not available. Install `
- OpenTelemetry OTLP gRPC log exporter is not available. Insta
- OpenTelemetry OTLP gRPC metric exporter is not available. In
- OpenTelemetry OTLP gRPC metric exporter is not available. In
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/ecb0b65f502769c7.
Report an issue: GitHub.