Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix MCP client

Ishaan Jaffer36dfa0f2ee42
diff --git a/litellm/experimental_mcp_client/client.py b/litellm/experimental_mcp_client/client.py
index e2de3cd5021..3e8f9bc337b 100644
--- a/litellm/experimental_mcp_client/client.py
+++ b/litellm/experimental_mcp_client/client.py
@@ -11,10 +11,12 @@ from mcp import ClientSession, ReadResourceResult, Resource, StdioServerParamete
from mcp.client.sse import sse_client
from mcp.client.stdio import stdio_client
+streamable_http_client: Optional[Any] = None
try:
- from mcp.client.streamable_http import streamable_http_client # type: ignore
+ import mcp.client.streamable_http as streamable_http_module # type: ignore
+ streamable_http_client = getattr(streamable_http_module, "streamable_http_client", None)
except ImportError:
- streamable_http_client = None
+ pass
from mcp.types import CallToolRequestParams as MCPCallToolRequestParams
from mcp.types import CallToolResult as MCPCallToolResult
from mcp.types import (
@@ -111,6 +113,12 @@ class MCPClient:
), 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(