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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(mcp): skip prefix lookup when a server has no listed tools
yuchengd5b8effa99a1
diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.pyindex 793419e2270..872b1fb5262 100644--- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py+++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py@@ -5139,7 +5139,9 @@ class MCPServerManager:return prefixed_toolsdef get_listed_tool(self, server: MCPServer, name: str) -> MCPTool | None:- listed: Final = self._listed_tools_by_server_id.get(server.server_id, {})+ listed: Final = self._listed_tools_by_server_id.get(server.server_id)+ if not listed:+ return Nonereturn listed.get(name) or listed.get(strip_known_server_prefix(name, server))def _create_prefixed_prompts(diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_guardrail_usage_monitor.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_guardrail_usage_monitor.pyindex 24e6d2de10d..956f87f0da1 100644--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_guardrail_usage_monitor.py+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_guardrail_usage_monitor.py@@ -48,6 +48,7 @@ def _bare_manager() -> MOD.MCPServerManager:reaches the guardrail hooks; they have their own coverage elsewhere."""mgr = MOD.MCPServerManager.__new__(MOD.MCPServerManager)+ mgr._listed_tools_by_server_id = {}mgr.check_allowed_or_banned_tools = lambda name, server: Truemgr.validate_allowed_params = lambda tool_name, arguments, server: None