Skip to main content
Agent platforms that have already verified a user’s email can establish a Clink MCP session from their backend. The platform keeps the platform client_id and client_secret on its server and never sends the platform token to the browser or the Agent. Clink uses one pre-registered platform client for both the MCP login described here and the Customize Agent Portal read-only API. The two token types are different, but the client identity is the same.

How it works

Before you start

Ask Clink to pre-register the platform client in the target environment. You need:
  • A platform client_id and client_secret.
  • The exact OAuth redirect_uri you will use for first-time authorization.
  • PKCE S256 support in the platform backend.
  • The environment MCP resource, for example https://uat-api.clinkbill.com/mcp.
  • A verified user email from your own user system. Do not send an unverified or user-editable address.
The platform client is never created through Dynamic Client Registration. It is registered by Clink.

1. Get a platform client token

The returned token is a client token, not a user token. It has token_use=client, audience clink-agent-platform-api, and scope agent-platform:account. Cache it until shortly before expires_in; do not send it to the Agent or the browser.

2. Create or resume the MCP session

The examples below show the full { code, msg, data } response envelope. Read data.status:

authorized

customer_created is true when Clink created a customer from the verified email. A refresh token is returned on first login. When an existing session is reused, only an access token is returned unless issue_refresh: true was requested.

authorization_required

The URL uses the standard Clink Authorization Endpoint. It carries an email prefill for the Portal login page when available, but the user still completes email OTP verification. Keep state and the PKCE code_verifier on the platform server until the callback completes.

3. Connect the Agent to MCP

Use the returned access_token as the Bearer token for the MCP endpoint:
The user access token has: The Agent can now use the normal MCP connection for wallet and payment tools. Do not expose the platform client token to the Agent.

4. Complete first-time authorization

For authorization_required, redirect the user to authorization_url. After the user signs in and consents, the browser reaches your registered callback with code, state, and iss.
  • Verify state belongs to the user who started the flow.
  • Verify iss matches the environment issuer from Authorization Server Metadata.
  • Exchange the code with PKCE exactly as described in Browser Pay platform setup.
  • Retry POST /agent/cwallet/platform/sessions with the same email. The new LoginSession lets Clink return authorized without another browser round trip.

Refresh tokens

On first login, the platform receives a refresh token. Store it on the server and refresh before it expires:
If the refresh token expires or is revoked, call /agent/cwallet/platform/sessions again. A missing or revoked session falls back to authorization_required; do not bypass that flow by omitting the user’s authorization.

Environment endpoints

Security

  • Keep the platform client_secret and platform client token on the server.
  • Treat email as a platform-asserted identity only after your own verification.
  • Never accept a customer_id or email supplied by the Agent to choose a different user.
  • Use a stable device_id; it is part of the user’s login state.
  • Never mix sandbox and production client credentials, callbacks, or MCP resources.

Customize Agent Portal

Use the same platform client to obtain a read-only portal token and render the user’s Clink data.

MCP connection and OAuth

Review the complete MCP authorization and connection lifecycle.