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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(mcp): hoist repeated bridge relay check and align raise detail shapes
Tin Chi Loc79dcef81218
diff --git a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.pyindex 86c2bd9cea5..f3a53c0d9d9 100644--- a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py+++ b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py@@ -539,12 +539,10 @@ def _require_s256_pkce(return code_challenge, code_challenge_methodraise HTTPException(status_code=400,- detail={- "error": (- "This server requires PKCE: send code_challenge with "- "code_challenge_method=S256 on the authorization request"- )- },+ detail=(+ "This server requires PKCE: send code_challenge with "+ "code_challenge_method=S256 on the authorization request"+ ),)@@ -701,7 +699,8 @@ async def exchange_token_with_server(status_code=400,detail="code is required for authorization_code grant",)- if _dcr_bridge_relays_client_registration(mcp_server) and not redirect_uri:+ bridge_token_relay = _dcr_bridge_relays_client_registration(mcp_server)+ if bridge_token_relay and not redirect_uri:raise HTTPException(status_code=400,detail=(@@ -710,9 +709,7 @@ async def exchange_token_with_server(),)proxy_base_url = get_request_base_url(request)- resolved_redirect_uri = (- redirect_uri if _dcr_bridge_relays_client_registration(mcp_server) else f"{proxy_base_url}/callback"- )+ resolved_redirect_uri = redirect_uri if bridge_token_relay else f"{proxy_base_url}/callback"token_data = {"grant_type": "authorization_code","code": code,