Metadata about this OAuth client.
The URL to redirect the user agent to after authorization.
OptionaladdAdds custom client authentication to OAuth token requests.
This optional method allows implementations to customize how client credentials are included in token exchange and refresh requests. When provided, this method is called instead of the default authentication logic, giving full control over the authentication mechanism.
Common use cases include:
The request headers (can be modified to add authentication)
The request body parameters (can be modified to add credentials)
The token endpoint URL being called
Optionalmetadata: AuthorizationServerMetadataOptional OAuth metadata for the server, which may include supported authentication methods
Loads information about this OAuth client, as registered already with the
server, or returns undefined if the client is not registered with the
server.
Loads the PKCE code verifier for the current session, necessary to validate the authorization result.
OptionalinvalidateIf implemented, provides a way for the client to invalidate (e.g. delete) the specified credentials, in the case where the server has indicated that they are no longer valid. This avoids requiring the user to intervene manually.
Invoked to redirect the user agent to the given URL to begin the authorization flow.
OptionalsaveIf implemented, this permits the OAuth client to dynamically register with
the server. Client information saved this way should later be read via
clientInformation().
This method is not required to be implemented if client information is statically known (e.g., pre-registered).
Saves a PKCE code verifier for the current session, before redirecting to the authorization flow.
Stores new OAuth tokens for the current session, after a successful authorization.
OptionalstateReturns a OAuth2 state parameter.
Loads any existing OAuth tokens for the current session, or returns
undefined if there are no saved tokens.
OptionalvalidateIf defined, overrides the selection and validation of the RFC 8707 Resource Indicator. If left undefined, default validation behavior will be used.
Implementations must verify the returned resource matches the MCP server.
Optionalresource: string
Implements an end-to-end OAuth client to be used with one MCP server.
This client relies upon a concept of an authorized "session," the exact meaning of which is application-defined. Tokens, authorization codes, and code verifiers should not cross different sessions.