Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix unreachable special MCP server name guard in add_mcp_server

yuneng-jiange678ddea4310
diff --git a/litellm/proxy/management_endpoints/mcp_management_endpoints.py b/litellm/proxy/management_endpoints/mcp_management_endpoints.py
index f29a721ede8..e4bb288cda9 100644
--- a/litellm/proxy/management_endpoints/mcp_management_endpoints.py
+++ b/litellm/proxy/management_endpoints/mcp_management_endpoints.py
@@ -1214,17 +1214,9 @@ if MCP_AVAILABLE:
"error": "User does not have permission to create mcp servers. You can only create mcp servers if you are a PROXY_ADMIN."
},
)
- elif payload.server_id is not None:
- # fail if the mcp server with id already exists
- mcp_server = await get_mcp_server(prisma_client, payload.server_id)
- if mcp_server is not None:
- raise HTTPException(
- status_code=status.HTTP_400_BAD_REQUEST,
- detail={
- "error": f"MCP Server with id {payload.server_id} already exists. Cannot create another."
- },
- )
- elif (
+
+ # Block reserved special server IDs
+ if (
SpecialMCPServerName.all_team_servers == payload.server_id
or SpecialMCPServerName.all_proxy_servers == payload.server_id
):
@@ -1235,6 +1227,17 @@ if MCP_AVAILABLE:
},
)
+ if payload.server_id is not None:
+ # fail if the mcp server with id already exists
+ mcp_server = await get_mcp_server(prisma_client, payload.server_id)
+ if mcp_server is not None:
+ raise HTTPException(
+ status_code=status.HTTP_400_BAD_REQUEST,
+ detail={
+ "error": f"MCP Server with id {payload.server_id} already exists. Cannot create another."
+ },
+ )
+
# TODO: audit log for create
# Admin-created servers are always active — clear any submission lifecycle