Skip to main content

Overview

auth_type: "per_user_oauth" lets each end-user connect to an upstream MCP service (Notion, GitHub, Sentry, etc.) under their own account. Bifrost stores one OAuth token per (identity, mcp_client) and reuses it on every later call. If a single shared admin token is fine, use OAuth 2.0 instead. This auth type is only valid for HTTP connections. It is refused on an SSE or STDIO client, because each call opens its own connection: the API answers 400, and a config.json client is skipped at boot with an error naming it.
This page covers upstream per-user OAuth — Bifrost holding a token for an upstream MCP service on behalf of each end-user, resolved lazily on the first tool call that needs it. Identity is asserted by the caller via headers (or upstream SSO).This is separate from Bifrost acting as an OAuth 2.1 Authorization Server for inbound /mcp clients (browser consent + .well-known discovery), which is covered in Gateway Authentication.
By default every user sees the tool list the admin’s login discovered. If the upstream service gives different accounts different tools, turn on Per-Caller Discovery so each user sees the tools their own account has.

Setup

Per-user OAuth needs a one-time admin test login so Bifrost can verify the OAuth configuration and discover the tool list from the upstream service. The admin’s bootstrap token is retained after verification as the admin discovery credential, used only to keep the tool list fresh; per-user tokens are minted lazily by end-users at runtime, and end-user traffic never uses the admin token. With Per-Caller Discovery on, the admin login only verifies the setup and is not kept. You can run the admin verification either from the Web UI during create, or from a config.json-declared client by clicking Verify in the UI after Bifrost boots.
  1. Navigate to MCP Gateway in the sidebar
  2. Click New MCP Server
  3. Pick HTTP as the connection type, fill in the Connection URL
  4. Set Auth Type to Per-User OAuth 2.0
  5. Fill in the OAuth fields:
    • Client ID (optional — leave blank for Dynamic Client Registration)
    • Client Secret (optional — omit for PKCE public clients)
    • Authorize URL / Token URL (optional — leave blank for OAuth discovery)
    • Scopes (comma-separated)
  6. Click Create — Bifrost runs a test OAuth flow in a popup as the admin
  7. Complete the upstream sign-in
  8. The MCP client is persisted with the discovered tool list and made available for end-users
MCP client form with Auth Type set to Per-User OAuth 2.0 and the OAuth fields ready for setup
If the upstream server supports OAuth Discovery (RFC 8414), you can leave the authorize and token URLs blank and provide only the Connection URL plus client ID. Bifrost discovers the endpoints automatically.
Providers that only issue refresh tokens on explicit request (Google needs access_type=offline&prompt=consent) will otherwise hand out access-token-only grants that expire within about an hour and flip to needs_reauth. Append the provider’s offline-access parameters to authorize_url; Bifrost preserves query parameters already present on it. See the refresh-token warning on the OAuth 2.0 page.

How it works

The same lazy-auth pattern is used on both the MCP Gateway (/mcp) and the LLM Gateway (/v1/chat/completions):
  1. The caller sends a request with an identity (header or SSO).
  2. The LLM (or MCP client) asks to invoke a tool on a per-user OAuth service.
  3. Bifrost looks up an existing token for (identity, mcp_client):
    • Token found and active → upstream call goes out transparently
    • Missing, orphaned, or needs_reauth → Bifrost returns an mcp_auth_required payload with an inline authorize_url. The tool is not executed.
    • Rejected upstream (the provider expired or revoked it before the expiry Bifrost stored) → Bifrost refreshes it once and connects again, so the call goes ahead. If the provider refuses the refresh too, the token becomes needs_reauth and the same request returns mcp_auth_required.
  4. The user opens the URL, completes the upstream OAuth flow, and Bifrost stores the resulting token against their identity.
  5. The next request executes the tool normally.
Per-user OAuth lazy flow — identity → tool call → auth URL → upstream OAuth → tool executes

What the auth URL looks like

