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]

test(mcp): resolve current manager in proxy fixtures

Yuneng Jiangfb21852f7bc5
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/conftest.py b/tests/test_litellm/proxy/_experimental/mcp_server/conftest.py
index 2ccba2b2055..9a66f130d24 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/conftest.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/conftest.py
@@ -2,15 +2,15 @@ import os
import pytest
-from litellm.proxy._experimental.mcp_server.mcp_server_manager import (
- global_mcp_server_manager,
-)
-
@pytest.fixture(autouse=True)
def _hermetic_mcp_server_registry():
"""Restore the singleton ``global_mcp_server_manager``'s registry state around every
test, so entries seeded by one test never leak into another on a shared shard."""
+ from litellm.proxy._experimental.mcp_server.mcp_server_manager import (
+ global_mcp_server_manager,
+ )
+
saved_registry = dict(global_mcp_server_manager.registry)
saved_config_servers = dict(global_mcp_server_manager.config_mcp_servers)
saved_tool_mapping = dict(global_mcp_server_manager.tool_name_to_mcp_server_name_mapping)
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_proxy_mode.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_proxy_mode.py
index e86fc27fed7..413785529d5 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_proxy_mode.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_proxy_mode.py
@@ -7,7 +7,6 @@ from mcp.types import CallToolResult, TextContent, Tool
from litellm.proxy._experimental.mcp_server import server
from litellm.proxy._experimental.mcp_server.faults.list_outcomes import AggregateToolListing
-from litellm.proxy._experimental.mcp_server.mcp_server_manager import global_mcp_server_manager
from litellm.proxy._experimental.mcp_server.tool_search import (
MCP_PROXY_CALL_TOOL_NAME,
MCP_PROXY_SCHEMA_TOOL_NAME,
@@ -271,6 +270,8 @@ class TestMcpProxyAuthorizationScope:
@pytest.fixture
def rig(self) -> Iterator[AsyncMock]:
+ from litellm.proxy._experimental.mcp_server.mcp_server_manager import global_mcp_server_manager
+
upstream = {
"srv-alpha": [_upstream_tool("alpha", "add"), _upstream_tool("alpha", "multiply")],
"srv-beta": [_upstream_tool("beta", "add")],