Skip to main content
Use 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 clientId and clientSecret.
  • The provider does not expose a registration_endpoint in 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.
Common proxy targets include Google, GitHub, Okta, Microsoft Entra ID, and enterprise SSO deployments that require pre-registered applications.

Register one upstream redirect URI

In the provider dashboard, register the MCP server callback URL:
Use your deployed server domain in production:
Do not register every MCP client’s redirect URI with the upstream provider. The MCP server brokers the callback for clients.

Configure the proxy

This Google example validates opaque user access tokens with Google’s tokeninfo and userinfo endpoints.
Use 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.
  1. The MCP client calls the MCP server’s /register endpoint.
  2. The MCP server returns the pre-registered upstream clientId.
  3. The client starts PKCE authorization through the MCP server’s /authorize endpoint.
  4. The upstream provider redirects to the MCP server’s /oauth/callback.
  5. The MCP server forwards the authorization code to the client’s original redirect URI.
  6. During token exchange, the MCP server injects the upstream clientId and clientSecret.
  7. The client calls /mcp/* with the upstream access token.
  8. The MCP server verifies the token with your verifyToken function.
The proxy passes upstream tokens through. It does not mint its own access tokens.

Handle opaque tokens

GitHub issues opaque access tokens, so jwksVerifier does not apply. Validate the token by calling the provider API.

Use upstream tokens in tools

The upstream access token is available as ctx.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.