Skip to content

feat: add ui for token_exchange (On-Behalf-Of) auth type MCP clients - #5725

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
07-31-feat_ui_support_for_token_exchange_mcp_auth_type
Aug 8, 2026
Merged

feat: add ui for token_exchange (On-Behalf-Of) auth type MCP clients#5725
Pratham-Mishra04 merged 1 commit into
devfrom
07-31-feat_ui_support_for_token_exchange_mcp_auth_type

Conversation

@Pratham-Mishra04

Copy link
Copy Markdown
Collaborator

Summary

Adds token_exchange as a first-class MCP auth type, enabling OAuth 2.0 Token Exchange (On-Behalf-Of) for MCP clients. When configured, each caller's identity-provider token is automatically exchanged at runtime for a short-lived token scoped to the target server's audience — no per-user login flow, no shared credential, and no persistent session rows. The feature is gated behind IS_ENTERPRISE and requires an active SCIM/IdP integration to be visible in the UI.

Changes

  • Added token_exchange to the MCPAuthType union and introduced MCPTokenExchangeConfig (audience, exchange client ID/secret, optional scopes) to the MCP type definitions and request/response interfaces.
  • Extended the MCP client creation form with a token_exchange auth kind option, including fields for audience, exchange client ID, exchange client secret (optional), and scopes. The option only renders when the deployment has an IdP configured.
  • Removed the "Auth Scope" dropdown for token_exchange since it is inherently per-caller with no shared variant.
  • Added a verifyMCPClientExchange API mutation that POSTs to /mcp/client/:id/verify-exchange with no body; the backend exchanges the signed-in admin's own identity token to bootstrap and discover tools.
  • Wired token_exchange into the client sheet: bootstrap uses "Verify as me" instead of an OAuth browser flow, a "Re-verify as me" repair button appears on needs_reauth, and the connection-state badge is suppressed (no persistent session to display).
  • Classified token_exchange as a per-user auth type throughout the table and sheet so reconnect actions and session links are correctly suppressed.
  • Added token_exchange as a filter option in the clients filter sidebar and as a display label in the clients table.
  • Added token_exchange label and help text to the MCP library install sheet.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

  1. Deploy with an enterprise license and an active SCIM/IdP integration enabled.
  2. Navigate to the MCP Clients page and open the "Add Client" form.
  3. Confirm "Token Exchange (On-Behalf-Of)" appears in the auth type dropdown only when an IdP is configured.
  4. Select it and verify the audience, exchange client ID, exchange client secret, and scopes fields render; confirm the "Auth Scope" dropdown is absent.
  5. Create a client — the backend should exchange your signed-in identity token, verify upstream, and discover tools.
  6. Confirm the client sheet shows "Verify as me" for pending_verification and "Re-verify as me" for needs_reauth.
  7. Confirm no sessions link or live connection badge appears for token_exchange clients.
  8. Confirm token_exchange appears as a filter option in the sidebar and renders "Token Exchange" / "Per-User" in the table columns.
cd ui
pnpm i
pnpm build

Breaking changes

  • Yes
  • No

Security considerations

  • Exchange client credentials (client ID and secret) are treated as SecretVar values and are redacted on GET responses, consistent with existing OAuth credential handling.
  • The token exchange verification endpoint uses the signed-in admin's own identity token as the exchange subject; sessions authenticated only via virtual/API keys cannot bootstrap or use token_exchange clients, enforced server-side.
  • No exchanged tokens are persisted; they are short-lived and scoped per tool call.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This was referenced Jul 30, 2026

Pratham-Mishra04 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@framework/oauth2/tokenexchange.go`:
- Around line 22-32: Update the documentation for subjectTokenTypeAccessToken
and BifrostContextKeyMCPInboundBearer to describe the RFC 8693 subject_token
flow, referring to the value as the caller’s inbound bearer and requiring it to
be an OAuth access token rather than an ID token. Remove the provider-specific
claims that id_token is unsupported or categorically rejected, while preserving
the responsibility for the context value to contain the correct access token.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1a2f053b-2aa3-4e52-8060-687435cfe851

📥 Commits

Reviewing files that changed from the base of the PR and between a50a683 and 576081e.

📒 Files selected for processing (9)
  • framework/oauth2/tokenexchange.go
  • ui/app/workspace/mcp-registry/library/views/mcpLibraryInstallSheet.tsx
  • ui/app/workspace/mcp-registry/views/mcpClientForm.tsx
  • ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx
  • ui/app/workspace/mcp-registry/views/mcpClientsFilterSidebar.tsx
  • ui/app/workspace/mcp-registry/views/mcpClientsTable.tsx
  • ui/lib/store/apis/mcpApi.ts
  • ui/lib/types/mcp.ts
  • ui/lib/types/schemas.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • ui/app/workspace/mcp-registry/views/mcpClientsFilterSidebar.tsx
  • ui/app/workspace/mcp-registry/library/views/mcpLibraryInstallSheet.tsx
  • ui/lib/types/schemas.ts
  • ui/lib/store/apis/mcpApi.ts
  • ui/lib/types/mcp.ts
  • ui/app/workspace/mcp-registry/views/mcpClientForm.tsx
  • ui/app/workspace/mcp-registry/views/mcpClientsTable.tsx
  • ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx

Comment thread framework/oauth2/tokenexchange.go
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 6, 2026
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-30-feat_add_token_exchange_mcp_auth_type_for_on-behalf-of_upstream_credentials branch from a50a683 to 69add27 Compare August 6, 2026 21:53
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-31-feat_ui_support_for_token_exchange_mcp_auth_type branch from 576081e to 01d9624 Compare August 6, 2026 21:53
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-30-feat_add_token_exchange_mcp_auth_type_for_on-behalf-of_upstream_credentials branch from 69add27 to 367a387 Compare August 8, 2026 08:43
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-31-feat_ui_support_for_token_exchange_mcp_auth_type branch from 01d9624 to 0c63dfc Compare August 8, 2026 08:43

Pratham-Mishra04 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Aug 8, 8:47 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 8, 10:03 AM UTC: Graphite rebased this pull request as part of a merge.
  • Aug 8, 10:04 AM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from 07-30-feat_add_token_exchange_mcp_auth_type_for_on-behalf-of_upstream_credentials to graphite-base/5725 August 8, 2026 09:59
@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from graphite-base/5725 to dev August 8, 2026 10:02
@Pratham-Mishra04
Pratham-Mishra04 dismissed coderabbitai[bot]’s stale review August 8, 2026 10:02

The base branch was changed.

@Pratham-Mishra04
Pratham-Mishra04 requested a review from a team as a code owner August 8, 2026 10:02
… confirm dialog, badge pending_verification/needs_reauth instead of the sessions link

handleStartBootstrap never gained a token_exchange branch when the
Authorize/Verify action moved to the row actions menu, so a pending
token_exchange client hit initiate-verification (OAuth-only) and failed
with a 400. Route it through the same confirm dialog used to re-verify an
already-connected token_exchange client instead.

The table's State column also only ever surfaced needs_reauth for per-user
auth types, leaving pending_verification invisible there even though it's
the state the same action targets; the sessions link doesn't help either
of these two admin-facing states (nothing to view yet, or the link isn't
the fix), so both now show just the badge.
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-31-feat_ui_support_for_token_exchange_mcp_auth_type branch from 0c63dfc to 8c4a45c Compare August 8, 2026 10:02
@Pratham-Mishra04
Pratham-Mishra04 merged commit daf56ec into dev Aug 8, 2026
14 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 07-31-feat_ui_support_for_token_exchange_mcp_auth_type branch August 8, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants