diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index dc4f17c7b31..a3854a6f3c3 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -472,7 +472,7 @@ class LiteLLMRoutes(enum.Enum): mcp_inference_routes = [ "/mcp", "/mcp/", - "/mcp/{subpath}", + "/mcp/{subpath:path}", "/mcp/tools", "/mcp/tools/list", "/mcp/tools/call", diff --git a/tests/test_litellm/proxy/auth/test_route_checks.py b/tests/test_litellm/proxy/auth/test_route_checks.py index 0bfb10320f7..d5161db7f37 100644 --- a/tests/test_litellm/proxy/auth/test_route_checks.py +++ b/tests/test_litellm/proxy/auth/test_route_checks.py @@ -462,6 +462,8 @@ def test_virtual_key_llm_api_routes_rejects_mcp_multi_segment_admin_subpaths( ("/mcp", "POST"), ("/mcp/", "POST"), ("/mcp/my-server", "POST"), # matches the /mcp/{subpath} pattern + ("/mcp/my-server/", "POST"), # same server, trailing slash + ("/mcp/my-server/mcp", "POST"), # streamable-http transport sub-path ("/mcp/tools", "GET"), ("/mcp/tools/list", "POST"), ("/mcp/tools/call", "POST"),