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): share _UPSTREAM_OAUTH_DISCOVERY_AUTH_TYPES in the relay gate and tools preview
Tind4e02ac04756
diff --git a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.pyindex 7606deac241..4fd47a97066 100644--- a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py+++ b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py@@ -473,7 +473,11 @@ def _raise_if_not_oauth2(mcp_server: MCPServer) -> None:token is upstream-audienced and held by the caller; the gateway persists nothing for thesemodes (DCR persistence is opt-in and never enabled on this path)."""- if mcp_server.auth_type in (MCPAuth.oauth2, MCPAuth.true_passthrough, MCPAuth.oauth_delegate):+ from litellm.proxy._experimental.mcp_server.mcp_server_manager import ( # noqa: PLC0415 # circular import with mcp_server_manager at module load+ _UPSTREAM_OAUTH_DISCOVERY_AUTH_TYPES,+ )++ if mcp_server.auth_type in _UPSTREAM_OAUTH_DISCOVERY_AUTH_TYPES:returnraise HTTPException(status_code=400,diff --git a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py b/litellm/proxy/_experimental/mcp_server/rest_endpoints.pyindex cae304bf73a..74f0b488d20 100644--- a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py+++ b/litellm/proxy/_experimental/mcp_server/rest_endpoints.py@@ -69,6 +69,7 @@ if MCP_AVAILABLE:from mcp.types import Tool as MCPToolfrom litellm.proxy._experimental.mcp_server.mcp_server_manager import (+ _UPSTREAM_OAUTH_DISCOVERY_AUTH_TYPES,global_mcp_server_manager,)from litellm.proxy._experimental.mcp_server.oauth_utils import (@@ -1325,11 +1326,9 @@ if MCP_AVAILABLE:# when the primary x-litellm-api-key header is absent, the Authorization value is the# caller's LiteLLM key, not an upstream token, and must never be forwarded upstream.oauth2_headers: Optional[Dict[str, str]] = None- if new_mcp_server_request.auth_type in {- MCPAuth.oauth2,- MCPAuth.true_passthrough,- MCPAuth.oauth_delegate,- } and headers.get(MCPRequestHandler.LITELLM_API_KEY_HEADER_NAME_PRIMARY):+ if new_mcp_server_request.auth_type in _UPSTREAM_OAUTH_DISCOVERY_AUTH_TYPES and headers.get(+ MCPRequestHandler.LITELLM_API_KEY_HEADER_NAME_PRIMARY+ ):oauth2_headers = MCPRequestHandler._get_oauth2_headers_from_headers(headers)async def _list_tools_operation(client):