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: dont require mcp pip for proxy (#11282)

Ishaan Jaff2f8eb1dcc312
diff --git a/litellm/proxy/_experimental/mcp_server/utils.py b/litellm/proxy/_experimental/mcp_server/utils.py
new file mode 100644
index 00000000000..bad5f060fb8
--- /dev/null
+++ b/litellm/proxy/_experimental/mcp_server/utils.py
@@ -0,0 +1,12 @@
+import importlib
+
+
+def is_mcp_available() -> bool:
+ """
+ Returns True if the MCP module is available, False otherwise
+ """
+ try:
+ importlib.import_module("mcp")
+ return True
+ except ImportError:
+ return False
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index 633e6d086f4..c54d3c08dc9 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -2786,6 +2786,14 @@ class ProxyConfig:
)
async def _init_mcp_servers_in_db(self):
+ from litellm.proxy._experimental.mcp_server.utils import is_mcp_available
+
+ if not is_mcp_available():
+ verbose_proxy_logger.debug(
+ "MCP module not available, skipping MCP server initialization"
+ )
+ return
+
from litellm.proxy._experimental.mcp_server.mcp_server_manager import (
global_mcp_server_manager,
)