McpOAuth

class McpOAuth(http: OkHttpClient = DefaultHttpClient)(source)

MCP authorization (OAuth 2.1) discovery and client registration, per the MCP authorization spec:

  1. Protected Resource Metadata (RFC 9728) from the 401 challenge's resource_metadata, else the well-known URIs of the server URL;

  2. Authorization Server Metadata (RFC 8414, then OpenID Connect discovery); PKCE S256 support is required;

  3. Dynamic Client Registration (RFC 7591) as a public client with a loopback redirect (RFC 8252), unless a client id is supplied.

Then run McpOAuthRegistration.flow with OAuthClient and keep the tokens in a TokenStore behind McpOAuthTokens.

Constructors

Link copied to clipboard
constructor(http: OkHttpClient = DefaultHttpClient)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun discover(serverUrl: String, resourceMetadataUrl: String? = null, scope: String? = null, redirect: LoopbackRedirect, clientName: String = "AI Elements", clientId: String? = null): McpOAuthRegistration