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
APromise (discovery is a boot-time network call) for the OAuthConfig you pass to the oauth constructor option.
TExtra is the claim shape the verifier resolves with, and the server reads it from here, so handlers get extra.authInfo?.extra typed without declaring anything. Pass it as a type argument to name claims your IdP sends: customProvider<{ subject?: string; email?: string }>({ ... }).
Build this object by hand only to wire an IdP whose metadata customProvider can’t discover. Supply exactly one of the two: verifier, from createJwksVerifier({ issuer, jwksUri }) for JWTs or your own TokenVerifier for opaque tokens, or the deprecated verify parameters. Either way 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