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(mcp): stamp oauth2_flow=authorization_code when persisting a DCR client registration (#32283)

tin-berrif5ea72b1b86c
diff --git a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py
index 8d53cd889a3..0ccd7f9b2f9 100644
--- a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py
+++ b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py
@@ -772,6 +772,7 @@ async def _persist_dcr_client_registration(
data=UpdateMCPServerRequest(
server_id=mcp_server.server_id,
credentials=credentials,
+ oauth2_flow="authorization_code",
**({"token_url": mcp_server.token_url} if mcp_server.token_url else {}),
),
touched_by="mcp_oauth_dcr",
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py
index 13dbdcc7dee..8ee8f658f6e 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py
@@ -519,7 +519,12 @@ async def test_register_client_persists_dcr_client_identity():
"""A dynamic client registration (RFC 7591) must persist the issued client_id /
client_secret / token_endpoint_auth_method and the token_url onto the server row so
autonomous refresh can authenticate as the registered client. Without persistence the
- minted client_id is discarded and the refresh_token grant has no client identity."""
+ minted client_id is discarded and the refresh_token grant has no client identity.
+
+ The persist must also stamp oauth2_flow="authorization_code": only the interactive
+ flow reaches this persist, and without the stamp the row (client creds + token_url,
+ no persisted authorization_url) matches the legacy M2M inference whenever endpoint
+ discovery fails at registry build, flipping the server to client_credentials."""
try:
from fastapi import Request
@@ -597,6 +602,7 @@ async def test_register_client_persists_dcr_client_identity():
assert update_data.credentials["client_id"] == "generated-client"
assert update_data.credentials["client_secret"] == "generated-secret"
assert update_data.credentials["token_endpoint_auth_method"] == "client_secret_basic"
+ assert update_data.oauth2_flow == "authorization_code"
mock_update_server.assert_called_once()