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: set oauth2_flow when building MCPServer in _execute_with_mcp_client

joereynafeee689e878f
diff --git a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py b/litellm/proxy/_experimental/mcp_server/rest_endpoints.py
index 307caa2fbc8..298fe363425 100644
--- a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py
+++ b/litellm/proxy/_experimental/mcp_server/rest_endpoints.py
@@ -906,9 +906,11 @@ if MCP_AVAILABLE:
client_id, client_secret, scopes = _extract_credentials(request)
_oauth2_flow: Optional[Literal["client_credentials", "authorization_code"]] = (
- "client_credentials"
- if client_id and client_secret and request.token_url
- else None
+ request.oauth2_flow or (
+ "client_credentials"
+ if client_id and client_secret and request.token_url
+ else None
+ )
)
server_model = MCPServer(