MCP credential reuse
Last updated: 2026-11-15T01:35:00-03:00 (UTC-3)
With per-user OAuth, each user connects their own account on every MCP server that acts as them. When several MCP servers sit behind the same authorization server and accept the same tokens, connecting each one separately is redundant. Credential reuse lets a server use the user’s grant of another server, but only where the operator declared it, the binding still matches, and the user consented.
| Flag | Default | What it turns on |
|---|---|---|
mcp_credential_reuse |
false |
Reuse of consented grants and the consent routes; an operator control; requires mcp_user_oauth |
A grant is never shared because hosts, teams or issuers happen to match. Declaring a shared audience is a trust decision: a token issued for it is valid at every resource server that accepts that audience, so the target can act at the source with the user’s rights. Declare it only for servers operated under the same trust.
Declaring a reusable pair
Section titled “Declaring a reusable pair”Both servers are boot (YAML) servers with auth: per_user_oauth and declare:
- the same pre-registered
oauth.client_id(a dynamic registration is per server and never shared); - the same
oauth.audience: the RFC 8707 resource the grants are bound to, which both resource servers accept. With an audience set, it is sent asresourceinstead of the server URL on authorization, token and refresh requests; - on the target,
oauth.reuse_fromnaming the source, and explicitoauth.scopesthat are a subset of the source’s.
mcp_execution: servers: - id: docs endpoint_url: https://docs.example.com/mcp auth: per_user_oauth oauth: client_id: gateway-mcp client_secret_env: MCP_DOCS_CLIENT_SECRET scopes: [tools, read] audience: https://api.example.com tools: [...] - id: search endpoint_url: https://search.example.com/mcp auth: per_user_oauth oauth: client_id: gateway-mcp client_secret_env: MCP_DOCS_CLIENT_SECRET scopes: [tools] audience: https://api.example.com reuse_from: docs tools: [...]| Field | Default | Rules |
|---|---|---|
oauth.audience |
empty (the server URL is the resource) | absolute https URI without query or fragment, compared exactly (plain http only on loopback with allow_loopback_http); not combined with omit_resource |
oauth.reuse_from |
empty | a per-user OAuth server with an oauth client, not itself, not itself reusing (no chains); same client_id and audience; explicit scopes within the source’s |
The configuration is refused at startup when any rule fails.
Consent
Section titled “Consent”In MCP connections the user sees each server offering reuse, the connection it would use, its audience and scopes, and Allow / Revoke. Allowing requires an active grant on the source that includes the target’s scopes, and the target’s authorization server (discovered from its RFC 9728 metadata) must be the issuer of that grant; otherwise the consent is refused (409 mcp_reuse_source_not_connected, mcp_reuse_scope_not_granted, mcp_reuse_issuer_mismatch). The consent records the binding: source, issuer, client, audience, scopes and the target endpoint the token will be sent to, which the panel shows. Every grant now records the resource it was obtained for; a source grant obtained before its audience was declared (or before migration 154) cannot be reused until the user reconnects the source (409 mcp_reuse_resource_mismatch). Reconnecting the source is a new grant and clears its consents.
Every use checks again
Section titled “Every use checks again”A call to the target with no grant of its own uses the source grant only if:
- the consent still names the declared source, client, audience and the target’s endpoint (repointing the target needs a new consent);
- the source grant was obtained for the consented audience;
- the target’s scopes are within the consented scopes (an expanded declaration needs a new consent) and within the scopes granted to the source;
- the source grant’s issuer is the consented issuer, and the target’s discovered authorization server is that issuer: a server that trusts another authorization server never receives the token (confused deputy);
- the source grant is active, refreshed when needed under its cross-replica claim.
Otherwise the call answers 401 mcp_auth_required as before; it never falls back to a team or boot credential. The checks run again on the grant that is actually sent, after any refresh. The token is never copied, logged or shown: the source grant stays the only encrypted copy, and the execution trail records the credential class user_oauth_reused.
The issuer check compares the target’s own RFC 9728 metadata with the grant’s issuer: it stops a server that honestly trusts another authorization server, but a resource server can advertise any issuer, so the endpoint binding in the consent and the operator’s declaration remain the controls against an untrusted target.
A grant whose resource no longer matches its server’s configuration (an audience added or changed) is not sent to that server either; the user reconnects.
Revocation
Section titled “Revocation”- Revoke (
DELETE /api/v1/admin/mcp/servers/{id}/oauth/reuse) removes one binding; the source connection and other bindings stay. - Disconnecting the source revokes every binding built on it in the same transaction.
- Deleting the user removes their bindings.
- Revoking a binding does not revoke the token at the provider: a token the target already received stays valid there until it expires. Disconnect the source to revoke the grant at the provider.
Each consent and revocation is in the identity audit (mcp_oauth.reuse_consent, mcp_oauth.reuse_revoke).
Routes
Section titled “Routes”All require a named console user and mcp_oauth:self.
| Route | Behavior |
|---|---|
GET /api/v1/admin/mcp/oauth/reuse |
Offers: server_id, source_server_id, audience, scopes, source_connected, consent and current (false when the declaration changed since the consent) |
POST /api/v1/admin/mcp/servers/{id}/oauth/reuse |
Consent for the caller |
DELETE /api/v1/admin/mcp/servers/{id}/oauth/reuse |
Revoke the caller’s consent |
Upgrade
Section titled “Upgrade”Migration 154 creates gateway_mcp_oauth_reuse_consents. Declaring audience changes the resource of future authorizations of that server: existing grants keep working until they need a new authorization, which then uses the audience. Upgrade every replica before turning the flag on.