Build an OAuth MCP client
Discover i2v.ai's authorization server, register a public client, and request only the scopes it needs.
Use a Streamable HTTP MCP SDK with OAuth support when building your own client. The resource and token audience are https://i2v.ai/api/mcp.
Discover and register
- An unauthenticated MCP request returns HTTP
401. Read theresource_metadataURL in itsWWW-Authenticateheader. The endpoint ishttps://i2v.ai/.well-known/oauth-protected-resource/api/mcp. - Follow its authorization server to
https://i2v.ai/.well-known/oauth-authorization-serverto discover authorization, token, registration and revocation endpoints. - Register a public client using the advertised
registration_endpoint. Supply your callback inredirect_urisand usetoken_endpoint_auth_method: none. Register the exact HTTPS callback or a loopback callback for an installed app.
Authorize and initialize
- Generate a fresh PKCE verifier for this authorization and send its S256 challenge. Generate and store
statefor the callback. Requestresponse_type=code, the registeredclient_idandredirect_uri, the MCPresource, and the required scopes. - Request
mcp:readfor discovery and account queries. To submit or upload, requestmcp:writeas well and let the user approve it on the consent screen. A client should check the granted scopes rather than infer them from its request. - Validate
stateat the callback and exchange the code for tokens with the original verifier and redirect URI. Send the resulting access token as a Bearer credential to the MCP endpoint. Initialize the SDK connection before discovering or calling tools.
Refresh and revoke
The authorization code expires after 60 seconds. Access tokens last one hour, and refresh tokens last 30 days and rotate on use. Persist the newly returned refresh token atomically so another worker cannot retry with a consumed token. Submit revocation to the discovered endpoint or have the user revoke the client in . Keep tokens out of logs and support tickets. See the MCP authorization specification for client behavior.

