diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py index 9eb44f5597..df9ae0ea57 100644 --- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py +++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py @@ -8,17 +8,11 @@ This is a Proxy import asyncio import json -from typing import TYPE_CHECKING, Any, Dict, List, Optional +from typing import Any, Dict, List, Optional -if TYPE_CHECKING: - from mcp import ClientSession - from mcp.client.sse import sse_client - from mcp.types import Tool as MCPTool -else: - # Provide fallback types for runtime incase `mcp` is not installed - ClientSession = None - MCPTool = object - sse_client = None +from mcp import ClientSession +from mcp.client.sse import sse_client +from mcp.types import Tool as MCPTool from litellm._logging import verbose_logger from litellm.types.mcp_server.mcp_server_manager import MCPInfo, MCPSSEServer diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.py index 510bd6ab3b..603370711f 100644 --- a/litellm/proxy/_experimental/mcp_server/server.py +++ b/litellm/proxy/_experimental/mcp_server/server.py @@ -265,7 +265,7 @@ if MCP_AVAILABLE: ) ) except Exception as e: - verbose_logger.error(f"Error getting tools from {server.name}: {e}") + verbose_logger.exception(f"Error getting tools from {server.name}: {e}") continue return list_tools_result diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 1a469d2c27..99d665d94c 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -127,9 +127,6 @@ from litellm.litellm_core_utils.core_helpers import ( from litellm.litellm_core_utils.credential_accessor import CredentialAccessor from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler -from litellm.proxy._experimental.mcp_server.mcp_server_manager import ( - global_mcp_server_manager, -) from litellm.proxy._experimental.mcp_server.server import router as mcp_router from litellm.proxy._experimental.mcp_server.tool_registry import ( global_mcp_tool_registry, @@ -1966,6 +1963,10 @@ class ProxyConfig: mcp_servers_config = config.get("mcp_servers", None) if mcp_servers_config: + from litellm.proxy._experimental.mcp_server.mcp_server_manager import ( + global_mcp_server_manager, + ) + global_mcp_server_manager.load_servers_from_config(mcp_servers_config) ## CREDENTIALS