From a9d3c495728323b576cc6d33415cbd702b6e7b94 Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Thu, 19 Feb 2026 02:09:11 -0300 Subject: [PATCH] fix(tests): update MCP tests broken by user permissions commit (#21462) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four tests were broken by commit e00c181f0c (Mcp user permissions #21462): 1. test_list_tools_single_server_unprefixed_names: The commit changed _get_tools_from_mcp_servers to always add server prefixes (add_prefix=True), removing the conditional that skipped prefixing for single servers. Updated assertion from "toolA" → "zapier-toolA". 2. test_mcp_get_prompt_success: mcp_get_prompt now extracts the server name from a prefixed prompt name via split_server_prefix_from_name(). Passing unprefixed "hello" returns server_name="" which matches no server → 403. Updated call to use "server_a-hello" so the server lookup succeeds. 3. test_e2e_jwt_team_mcp_permissions_enforced & 4. test_e2e_jwt_team_mcp_key_intersection: The commit replaced `from typing import List` with `from litellm.proxy.proxy_server import general_settings` in MCPRequestHandler.get_allowed_mcp_servers(). Both tests mock litellm.proxy.proxy_server with a types.ModuleType that lacked general_settings, causing ImportError. Added general_settings={} to both mock modules. Co-Authored-By: Claude Sonnet 4.6 --- .../_experimental/mcp_server/test_jwt_mcp_enforcement.py | 2 ++ .../proxy/_experimental/mcp_server/test_mcp_server.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) 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