From b2747211c84092056b8acf4183e34d642ec7680c Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Sat, 11 Oct 2025 09:53:25 -0700 Subject: [PATCH] test install on python 3.8 --- .../_experimental/mcp_server/tool_registry.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/litellm/proxy/_experimental/mcp_server/tool_registry.py b/litellm/proxy/_experimental/mcp_server/tool_registry.py index bc69095fc43..58570aafadf 100644 --- a/litellm/proxy/_experimental/mcp_server/tool_registry.py +++ b/litellm/proxy/_experimental/mcp_server/tool_registry.py @@ -1,12 +1,18 @@ import json -from typing import Any, Callable, Dict, List, Optional - -from mcp.types import Tool as MCPToolSDKTool +from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional from litellm._logging import verbose_logger from litellm.proxy.types_utils.utils import get_instance_fn from litellm.types.mcp_server.tool_registry import MCPTool +if TYPE_CHECKING: + from mcp.types import Tool as MCPToolSDKTool +else: + try: + from mcp.types import Tool as MCPToolSDKTool + except ImportError: + MCPToolSDKTool = None # type: ignore + class MCPToolRegistry: """ @@ -55,7 +61,11 @@ class MCPToolRegistry: def convert_tools_to_mcp_sdk_tool_type( self, tools: List[MCPTool] - ) -> List[MCPToolSDKTool]: + ) -> 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,