Discover the authorization server
Start from the production API’s protected-resource metadata:authorization_servers and scopes_supported values for the current environment. Discover these values at runtime instead of hard-coding the Clerk host.
Authorization flow
Use OAuth 2.0 authorization code with PKCE (S256):
- Register a public OAuth client with the discovered authorization server. Dynamic Client Registration is supported for compatible clients.
- Use a loopback redirect URI such as
http://127.0.0.1:<port>/callback. - Generate a PKCE verifier and challenge.
- Open the authorization URL in the user’s browser.
- The user signs in to Control and is redirected to the loopback callback with a one-time code.
- Exchange the code and verifier at the discovered token endpoint.
- Send the access token as
Authorization: Bearer <token>. - Use the refresh token before the access token expires.
OAuth-capable MCP clients perform the redirect, PKCE, token exchange, and refresh automatically. The user should not
copy an access token into chat or application settings.
Verify the token
401means the token is missing, invalid, or expired.403means the signed-in user lacks tenant access or the Parquet feature is not enabled.