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): preserve toolset scope across explicit context

Joshua Vallurud2f30a77fded
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_toolset_scope.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_toolset_scope.py
index 60098b1f656..1398884783e 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_toolset_scope.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_toolset_scope.py
@@ -58,6 +58,22 @@ class TestApplyToolsetScope:
assert set(op.mcp_servers or []) == {"server-a", "server-b"}
assert op.mcp_tool_permissions == toolset_perms
+ from litellm.proxy._experimental.mcp_server.mcp_server_manager import MCPServerManager
+ from litellm.proxy._experimental.mcp_server.operations import prepare_context
+
+ manager = MCPServerManager()
+ unscoped_open = await manager.operator_open_server_ids(
+ auth, allow_all_server_ids=["operator-open-outside-toolset"], submitted_server_ids=[]
+ )
+ scoped_open = await manager.operator_open_server_ids(
+ prepare_context(result).user_api_key_auth,
+ allow_all_server_ids=["operator-open-outside-toolset"],
+ submitted_server_ids=[],
+ )
+ assert unscoped_open == {"operator-open-outside-toolset"}
+ assert scoped_open == set()
+ assert auth.mcp_toolset_id is None
+
@pytest.mark.asyncio
async def test_admin_creates_object_permission_when_none(self):
"""Admin key with object_permission=None can access any toolset."""