Skip to main content
customProvider builds a complete OAuthConfig from an identity provider’s OAuth discovery document: it reads the provider’s metadata at boot and verifies access tokens against its JWKS. Reach for it when no branded provider fits, for any IdP that publishes discovery metadata and signs JWT access tokens.

Example

server.ts
customProvider fetches https://auth.myshop.com’s discovery document at boot, then the oauth option mounts the well-known metadata and JWKS bearer verification on /mcp. audience is the value the IdP binds into the token’s aud claim, here this server’s public URL.

Signature

Parameters

opts

Returns

A Promise (discovery is a boot-time network call) for the OAuthConfig you pass to the oauth constructor option.
Build this object by hand only to wire an IdP whose metadata customProvider can’t discover: supply verify.issuer and verify.jwksUri yourself and the oauth option mounts the same endpoints.

Connect an Identity Provider

Set up sign-in with a hosted provider

Authenticate Users

Add sign-in to your app end to end

McpServer

Pass the config to the oauth option