mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix(proxy): allow trailing slash and sub-paths on MCP inference routes
`/mcp/{subpath}` compiles to `^/mcp/[^/]+$`, so `/mcp/<server>/` and
`/mcp/<server>/mcp` are not recognised as LLM API routes and fall through
to the admin-only branch, producing a misleading key/user/team error.
Use the `:path` placeholder already used by `mcp_management_routes`.
Fixes #36531
This commit is contained in:
parent
b0fac57fe4
commit
6f3cf9aec9
2 changed files with 3 additions and 1 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue