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]

feat(mcp): let users select the entra_obo token_exchange profile in the UI and API (#32144)

tin-berridb2402754aac
diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260703120000_add_token_exchange_profile_to_mcp_servers/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260703120000_add_token_exchange_profile_to_mcp_servers/migration.sql
new file mode 100644
index 00000000000..6dda56c4fb3
--- /dev/null
+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260703120000_add_token_exchange_profile_to_mcp_servers/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "LiteLLM_MCPServerTable" ADD COLUMN IF NOT EXISTS "token_exchange_profile" TEXT;
diff --git a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
index 05c1e6278d6..6d87102a3f3 100644
--- a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
+++ b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma
@@ -334,6 +334,7 @@ model LiteLLM_MCPServerTable {
// RFC 8707 resource indicators are a separate concept, named "resource" in the v2 egress types.
audience String?
subject_token_type String?
+ token_exchange_profile String?
allow_all_keys Boolean @default(false)
available_on_public_internet Boolean @default(true)
delegate_auth_to_upstream Boolean @default(false)
diff --git a/litellm/models/mcp_server.py b/litellm/models/mcp_server.py
index 821486b5dbe..d9757cf80f4 100644
--- a/litellm/models/mcp_server.py
+++ b/litellm/models/mcp_server.py
@@ -91,6 +91,7 @@ class LiteLLM_MCPServerTable(LiteLLMPydanticObjectBase):
token_exchange_endpoint: Optional[str] = None
audience: Optional[str] = None
subject_token_type: Optional[str] = None
+ token_exchange_profile: Optional[str] = None
allow_all_keys: bool = False
available_on_public_internet: bool = True
delegate_auth_to_upstream: bool = False
diff --git a/litellm/proxy/_experimental/mcp_server/db.py b/litellm/proxy/_experimental/mcp_server/db.py
index baa2365cf20..10081ce19de 100644
--- a/litellm/proxy/_experimental/mcp_server/db.py
+++ b/litellm/proxy/_experimental/mcp_server/db.py
@@ -55,6 +55,7 @@ _AUTH_FLOW_SCOPED_FIELDS: frozenset = frozenset(
"token_exchange_endpoint",
"audience",
"subject_token_type",
+ "token_exchange_profile",
}
)
@@ -70,6 +71,7 @@ _TOKEN_EXCHANGE_COLUMN_FIELDS: frozenset = frozenset(
"token_exchange_endpoint",
"audience",
"subject_token_type",
+ "token_exchange_profile",
}
)
diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
index 1a69a979496..7c88c903324 100644
--- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
+++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
@@ -1358,7 +1358,8 @@ class MCPServerManager:
subject_token_type=mcp_server.subject_token_type
or (credentials_dict.get("subject_token_type") if credentials_dict else None)
or DEFAULT_SUBJECT_TOKEN_TYPE,
- token_exchange_profile=(credentials_dict.get("token_exchange_profile") if credentials_dict else None)
+ token_exchange_profile=mcp_server.token_exchange_profile
+ or (credentials_dict.get("token_exchange_profile") if credentials_dict else None)
or "rfc8693",
timeout=getattr(mcp_server, "timeout", None),
max_concurrent_requests=getattr(mcp_server, "max_concurrent_requests", None),
@@ -4641,6 +4642,7 @@ class MCPServerManager:
token_exchange_endpoint=server.token_exchange_endpoint,
audience=server.audience,
subject_token_type=server.subject_token_type,
+ token_exchange_profile=server.token_exchange_profile,
allow_all_keys=server.allow_all_keys,
instructions=server.instructions,
timeout=server.timeout,
@@ -4748,6 +4750,7 @@ class MCPServerManager:
token_exchange_endpoint=server.token_exchange_endpoint,
audience=server.audience,
subject_token_type=server.subject_token_type,
+ token_exchange_profile=server.token_exchange_profile,
allow_all_keys=server.allow_all_keys,
available_on_public_internet=server.available_on_public_internet,
delegate_auth_to_upstream=server.delegate_auth_to_upstream,
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py
index 37d7fdff86f..9e390312fa1 100644
--- a/litellm/proxy/_types.py
+++ b/litellm/proxy/_types.py
@@ -1262,6 +1262,7 @@ class NewMCPServerRequest(LiteLLMPydanticObjectBase):
token_exchange_endpoint: Optional[str] = None
audience: Optional[str] = None
subject_token_type: Optional[str] = None
+ token_exchange_profile: Optional[str] = None
allow_all_keys: bool = False
available_on_public_internet: bool = True
delegate_auth_to_upstream: bool = False
@@ -1355,6 +1356,7 @@ class UpdateMCPServerRequest(LiteLLMPydanticObjectBase):
token_exchange_endpoint: Optional[str] = None
audience: Optional[str] = None
subject_token_type: Optional[str] = None
+ token_exchange_profile: Optional[str] = None
allow_all_keys: bool = False
available_on_public_internet: bool = True
delegate_auth_to_upstream: bool = False
diff --git a/litellm/proxy/management_endpoints/mcp_management_endpoints.py b/litellm/proxy/management_endpoints/mcp_management_endpoints.py
index b01e0231c2a..a66e2fcf618 100644
--- a/litellm/proxy/management_endpoints/mcp_management_endpoints.py
+++ b/litellm/proxy/management_endpoints/mcp_management_endpoints.py
@@ -540,6 +540,7 @@ if MCP_AVAILABLE:
sanitized.token_exchange_endpoint = None
sanitized.audience = None
sanitized.subject_token_type = None
+ sanitized.token_exchange_profile = None
# Drop env vars entirely rather than only blanking global values: the
# names alone (DB_PASSWORD, GITHUB_API_KEY, ...) leak what secrets the
# admin configured. Non-admins get the per-user vars they must fill in
@@ -584,6 +585,7 @@ if MCP_AVAILABLE:
sanitized.token_exchange_endpoint = None
sanitized.audience = None
sanitized.subject_token_type = None
+ sanitized.token_exchange_profile = None
sanitized.health_check_error = None
sanitized.last_health_check = None
diff --git a/litellm/proxy/schema.prisma b/litellm/proxy/schema.prisma
index 05c1e6278d6..6d87102a3f3 100644
--- a/litellm/proxy/schema.prisma
+++ b/litellm/proxy/schema.prisma
@@ -334,6 +334,7 @@ model LiteLLM_MCPServerTable {
// RFC 8707 resource indicators are a separate concept, named "resource" in the v2 egress types.
audience String?
subject_token_type String?
+ token_exchange_profile String?
allow_all_keys Boolean @default(false)
available_on_public_internet Boolean @default(true)
delegate_auth_to_upstream Boolean @default(false)
diff --git a/litellm/types/mcp.py b/litellm/types/mcp.py
index 884a0815dcb..9c564a3c7a6 100644
--- a/litellm/types/mcp.py
+++ b/litellm/types/mcp.py
@@ -166,6 +166,10 @@ class MCPCredentials(TypedDict, total=False):
Token exchange wire dialect: "rfc8693" (default, the standard token-exchange grant) or
"entra_obo" (Microsoft Entra On-Behalf-Of, the RFC 7523 jwt-bearer grant + requested_token_use
extension). Not a secret; stored unencrypted.
+
+ Legacy input shape: lifted into the dedicated ``token_exchange_profile`` column on
+ write and stripped from the stored blob; the column is authoritative. Prefer the
+ top-level request field.
"""
diff --git a/schema.prisma b/schema.prisma
index 05c1e6278d6..6d87102a3f3 100644
--- a/schema.prisma
+++ b/schema.prisma
@@ -334,6 +334,7 @@ model LiteLLM_MCPServerTable {
// RFC 8707 resource indicators are a separate concept, named "resource" in the v2 egress types.
audience String?
subject_token_type String?
+ token_exchange_profile String?
allow_all_keys Boolean @default(false)
available_on_public_internet Boolean @default(true)
delegate_auth_to_upstream Boolean @default(false)
diff --git a/tests/mcp_tests/test_mcp_server.py b/tests/mcp_tests/test_mcp_server.py
index 103f6e0b2a6..515bf1233aa 100644
--- a/tests/mcp_tests/test_mcp_server.py
+++ b/tests/mcp_tests/test_mcp_server.py
@@ -1559,6 +1559,7 @@ async def test_add_update_server_with_alias():
mock_mcp_server.token_exchange_endpoint = None
mock_mcp_server.audience = None
mock_mcp_server.subject_token_type = None
+ mock_mcp_server.token_exchange_profile = None
# Additional fields used by build_mcp_server_from_table
mock_mcp_server.extra_headers = None
mock_mcp_server.allow_all_keys = False
@@ -1621,6 +1622,7 @@ async def test_add_update_server_without_alias():
mock_mcp_server.token_exchange_endpoint = None
mock_mcp_server.audience = None
mock_mcp_server.subject_token_type = None
+ mock_mcp_server.token_exchange_profile = None
# Additional fields used by build_mcp_server_from_table
mock_mcp_server.extra_headers = None
mock_mcp_server.allow_all_keys = False
@@ -1683,6 +1685,7 @@ async def test_add_update_server_fallback_to_server_id():
mock_mcp_server.token_exchange_endpoint = None
mock_mcp_server.audience = None
mock_mcp_server.subject_token_type = None
+ mock_mcp_server.token_exchange_profile = None
# Additional fields used by build_mcp_server_from_table - set explicitly
# to avoid MagicMock objects being passed to Pydantic MCPServer constructor
mock_mcp_server.extra_headers = None
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_db_credentials.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_db_credentials.py
index 826b7584202..8b8b8a363d5 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_db_credentials.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_db_credentials.py
@@ -740,6 +740,7 @@ def test_prepare_mcp_server_data_create_carries_token_exchange_columns():
token_exchange_endpoint="https://idp.example.com/oauth2/token",
audience="https://upstream.example.com",
subject_token_type="urn:ietf:params:oauth:token-type:jwt",
+ token_exchange_profile="entra_obo",
credentials={"client_id": "te-client", "client_secret": "te-secret"},
)
@@ -748,6 +749,7 @@ def test_prepare_mcp_server_data_create_carries_token_exchange_columns():
assert data["token_exchange_endpoint"] == "https://idp.example.com/oauth2/token"
assert data["audience"] == "https://upstream.example.com"
assert data["subject_token_type"] == "urn:ietf:params:oauth:token-type:jwt"
+ assert data["token_exchange_profile"] == "entra_obo"
def test_prepare_mcp_server_data_update_carries_token_exchange_columns():
@@ -761,6 +763,7 @@ def test_prepare_mcp_server_data_update_carries_token_exchange_columns():
token_exchange_endpoint="https://idp.example.com/oauth2/token",
audience="https://upstream.example.com",
subject_token_type="urn:ietf:params:oauth:token-type:jwt",
+ token_exchange_profile="entra_obo",
)
data = _prepare_mcp_server_data(request, exclude_unset=True)
@@ -768,3 +771,4 @@ def test_prepare_mcp_server_data_update_carries_token_exchange_columns():
assert data["token_exchange_endpoint"] == "https://idp.example.com/oauth2/token"
assert data["audience"] == "https://upstream.example.com"
assert data["subject_token_type"] == "urn:ietf:params:oauth:token-type:jwt"
+ assert data["token_exchange_profile"] == "entra_obo"
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_partial_update.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_partial_update.py
index 211be084807..d341d8f7e3b 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_partial_update.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_partial_update.py
@@ -204,6 +204,7 @@ async def test_auth_type_switch_clears_stale_flow_scoped_fields():
"token_exchange_endpoint",
"audience",
"subject_token_type",
+ "token_exchange_profile",
):
assert data_dict[stale_field] is None, f"{stale_field} must be cleared on auth_type switch"
assert data_dict["credentials"] is None
@@ -235,6 +236,7 @@ async def test_auth_type_switch_back_to_oauth2_clears_token_exchange_fields():
assert data_dict["token_exchange_endpoint"] is None
assert data_dict["audience"] is None
assert data_dict["subject_token_type"] is None
+ assert data_dict["token_exchange_profile"] is None
@pytest.mark.asyncio
@@ -257,6 +259,7 @@ async def test_unchanged_auth_type_does_not_clear_flow_fields():
"token_exchange_endpoint",
"audience",
"subject_token_type",
+ "token_exchange_profile",
):
assert flow_field not in data_dict
@@ -309,6 +312,7 @@ def _existing_row(auth_type: str, credentials: dict | None = None):
existing.token_exchange_endpoint = None
existing.audience = None
existing.subject_token_type = None
+ existing.token_exchange_profile = None
return existing
@@ -328,6 +332,7 @@ async def test_create_lifts_blob_token_exchange_settings_into_columns():
"token_exchange_endpoint": "https://idp.example.com/oauth2/token",
"audience": "api://upstream",
"subject_token_type": "urn:ietf:params:oauth:token-type:jwt",
+ "token_exchange_profile": "entra_obo",
},
)
@@ -337,8 +342,9 @@ async def test_create_lifts_blob_token_exchange_settings_into_columns():
assert data_dict["token_exchange_endpoint"] == "https://idp.example.com/oauth2/token"
assert data_dict["audience"] == "api://upstream"
assert data_dict["subject_token_type"] == "urn:ietf:params:oauth:token-type:jwt"
+ assert data_dict["token_exchange_profile"] == "entra_obo"
stored_blob = json.loads(data_dict["credentials"])
- for te_field in ("token_exchange_endpoint", "audience", "subject_token_type"):
+ for te_field in ("token_exchange_endpoint", "audience", "subject_token_type", "token_exchange_profile"):
assert te_field not in stored_blob
assert "client_id" in stored_blob
@@ -374,6 +380,7 @@ async def test_credentials_merge_migrates_legacy_blob_te_settings():
"client_id": "enc-old-cid",
"token_exchange_endpoint": "https://legacy-idp.example.com/token",
"audience": "api://legacy",
+ "token_exchange_profile": "entra_obo",
},
)
mock_prisma.db.litellm_mcpservertable.find_unique = AsyncMock(return_value=existing)
@@ -388,8 +395,9 @@ async def test_credentials_merge_migrates_legacy_blob_te_settings():
assert data_dict["token_exchange_endpoint"] == "https://legacy-idp.example.com/token"
assert data_dict["audience"] == "api://legacy"
+ assert data_dict["token_exchange_profile"] == "entra_obo"
merged_blob = json.loads(data_dict["credentials"])
- for te_field in ("token_exchange_endpoint", "audience", "subject_token_type"):
+ for te_field in ("token_exchange_endpoint", "audience", "subject_token_type", "token_exchange_profile"):
assert te_field not in merged_blob
@@ -465,6 +473,7 @@ async def test_auth_type_switch_clears_flow_fields_with_external_fields_set():
"token_exchange_endpoint",
"audience",
"subject_token_type",
+ "token_exchange_profile",
):
assert data_dict[stale_field] is None, f"{stale_field} must be cleared via the fields_set path"
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
index 290d0b0a999..b24457deabd 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
@@ -5187,6 +5187,7 @@ async def test_list_tools_with_legacy_db_m2m_server_resolves_oauth2_flow():
legacy_server.token_exchange_endpoint = None
legacy_server.audience = None
legacy_server.subject_token_type = None
+ legacy_server.token_exchange_profile = None
legacy_server.token_url = "https://oauth.example.com/token"
legacy_server.authorization_url = None
legacy_server.client_id = "client-id"
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py
index 7900f6fb04a..6fa69b2f96c 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py
@@ -1772,6 +1772,66 @@ class TestMCPServerManager:
assert isinstance(result, Error)
assert result.error.tag == "misconfigured"
+ @pytest.mark.asyncio
+ async def test_load_servers_from_config_reads_all_token_exchange_fields(self):
+ """Every token-exchange setting is configurable through config.yaml as a top-level
+ key (the config counterpart of the REST/UI columns) and reaches the resolver spec;
+ omitted keys resolve to their documented defaults. token_exchange servers need no
+ oauth2_flow (that requirement is oauth2-only)."""
+ from litellm.types.mcp import DEFAULT_SUBJECT_TOKEN_TYPE
+
+ manager = MCPServerManager()
+ config = {
+ "te_full": {
+ "url": "https://up.example.com/mcp",
+ "transport": MCPTransport.http,
+ "auth_type": MCPAuth.oauth2_token_exchange,
+ "token_exchange_endpoint": "https://idp.example.com/oauth2/token",
+ "audience": "api://upstream",
+ "subject_token_type": "urn:ietf:params:oauth:token-type:jwt",
+ "token_exchange_profile": "entra_obo",
+ "client_id": "cid",
+ "client_secret": "csec",
+ "scopes": ["api://upstream/.default"],
+ },
+ "te_minimal": {
+ "url": "https://up2.example.com/mcp",
+ "transport": MCPTransport.http,
+ "auth_type": MCPAuth.oauth2_token_exchange,
+ "token_exchange_endpoint": "https://idp2.example.com/oauth2/token",
+ "client_id": "cid2",
+ "client_secret": "csec2",
+ },
+ }
+
+ with patch.object(manager, "_descovery_metadata", new=AsyncMock(return_value=None)):
+ await manager.load_servers_from_config(config)
+
+ by_name = {s.server_name: s for s in manager.config_mcp_servers.values()}
+
+ full = by_name["te_full"]
+ assert full.token_exchange_endpoint == "https://idp.example.com/oauth2/token"
+ assert full.audience == "api://upstream"
+ assert full.subject_token_type == "urn:ietf:params:oauth:token-type:jwt"
+ assert full.token_exchange_profile == "entra_obo"
+
+ minimal = by_name["te_minimal"]
+ assert minimal.audience is None
+ assert minimal.subject_token_type == DEFAULT_SUBJECT_TOKEN_TYPE
+ assert minimal.token_exchange_profile == "rfc8693"
+
+ from litellm.proxy._experimental.mcp_server.outbound_credentials.adapter import to_server_spec
+
+ spec = to_server_spec(full)
+ assert spec is not None
+ assert spec.config.token_exchange_endpoint == "https://idp.example.com/oauth2/token"
+ assert spec.config.profile == "entra_obo"
+
+ minimal_spec = to_server_spec(minimal)
+ assert minimal_spec is not None
+ assert minimal_spec.config.subject_token_type == DEFAULT_SUBJECT_TOKEN_TYPE
+ assert minimal_spec.config.profile == "rfc8693"
+
@pytest.mark.asyncio
async def test_config_oauth_initialize_tool_name_to_mcp_server_name_mapping(self):
manager = MCPServerManager()
@@ -4482,6 +4542,81 @@ class TestMCPServerTokenExchangeColumns:
assert rebuilt_table.audience == "https://upstream.example.com"
assert rebuilt_table.subject_token_type == "urn:ietf:params:oauth:token-type:jwt"
+ @pytest.mark.asyncio
+ async def test_build_mcp_server_from_table_reads_token_exchange_profile_column(self):
+ """The profile dialect selector (rfc8693 vs entra_obo) is read from its dedicated column
+ so a server created via the REST API/UI as entra_obo resolves to the Entra dialect."""
+ manager = MCPServerManager()
+
+ table_record = LiteLLM_MCPServerTable(
+ server_id="te-profile",
+ server_name="te_profile",
+ url="https://upstream.example.com/mcp",
+ transport=MCPTransport.http,
+ auth_type=MCPAuth.oauth2_token_exchange,
+ token_exchange_endpoint="https://login.microsoftonline.com/tenant/oauth2/v2.0/token",
+ token_exchange_profile="entra_obo",
+ )
+
+ mcp_server = await manager.build_mcp_server_from_table(table_record)
+
+ assert mcp_server.token_exchange_profile == "entra_obo"
+
+ @pytest.mark.asyncio
+ async def test_build_mcp_server_from_table_token_exchange_profile_defaults_rfc8693(self):
+ """token_exchange_profile falls back to rfc8693 when neither column nor blob sets it."""
+ manager = MCPServerManager()
+
+ table_record = LiteLLM_MCPServerTable(
+ server_id="te-profile-default",
+ server_name="te_profile_default",
+ url="https://upstream.example.com/mcp",
+ transport=MCPTransport.http,
+ auth_type=MCPAuth.oauth2_token_exchange,
+ token_exchange_endpoint="https://idp.example.com/oauth2/token",
+ )
+
+ mcp_server = await manager.build_mcp_server_from_table(table_record)
+
+ assert mcp_server.token_exchange_profile == "rfc8693"
+
+ @pytest.mark.asyncio
+ async def test_build_mcp_server_from_table_token_exchange_profile_blob_fallback(self):
+ """Backwards compatibility: a server with the profile only in the credentials blob still loads."""
+ manager = MCPServerManager()
+
+ table_record = LiteLLM_MCPServerTable(
+ server_id="te-profile-blob",
+ server_name="te_profile_blob",
+ url="https://upstream.example.com/mcp",
+ transport=MCPTransport.http,
+ auth_type=MCPAuth.oauth2_token_exchange,
+ credentials={"token_exchange_profile": "entra_obo"},
+ )
+
+ mcp_server = await manager.build_mcp_server_from_table(table_record)
+
+ assert mcp_server.token_exchange_profile == "entra_obo"
+
+ @pytest.mark.asyncio
+ async def test_round_trip_token_exchange_profile_preserved(self):
+ """token_exchange_profile survives LiteLLM_MCPServerTable -> MCPServer -> LiteLLM_MCPServerTable."""
+ manager = MCPServerManager()
+
+ table_record = LiteLLM_MCPServerTable(
+ server_id="te-profile-rt",
+ server_name="te_profile_rt",
+ url="https://upstream.example.com/mcp",
+ transport=MCPTransport.http,
+ auth_type=MCPAuth.oauth2_token_exchange,
+ token_exchange_profile="entra_obo",
+ )
+
+ mcp_server = await manager.build_mcp_server_from_table(table_record)
+ rebuilt_table = manager._build_mcp_server_table(mcp_server)
+
+ assert rebuilt_table.token_exchange_profile == "entra_obo"
+
class TestInternalDelegatePkceWarningLog:
@pytest.mark.asyncio
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_sigv4_auth.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_sigv4_auth.py
index e638f66920e..f5a48b5ec34 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_sigv4_auth.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_sigv4_auth.py
@@ -859,6 +859,7 @@ class TestSigV4BuildFromTable:
table_record.token_exchange_endpoint = None
table_record.audience = None
table_record.subject_token_type = None
+ table_record.token_exchange_profile = None
table_record.instructions = None
table_record.source_url = None
@@ -921,6 +922,7 @@ class TestSigV4BuildFromTable:
table_record.token_exchange_endpoint = None
table_record.audience = None
table_record.subject_token_type = None
+ table_record.token_exchange_profile = None
table_record.instructions = None
table_record.source_url = None
diff --git a/tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py
index c56a16bc7b3..6976aa76a94 100644
--- a/tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py
+++ b/tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py
@@ -3775,6 +3775,7 @@ def test_sanitize_mcp_server_for_non_admin_clears_credential_fields():
server.token_exchange_endpoint = "https://idp/token-exchange"
server.audience = "https://upstream/api"
server.subject_token_type = "urn:ietf:params:oauth:token-type:jwt"
+ server.token_exchange_profile = "entra_obo"
sanitized = _sanitize_mcp_server_for_non_admin(server)
@@ -3795,6 +3796,7 @@ def test_sanitize_mcp_server_for_non_admin_clears_credential_fields():
assert sanitized.token_exchange_endpoint is None
assert sanitized.audience is None
assert sanitized.subject_token_type is None
+ assert sanitized.token_exchange_profile is None
# Identity / metadata fields are preserved so the UI can list the
# server without exposing secrets.
@@ -3858,6 +3860,7 @@ def test_sanitize_virtual_key_clears_token_exchange_endpoint_and_audience():
server.token_exchange_endpoint = "https://idp/token-exchange"
server.audience = "https://upstream/api"
server.subject_token_type = "urn:ietf:params:oauth:token-type:jwt"
+ server.token_exchange_profile = "entra_obo"
sanitized = mgmt._sanitize_mcp_server_for_virtual_key(server)
@@ -3865,6 +3868,7 @@ def test_sanitize_virtual_key_clears_token_exchange_endpoint_and_audience():
assert sanitized.token_exchange_endpoint is None
assert sanitized.audience is None
assert sanitized.subject_token_type is None
+ assert sanitized.token_exchange_profile is None
def _server_with_env_vars(server_id: str = "srv-env"):
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/TokenExchangeFormFields.tsx b/ui/litellm-dashboard/src/components/mcp_tools/TokenExchangeFormFields.tsx
index 6a777938827..9e1e1a85743 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/TokenExchangeFormFields.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/TokenExchangeFormFields.tsx
@@ -22,6 +22,25 @@ const TokenExchangeFormFields: React.FC<TokenExchangeFormFieldsProps> = ({ isEdi
return (
<>
+ <Form.Item
+ label={
+ <FieldLabel
+ label="Profile"
+ tooltip="Token-exchange wire dialect. RFC 8693 is the standard token-exchange grant. Microsoft Entra OBO uses Entra's On-Behalf-Of dialect (the RFC 7523 jwt-bearer grant with requested_token_use=on_behalf_of) and carries the target resource in a scope like api://<app-id>/.default."
+ />
+ }
+ name="token_exchange_profile"
+ {...(isEditing ? {} : { initialValue: "rfc8693" })}
+ >
+ <Select className="rounded-lg" size="large">
+ <Select.Option value="rfc8693">
+ <span className="font-medium">RFC 8693 (standard)</span>
+ </Select.Option>
+ <Select.Option value="entra_obo">
+ <span className="font-medium">Microsoft Entra OBO</span>
+ </Select.Option>
+ </Select>
+ </Form.Item>
<Form.Item
label={
<FieldLabel
@@ -57,33 +76,71 @@ const TokenExchangeFormFields: React.FC<TokenExchangeFormFieldsProps> = ({ isEdi
>
<Input.Password placeholder={`Enter OAuth client secret${placeholderSuffix}`} className={fieldClassName} />
</Form.Item>
- <Form.Item
- label={
- <FieldLabel
- label="Audience (optional)"
- tooltip="Target audience for the exchanged token (RFC 8693 audience). Identifies the upstream MCP server the token is for."
- />
- }
- name="audience"
- >
- <Input placeholder="https://upstream.example.com" className={fieldClassName} />
- </Form.Item>
- <Form.Item
- label={
- <FieldLabel
- label="Subject Token Type (optional)"
- tooltip="Type of the user's incoming token (RFC 8693 subject_token_type). Defaults to urn:ietf:params:oauth:token-type:access_token."
- />
- }
- name="subject_token_type"
- >
- <Input placeholder="urn:ietf:params:oauth:token-type:access_token" className={fieldClassName} />
- </Form.Item>
- <Form.Item
- label={<FieldLabel label="Scopes (optional)" tooltip="Optional scopes to request during the token exchange." />}
- name={["credentials", "scopes"]}
- >
- <Select mode="tags" tokenSeparators={[","]} placeholder="Add scopes" className="rounded-lg" size="large" />
+ <Form.Item noStyle shouldUpdate={(prev, cur) => prev.token_exchange_profile !== cur.token_exchange_profile}>
+ {({ getFieldValue }) => {
+ const isEntraObo = getFieldValue("token_exchange_profile") === "entra_obo";
+ return (
+ <>
+ {!isEntraObo && (
+ <>
+ <Form.Item
+ label={
+ <FieldLabel
+ label="Audience (optional)"
+ tooltip="Target audience for the exchanged token (RFC 8693 audience). Identifies the upstream MCP server the token is for."
+ />
+ }
+ name="audience"
+ >
+ <Input placeholder="https://upstream.example.com" className={fieldClassName} />
+ </Form.Item>
+ <Form.Item
+ label={
+ <FieldLabel
+ label="Subject Token Type (optional)"
+ tooltip="Type of the user's incoming token (RFC 8693 subject_token_type). Defaults to urn:ietf:params:oauth:token-type:access_token."
+ />
+ }
+ name="subject_token_type"
+ >
+ <Input placeholder="urn:ietf:params:oauth:token-type:access_token" className={fieldClassName} />
+ </Form.Item>
+ </>
+ )}
+ <Form.Item
+ label={
+ <FieldLabel
+ label={isEntraObo ? "Scopes" : "Scopes (optional)"}
+ tooltip={
+ isEntraObo
+ ? "Microsoft Entra OBO carries the target resource in the scope, so at least one is required (e.g. api://<app-id>/.default)."
+ : "Optional scopes to request during the token exchange."
+ }
+ />
+ }
+ name={["credentials", "scopes"]}
+ rules={
+ isEntraObo
+ ? [
+ {
+ required: true,
+ message: "Microsoft Entra OBO requires a scope, e.g. api://<app-id>/.default",
+ },
+ ]
+ : []
+ }
+ >
+ <Select
+ mode="tags"
+ tokenSeparators={[","]}
+ placeholder={isEntraObo ? "api://<app-id>/.default" : "Add scopes"}
+ className="rounded-lg"
+ size="large"
+ />
+ </Form.Item>
+ </>
+ );
+ }}
</Form.Item>
</>
);
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.test.tsx b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.test.tsx
index 97ed63807d9..9f381503d18 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.test.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.test.tsx
@@ -437,12 +437,49 @@ describe("CreateMCPServer", () => {
const [, payload] = vi.mocked(networking.createMCPServer).mock.calls[0];
expect(payload.auth_type).toBe("oauth2_token_exchange");
expect(payload.token_exchange_endpoint).toBe("https://idp.example.com/oauth2/token");
+ expect(payload.token_exchange_profile).toBe("rfc8693");
expect(payload.credentials).toMatchObject({
client_id: "te-client-id",
client_secret: "te-client-secret",
});
});
+ it("makes scope required when the Entra OBO profile is selected", async () => {
+ await selectHttpTransport();
+
+ const user = userEvent.setup({ delay: null });
+
+ await user.type(getServerNameInput(), "Entra_Server");
+ await user.type(screen.getByPlaceholderText("https://your-mcp-server.com"), "https://upstream.example.com/mcp");
+
+ await selectAntOption("Authentication", "OAuth Token Exchange (OBO)");
+ await waitFor(() => {
+ expect(screen.getByPlaceholderText("https://idp.example.com/oauth2/token")).toBeInTheDocument();
+ });
+
+ await selectAntOption("Profile", "Microsoft Entra OBO");
+
+ await user.type(
+ screen.getByPlaceholderText("https://idp.example.com/oauth2/token"),
+ "https://login.microsoftonline.com/tenant/oauth2/v2.0/token",
+ );
+ await user.type(screen.getByPlaceholderText("Enter OAuth client ID"), "entra-client");
+ await user.type(screen.getByPlaceholderText("Enter OAuth client secret"), "entra-secret");
+
+ // Selecting Entra OBO makes the scope required; submitting without one is blocked by validation
+ // (rfc8693 would not require it), which confirms the profile selection took effect.
+ const submitButton = screen.getByRole("button", { name: "Add MCP Server" });
+ await act(async () => {
+ fireEvent.click(submitButton);
+ });
+ await waitFor(() => {
+ expect(
+ screen.getByText("Microsoft Entra OBO requires a scope, e.g. api://<app-id>/.default"),
+ ).toBeInTheDocument();
+ });
+ expect(networking.createMCPServer).not.toHaveBeenCalled();
+ });
+
it("enforces the allowlist when the user explicitly deselects every tool", async () => {
await selectHttpTransport();
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx
index 842af787999..faf7737e995 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx
@@ -651,7 +651,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
: {}),
...(mcpServer.auth_type === AUTH_TYPE.OAUTH2_TOKEN_EXCHANGE &&
restValues.auth_type !== AUTH_TYPE.OAUTH2_TOKEN_EXCHANGE
- ? { token_exchange_endpoint: null, audience: null, subject_token_type: null }
+ ? { token_exchange_endpoint: null, audience: null, subject_token_type: null, token_exchange_profile: null }
: {}),
server_id: mcpServer.server_id,
mcp_info: {
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
index e07274a8d28..7e02b8779f5 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
@@ -241,6 +241,7 @@ export interface MCPServer {
token_exchange_endpoint?: string | null;
audience?: string | null;
subject_token_type?: string | null;
+ token_exchange_profile?: string | null;
mcp_info?: MCPInfo | null;
created_at: string;
created_by: string;