From 31f8c56cb7f4db3ba1835a89075c67850b2da00c Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 21 May 2026 03:38:27 +0000 Subject: [PATCH] fix(mcp,tests): assert cold-start helper directly for aggregate /mcp Threading client_ip into _target_servers_delegate_auth_to_upstream made get_mcp_server_by_name(name, client_ip=...) also fire from the delegate-auth check, so the call_args_list assertion on client_ip-in-kwargs no longer uniquely signals a cold-start lookup. Patch _is_mcp_passthrough_cold_start and assert it is not invoked, which is the actual contract the test is pinning. --- .../mcp_server/auth/test_user_api_key_auth_mcp.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py b/tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py index 241ff89b7e6..ebc37b7a0b5 100644 --- a/tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py +++ b/tests/test_litellm/proxy/_experimental/mcp_server/auth/test_user_api_key_auth_mcp.py @@ -910,6 +910,9 @@ class TestMCPPassthroughColdStartAdmission: patch( "litellm.proxy._experimental.mcp_server.mcp_server_manager.global_mcp_server_manager" ) as mock_mgr, + patch( + "litellm.proxy._experimental.mcp_server.auth.user_api_key_auth_mcp._is_mcp_passthrough_cold_start" + ) as mock_cold_start, ): mock_mgr.get_mcp_server_by_name.return_value = ( TestMCPPassthroughColdStartAdmission._make_passthrough_server() @@ -918,13 +921,10 @@ class TestMCPPassthroughColdStartAdmission: await MCPRequestHandler.process_mcp_request(scope) assert exc_info.value.status_code == 401 - # Cold-start lookup (signaled by the ``client_ip`` kwarg) must not - # fire for the aggregate ``/mcp`` route — only path-targeted - # routes are eligible for OAuth discovery admission. - assert not any( - "client_ip" in c.kwargs - for c in mock_mgr.get_mcp_server_by_name.call_args_list - ) + # Cold-start admission must not fire for the aggregate ``/mcp`` + # route — only path-targeted routes are eligible for OAuth + # discovery admission. + mock_cold_start.assert_not_called() async def test_cold_start_rejects_server_specific_authorization_header(self): from fastapi import HTTPException