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(tests): update MCP tests broken by user permissions commit (#21462)

Julio Quinteros Proa9d3c4957283
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_jwt_mcp_enforcement.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_jwt_mcp_enforcement.py
index b4a5a8ca19b..e93638df441 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_jwt_mcp_enforcement.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_jwt_mcp_enforcement.py
@@ -184,6 +184,7 @@ async def test_e2e_jwt_team_mcp_permissions_enforced(monkeypatch):
proxy_server_module.prisma_client = MagicMock() # Mock prisma client
proxy_server_module.user_api_key_cache = DualCache()
proxy_server_module.proxy_logging_obj = MagicMock()
+ proxy_server_module.general_settings = {}
monkeypatch.setitem(sys.modules, "litellm.proxy.proxy_server", proxy_server_module)
# Team "ABC" has MCP servers assigned via object_permission
@@ -389,6 +390,7 @@ async def test_e2e_jwt_team_mcp_key_intersection(monkeypatch):
proxy_server_module.prisma_client = MagicMock()
proxy_server_module.user_api_key_cache = DualCache()
proxy_server_module.proxy_logging_obj = MagicMock()
+ proxy_server_module.general_settings = {}
monkeypatch.setitem(sys.modules, "litellm.proxy.proxy_server", proxy_server_module)
# Team MCP servers
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
index d630ba6aaa5..b5f2197407a 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
@@ -332,7 +332,7 @@ async def test_mcp_get_prompt_success():
mock_manager.get_prompt_from_server = AsyncMock(return_value=prompt_result)
result = await mcp_get_prompt(
- name="hello",
+ name="server_a-hello", # prefixed name since server prefixes are always added
arguments={"foo": "bar"},
user_api_key_auth=user_api_key_auth,
)
@@ -1006,7 +1006,7 @@ async def test_oauth2_headers_passed_to_mcp_client():
@pytest.mark.asyncio
async def test_list_tools_single_server_unprefixed_names():
- """When only one MCP server is allowed, list tools should return unprefixed names."""
+ """When only one MCP server is allowed, list tools should return prefixed names (server prefix is always added)."""
try:
from litellm.proxy._experimental.mcp_server.server import (
_get_tools_from_mcp_servers,
@@ -1063,9 +1063,9 @@ async def test_list_tools_single_server_unprefixed_names():
mcp_server_auth_headers=None,
)
- # Should be unprefixed since only one server is allowed
+ # Server prefix is always added regardless of number of allowed servers
assert len(tools) == 1
- assert tools[0].name == "toolA"
+ assert tools[0].name == "zapier-toolA"
@pytest.mark.asyncio