mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-02 01:28:38 +00:00
* test(e2e): add enum values, auto-discovering label gates and secret hiding for e2e metadata * test(e2e): tag router, batches and mcp tests with Subject metadata and record client steps * test(e2e): leave the batches cleanup harness unit tests untagged * docs(e2e): name every markerless harness test file that carries no Subject * test(e2e): keep the step discovery comprehensions to one for clause * test(e2e): name every driven model on the vllm batch, prompt caching and complexity router subjects
61 lines
2.3 KiB
Python
61 lines
2.3 KiB
Python
"""Live e2e: MCP tool selection via access group at key creation.
|
|
|
|
An admin registers the Datadog remote MCP server tagged with a server-side
|
|
access group (`mcp_access_groups`). A key minted with that access group
|
|
(`object_permission.mcp_access_groups`) sees the server's tools; a key minted
|
|
with a different group does not. This exercises access-group-scoped tool
|
|
selection, the enterprise MCP surface where keys are granted tool access groups
|
|
rather than explicit server ids.
|
|
|
|
A tools/list that leaks the server across the access-group boundary fails hard.
|
|
Requires DD_API_KEY + DD_APP_KEY (the suite's real MCP upstream).
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from datadog_mcp import SEARCH_LOGS_TOOL, register_datadog_mcp
|
|
from e2e_config import unique_marker
|
|
from e2e_http import unwrap
|
|
from e2e_metadata import Domain, Route, Subject, meta
|
|
from lifecycle import ResourceManager
|
|
from mcp_client import McpClient
|
|
|
|
pytestmark = pytest.mark.e2e
|
|
|
|
|
|
class TestMcpAccessGroupToolSelection:
|
|
@pytest.mark.covers("mcp.list_tools.api_key.access_group_scoped")
|
|
@meta(
|
|
Subject(
|
|
domain=Domain.MCP,
|
|
route=Route.MCP,
|
|
)
|
|
)
|
|
def test_access_group_scopes_tool_selection(
|
|
self, client: McpClient, resources: ResourceManager
|
|
) -> None:
|
|
group = f"e2e-mcp-grp-{unique_marker()}"
|
|
server_id = register_datadog_mcp(client, resources, mcp_access_groups=[group])
|
|
client.await_registered(server_id)
|
|
|
|
granted = client.generate_key(
|
|
user_id=f"e2e-mcp-ag-granted-{unique_marker()}",
|
|
mcp_servers=None,
|
|
mcp_access_groups=[group],
|
|
)
|
|
resources.defer(lambda: client.proxy.delete_key(granted))
|
|
|
|
other = client.generate_key(
|
|
user_id=f"e2e-mcp-ag-other-{unique_marker()}",
|
|
mcp_servers=None,
|
|
mcp_access_groups=[f"e2e-mcp-grp-absent-{unique_marker()}"],
|
|
)
|
|
resources.defer(lambda: client.proxy.delete_key(other))
|
|
|
|
_ = client.await_tool(granted, server_id, SEARCH_LOGS_TOOL)
|
|
|
|
other_tools = unwrap(client.list_tools(other)).tool_names_for_server(server_id)
|
|
assert other_tools == frozenset(), (
|
|
f"key with a different access group saw the server's tools; access-group tool "
|
|
f"selection leaked across the boundary: {other_tools}"
|
|
)
|