oauthProxy when an identity provider cannot register MCP clients dynamically. You register one application in the provider dashboard, store its client credentials on the MCP server, and let the server mediate authorization and token exchange for MCP clients.
If your provider supports Dynamic Client Registration, use a built-in provider or Custom Provider. In DCR mode, clients register directly with the upstream provider and the MCP server only verifies tokens.
This guide covers the proxy workflow. Use the auth providers API reference for exact oauthProxy() options, defaults, payload contracts, and verifier behavior.
Use OAuth Proxy only when DCR is unavailable
OAuth Proxy is the right fit when all of these are true:- The provider gives you a fixed
clientIdandclientSecret. - The provider does not expose a
registration_endpointin OAuth metadata. - You can safely store the client secret on the MCP server.
- You are comfortable with the MCP server brokering the OAuth callback and token exchange.
Register one upstream redirect URI
In the provider dashboard, register the MCP server callback URL:Configure the proxy
This Google example validates opaque user access tokens with Google’s tokeninfo and userinfo endpoints.jwksVerifier only for providers that issue JWT access tokens and publish a JWKS. Write a custom verifyToken function for opaque-token providers.
Understand the proxy flow
In proxy mode, the MCP server acts as the OAuth-facing server for MCP clients.- The MCP client calls the MCP server’s
/registerendpoint. - The MCP server returns the pre-registered upstream
clientId. - The client starts PKCE authorization through the MCP server’s
/authorizeendpoint. - The upstream provider redirects to the MCP server’s
/oauth/callback. - The MCP server forwards the authorization code to the client’s original redirect URI.
- During token exchange, the MCP server injects the upstream
clientIdandclientSecret. - The client calls
/mcp/*with the upstream access token. - The MCP server verifies the token with your
verifyTokenfunction.
Handle opaque tokens
GitHub issues opaque access tokens, sojwksVerifier does not apply. Validate the token by calling the provider API.
Use upstream tokens in tools
The upstream access token is available asctx.auth.accessToken. Use it only when a tool must call the provider API on behalf of the user.
Next steps
Custom Provider
Use a provider that supports Dynamic Client Registration.
User Context
Use proxied identity data inside tools.
OAuth Proxy API reference
Look up exact proxy options, defaults, and verifier contracts.
PKCE
Review the authorization-code security flow used by MCP clients.