LLM Gateway — authorize_url is on the response’s extra_fields.mcp_auth_required block, and also embedded in the natural-language message so plain-text clients see it too:
VK and session-mode URLs may also carry a #t=<temp-token> fragment when mcp_enable_temp_token_auth is turned on. User-mode URLs never do — they require SSO login regardless.
LLM Gateway response with mcp_auth_required and an inline authorize_url
MCP Gateway — same string surfaces as a tool result message, so OAuth-capable MCP clients like Claude Code and Cursor see the URL inline in chat:
Auth URL surfaced inline in a Claude Code tool result
The URL points at a Bifrost dashboard page. It shows:
  • Which MCP server is asking for authentication
  • Which identity the resulting token will be bound to (VK name, signed-in user, or session ID)
  • An Authenticate button that redirects to the upstream provider
After completing upstream OAuth, the user is redirected back to /api/oauth/callback, the code is exchanged for tokens server-side, and the token is stored against the identity.
Bifrost consent page at /workspace/mcp-sessions/auth?flow=<id>, showing the MCP server, the identity, and an Authenticate button
When the #t=<temp-token> URL fragment is present, it authorizes anonymous browser visitors to complete the flow without a dashboard session. The fragment never reaches server logs (fragments are not sent in the request line). User-mode flow URLs never carry a temp token — visitors must complete SSO login first, and only the bound SSO user can finish the flow. See Flow mode and access rules for the per-mode behavior and how to enable temp tokens for VK/session flows.

Multi-server auth

If a single LLM turn triggers tool calls against multiple unauthenticated per-user MCP servers, the LLM only ever sees one mcp_auth_required at a time (the first un-authed service Bifrost hits). The user authenticates that one, retries, and the LLM is then prompted for the next un-authed service — until everything required for the turn is authenticated. A user signed in to the dashboard can avoid this by connecting their servers up front: see Connect before your first call.

Connect before your first call

A user signed in to the dashboard doesn’t have to wait for a tool call to hand them a link. They can start their own sign-in up front, from the dashboard or the API:
  • Dashboard: on Enterprise with SSO, Home → My access → MCP servers lists every MCP server the user can call, with how each one connects. Connect opens the provider’s sign-in in the same tab and brings the user back to Home, where the row reads Connected. The same row offers Reconnect once a sign-in expires, Continue sign-in for one they started and did not finish, and Load tools or Refresh tools on a server with Per-Caller Discovery.
  • API: POST /api/mcp/sessions/connect with the server’s client ID returns the provider’s authorize_url to open. See Start a sign-in.
The token is bound to the user, the same as one stored from an mcp_auth_required link, so it serves their calls through their own keys and sign-in. Only an enabled server that has passed admin verification can be connected this way.

Identity modes

Every per-user OAuth row is bound to exactly one identity column. The mode is derived from request context at lookup time, with priority user > vk > session. See Identity modes on the Auth overview for the full table. A per-user request without any identity is rejected with an mcp_auth_required payload that explains the caller must send a VK, sign in, or set x-bf-mcp-session-id.

Cross-gateway token sharing

Tokens are stored against an identity, not against a gateway. As long as the same identity reaches the gateway, the token is reused.
  • Authenticate via the LLM Gateway with vk_xyz → that token is immediately usable on the MCP Gateway as long as the inbound request also carries vk_xyz.
  • Authenticate via the MCP Gateway with x-bf-mcp-session-id=abc → the LLM Gateway can reuse it by sending the same x-bf-mcp-session-id header.
  • Authenticate via enterprise SSO as user u_123 on either gateway → the other gateway also reuses the token automatically (no header to set).

Configuration reference

After an MCP client is verified (via Web UI Create or via the config.json bootstrap flow), its auth_type is per_user_oauth with an oauth_config_id linking to the OAuth credentials Bifrost stored. You’ll see this shape in API responses:
MCP client names cannot contain hyphens — Bifrost prefixes tools as <client>-<tool> and uses the hyphen to split the two halves at execution time.

Managing user tokens

