Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions litellm/proxy/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ class LiteLLMRoutes(enum.Enum):
"/mcp/tools/call",
"/mcp-rest/tools/list",
"/mcp-rest/tools/call",
"/v1/mcp/tools",
]

# MCP server CRUD routes — control-plane. Gated by DISABLE_ADMIN_ENDPOINTS.
Expand Down
28 changes: 28 additions & 0 deletions tests/test_litellm/proxy/auth/test_route_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,34 @@ def test_virtual_key_llm_api_routes_rejects_mcp_multi_segment_admin_subpaths(
assert exc_info.value.status_code == 403


@pytest.mark.parametrize("method", ["GET", "POST"])
def test_virtual_key_llm_api_routes_allows_v1_mcp_tools(method):
"""Regression test: virtual keys with allowed_routes=["llm_api_routes"] must
be able to list MCP tools via GET /v1/mcp/tools.

The proxy already exposes `/mcp/tools/list` and `/mcp-rest/tools/list` to
llm_api_routes keys, so the equivalent `/v1/mcp/tools` discovery endpoint
must be reachable too. Unlike `/v1/mcp/server`, this path has no
management write counterpart, so it lives directly in `mcp_inference_routes`
rather than behind a method-aware carve-out.
"""
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

assert RouteChecks.is_llm_api_route(route="/v1/mcp/tools") is True

valid_token = UserAPIKeyAuth(
user_id="test_user",
allowed_routes=["llm_api_routes"],
)

result = RouteChecks.is_virtual_key_allowed_to_call_route(
route="/v1/mcp/tools",
valid_token=valid_token,
request=_mock_request(method),
)

assert result is True


def test_spend_logs_v2_classified_as_management_not_llm_api():
"""Paginated spend logs are a management/spend read route, not an LLM API."""

Expand Down
Loading