{"record":{"id":"ecb0b65f502769c7","repo":"BerriAI/litellm","slug":"mcp-sdk-is-not-installed-please-install-it-with","errorCode":null,"errorMessage":"MCP SDK is not installed. Please install it with: pip install 'litellm[proxy]'","messagePattern":"MCP SDK is not installed\\. Please install it with: pip install 'litellm\\[proxy\\]'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"litellm/proxy/_experimental/mcp_server/tool_registry.py","lineNumber":77,"sourceCode":"    def unregister_tools_with_prefix(self, prefix: str) -> int:\n        \"\"\"Remove tools whose registered name starts with ``prefix``.\n\n        Used when an OpenAPI-backed MCP server leaves the runtime registry so\n        stale tool handlers cannot be invoked after eviction.\n        \"\"\"\n        if not prefix:\n            return 0\n        removed = 0\n        for name in list(self.tools.keys()):\n            if name.startswith(prefix):\n                del self.tools[name]\n                removed += 1\n                verbose_logger.debug(\"Unregistered MCP tool %s\", name)\n        return removed\n\n    def convert_tools_to_mcp_sdk_tool_type(self, tools: list[MCPTool]) -> list[\"MCPToolSDKTool\"]:\n        if MCPToolSDKTool is None:\n            raise ImportError(\"MCP SDK is not installed. Please install it with: pip install 'litellm[proxy]'\")\n        return [\n            MCPToolSDKTool(\n                name=tool.name,\n                description=tool.description,\n                inputSchema=tool.input_schema,\n            )\n            for tool in tools\n        ]\n\n    def load_tools_from_config(\n        self,\n        mcp_tools_config: dict[str, Any] | None = None,\n        config_file_path: str | None = None,\n    ) -> None:\n        \"\"\"\n        Load and register tools from the proxy config\n\n        Args:","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/_experimental/mcp_server/tool_registry.py#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\npip install litellm  # mcp missing -> ImportError on tools/list\n\n# after\npip install 'litellm[proxy]'","handlingStrategy":"validation","validationCode":"import importlib.util\n\ndef mcp_sdk_available() -> bool:\n    return importlib.util.find_spec(\"mcp\") is not None\n\nassert mcp_sdk_available(), \"install the proxy extra: pip install 'litellm[proxy]'\"","typeGuard":"def safe_convert(registry, tools):\n    if getattr(registry, \"_MCP_SDK_missing\", False):\n        return None  # caller decides to skip or hard-fail\n    return registry.convert_tools_to_mcp_sdk_tool_type(tools)","tryCatchPattern":"try:\n    sdk_tools = registry.convert_tools_to_mcp_sdk_tool_type(tools)\nexcept ImportError as e:\n    raise RuntimeError(\"MCP tool listing requires the mcp SDK: pip install 'litellm[proxy]'\") from e","preventionTips":["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"],"tags":["mcp","import-error","missing-dependency","pip","litellm-proxy","packaging"],"backgroundTag":"missing-python-package","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}