Every per-user OAuth token shows up on the MCP Sessions page. From there callers can re-authenticate stale tokens, revoke rows outright, and see status (active, orphaned, needs_reauth). See MCP Sessions for the full lifecycle, the difference between orphaned and needs_reauth, and the auto-orphan-on-VK-change behavior.

Admin discovery credential

A client with Per-Caller Discovery on keeps no admin discovery credential: each user’s tools are discovered with their own token, so nothing in this section applies to it.
The admin’s one-time bootstrap token is not thrown away after verification: Bifrost retains it as a client-level admin discovery credential (auth mode admin). Its role is deliberately narrow:
  • Tool-list refresh only. The periodic tool syncer uses it for a one-shot connect, tools/list, disconnect cycle on the client’s tool sync interval. It is never used for end-user tool calls; those always run under the caller’s own token.
  • Proactively refreshed. The background token refresh worker keeps it alive alongside shared-client tokens, so tool discovery keeps working without anyone logging in again.
  • Invisible on the sessions page. Admin credentials are excluded from MCP Sessions; they are managed from the server’s view sheet and actions menu instead.
If the admin credential permanently dies (refresh rejected, provider-side revocation, or a credential rotation), the server’s state shows as needs_reauth in the servers table and on its view sheet. This is a display-level state: end-user credentials and tool calls keep working, only tool-list refresh pauses until an admin repairs it. Clients verified before Bifrost retained admin credentials have no admin row and simply stay healthy. To repair it, open the server’s actions menu (⋯) in the MCP Server Catalog and choose Refresh admin credential: Bifrost redoes the admin consent flow, verifies the fresh token upstream, re-discovers tools, and installs the token as the new admin credential. If verification fails, the fresh token is revoked and the previous credential and tool set are left untouched, so the repair is safely retryable.
MCP Server Catalog with a per-user OAuth client in Needs Reauth state and Refresh admin credential highlighted in its actions menu
The same repair is scriptable via POST /api/mcp/client/{id}/reauthorize ({id} = MCP client ID). It runs a fresh admin consent flow against the client’s stored OAuth config whether or not the current admin credential needs repair, and end-user tokens are untouched either way. The response is the standard pending_oauth payload (authorize_url, status_url, complete_url); complete it the same way as the scriptable verification flow. A client still in its first sign-in gets 400 (use initiate-verification instead), and so does a client with Per-Caller Discovery on, which has no admin credential to refresh.

Periodic tool sync

Per-user clients hold no persistent upstream connection, but their tool list still refreshes on a schedule using the admin discovery credential. A client with Per-Caller Discovery on has no tool list of its own and does no periodic sync: each user’s tools are discovered again from their session instead (see Keeping discoveries current). The cadence follows the per-client tool_sync_interval (minutes, on the create/update API):
  • Positive: sync every N minutes for this client
  • 0 / unset: inherit the global mcp_tool_sync_interval client setting (minutes, default 10)
  • Negative: disable periodic sync for this client
A failed sync keeps the existing tool set and retries on the next cycle. In config.json, the field also accepts duration strings such as "10m" (recommended); a bare number there is a legacy nanosecond value, unlike the API which takes minutes. Every sync’s result persists to the database (skipped when it’s byte-identical to what’s already stored), so a restart doesn’t revert the tool list to whatever was discovered at the client’s original bootstrap verification.

Public URL configuration

The consent page URL Bifrost builds (/workspace/mcp-sessions/auth?flow=…) and the redirect_uri Bifrost registers with upstream OAuth providers are both derived from the request Host header by default. Behind a reverse proxy, override them with:
  • mcp_external_client_url — public base URL for both the consent page and the redirect_uri Bifrost registers with upstream providers
See Reverse Proxy configuration → for the full reference.
Changing mcp_external_client_url after an upstream provider has been registered breaks already-authorized clients. Upstream providers lock the redirect_uri to whatever was registered during Dynamic Client Registration. To recover, clear the stored OAuth client credentials for the affected MCP server so Bifrost re-registers with the new URL.

Next Steps