BerriAI/litellm · error · ImportError

streamable_http_client is not available. Please install mcp

Error message

streamable_http_client is not available. Please install mcp with HTTP support.

What it means

At import time LiteLLM tries to load mcp.client.streamable_http.streamable_http_client; the module is optional in the `mcp` package. If the installed mcp version lacks the streamable HTTP client (or it is not exported), streamable_http_client stays None and the default HTTP transport path raises ImportError when the client tries to use it.

Source

Thrown at litellm/experimental_mcp_client/client.py:290

                args=self.stdio_config.get("args", []),
                env=self._get_safe_stdio_env(self.stdio_config.get("env")),
            )
            return stdio_client(server_params), None
        if self.transport_type == MCPTransport.sse:
            headers = self._get_auth_headers()
            httpx_client_factory = self._create_httpx_client_factory()
            return (
                sse_client(
                    url=self.server_url,
                    timeout=self.timeout,
                    headers=headers,
                    httpx_client_factory=httpx_client_factory,
                ),
                None,
            )
        # HTTP transport (default)
        if streamable_http_client is None:
            raise ImportError("streamable_http_client is not available. Please install mcp with HTTP support.")
        headers = self._get_auth_headers()
        httpx_client_factory = self._create_httpx_client_factory()
        verbose_logger.debug("litellm headers for streamable_http_client: %s", headers)
        http_client = httpx_client_factory(
            headers=headers,
            timeout=httpx.Timeout(self.timeout),
        )
        transport_ctx: Final = streamable_http_client(
            url=self.server_url,
            http_client=http_client,
        )
        return transport_ctx, http_client

    def _get_safe_stdio_env(self, provided_env: dict[str, str] | None) -> dict[str, str] | None:
        """
        Return a safe environment for the stdio subprocess.

        If provided_env is set, we use it as-is.

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Upgrade the mcp SDK: pip install -U mcp (streamable HTTP client ships with current versions)
  2. Verify in the runtime env: python -c "from mcp.client.streamable_http import streamable_http_client; print(streamable_http_client)"
  3. If you specifically need server-sent events instead, set transport_type='sse' — the sse_client import is mandatory and already worked
  4. Regenerate lockfiles/requirements so litellm's mcp dependency resolves to a version with HTTP support

Example fix

# before
pip install 'mcp==1.7.0'   # ImportError at connect time

# after
pip install -U 'mcp>=1.8'
Defensive patterns

Strategy: validation

Validate before calling

def mcp_http_supported() -> bool:
    try:
        from mcp.client.streamable_http import streamable_http_client  # noqa: F401
        return True
    except Exception:
        return False

if server.transport_type == "http" and not mcp_http_supported():
    raise RuntimeError("upgrade mcp: pip install -U mcp")

Prevention

When it happens

Trigger: transport_type='http' (the default) with an old mcp install (pre-streamable-http, roughly <1.8), an mcp build installed without HTTP extras, or a version where the attribute name differs so getattr returns None.

Common situations: Long-lived venvs that installed mcp early and were never upgraded; lockfiles pinning mcp to an old version; minimal installs that pulled only the stdio subset of the SDK.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/2af17933cadbdc72. Report an issue: GitHub.