Skip to main content
Clink MCP lets an agent call Clink wallet and payment tools as an authorized user. This page is for agent platform developers: the platform server uses the platform credentials issued by Clink to set up an MCP connection for each user, and the agent then completes payments through MCP. Personal users can start with the Local Agent quickstart. If you do not use MCP, read How to integrate RESTful API.

1. Prepare the environment and platform credentials

Clink configures credentials separately for each environment. Do not mix Sandbox UAT and Production tokens, user connections, MCP URLs, or callback URLs. Below, {API_BASE_URL} and {MCP_URL} stand for the URLs of the selected environment. The MCP URL is also the OAuth resource parameter and the audience of user tokens. MCP uses the platform client_id and client_secret issued through Pre-registration, and shares the same platform client with the RESTful API. For how to apply, what Clink registers, and the RSA public key, see How to get platform credentials. When the client is set up, register the redirect_uri used for the user’s first authorization and the MCP scopes below. In addition to the platform credentials, the backend also stores CLINK_API_BASE_URL and CLINK_MCP_URL. User tokens and decrypted card fields can be stored only on a trusted server. The MCP client configuration contains only the MCP URL; do not put a token or secret in it.
Set up a separate connection for each user, and store each user’s tokens separately on the server. All users share the same platform client; do not apply for a new client for each user.

Scope configuration

Clink configures scopes centrally based on the capabilities enabled for the platform; the platform does not need to register or assemble scopes one by one. When you apply, describe the capabilities the platform needs, and Clink configures the scopes for user authorization accordingly. The platform only needs to use the configuration Clink provides in the authorization flow. If the agent calls a capability that is not enabled, the tool returns insufficient_scope. To add a capability, contact Clink to update the configuration, then have the user authorize again. OAuth scopes only determine which tools the agent can call; they are not the same as the user authorizing a specific purchase. See Wallet Service for the difference.

2. Configure the agent’s system prompt

The platform’s agent needs a set of rules to know how to call Clink MCP tools, how to choose among the payment methods, and which operations are not allowed. Copy the rules below into the agent’s system prompt:
  1. Copy the “Common rules” first. They are required.
  2. Then copy the modules that match the capabilities enabled for the platform, and append them in order after the common rules. The agent does not use a capability whose module you did not copy.
  3. Browser Pay, UCP Pay, and Quick Pay all use cards in the user’s wallet. When you integrate any of these payment methods, we recommend also copying Wallet Services.
After connecting to MCP, the agent also reads clink://skill/rules from the server. When rules or a next_action returned by the server disagree with the system prompt, the server takes precedence. The common rules already state this.

Common rules (required)

Wallet Services

Manage cards, the default card, purchase authorizations, and risk rules. See Wallet Service for what it covers.

Browser Pay

Pay by card on any merchant website. See Browser Pay for the flow.

UCP Pay

UCP product search, UCP checkout, and benefit redemption. See UCP Pay for the flow.

Quick Pay

Place orders directly with Clink merchants, and look up orders and refunds. See Quick Pay for the flow.

3. Code integration

Clink MCP uses the Streamable HTTP transport with protocol version 2026-07-28. Use an MCP client SDK or agent framework that supports this version; it handles protocol negotiation, request headers, and streamed responses. After a user completes the first OAuth authorization and the tokens are exchanged, the platform server must persist the returned access_token, refresh_token, expiration time, and granted scopes per platform user and environment. Do not keep tokens only in the memory of the current request or agent process; otherwise the user’s MCP connection cannot be used after the service restarts.
  • access_token: used to call MCP. When it expires or you receive 401, use the matching refresh_token to get a new token.
  • refresh_token: store it encrypted. Each refresh returns a new refresh token. Save the new value atomically first, then use the new access token. Refreshes for the same user and environment must be serialized so that concurrent refreshes do not reuse an old token.
  • User identifier: use the platform’s own stable user ID as the primary key, isolated by environment. Do not use an email address as the primary key, and do not reuse tokens across users or environments.
  • After revocation or a failed refresh, delete the invalid local tokens and run the user authorization flow again. Do not bypass user authorization to create a new connection.
Tokens are server-side credentials. Encrypt, store, and use them only on a trusted server. Do not write them into agent configuration files, the system prompt, browser storage, logs, tool arguments, or user messages. The following example persists and refreshes tokens on the server. tokenStore should connect to a server-side database or secret store. withUserTokenRefreshLock should use a database lock or distributed lock to ensure that the same user and environment are never refreshed concurrently:
tokenStore needs a unique record per platformUserId + environment. A production implementation should also encrypt tokens with a key management service and keep token contents out of exceptions, logs, and monitoring. When revocation or refresh fails, delete the invalid credentials and guide the user through authorization again. Register Clink as a remote MCP server in the agent framework:
  • url: the {MCP_URL} of the selected environment.
  • Authorization: Bearer {USER_ACCESS_TOKEN}, the current user’s access token, injected per user at runtime.
On the first run, you cannot get the user’s access token directly. The server should call /platform/sessions first:
  • Returns authorized: read access_token from the response, persist the tokens, then start this agent run.
  • Returns authorization_required: do not start the agent or connect to MCP. Give the authorization_url from the response to the current user unchanged, and wait for the user to sign in and authorize. After the OAuth callback is validated, retry /platform/sessions, get the authorized response, and persist the tokens.
After the user has authorized, each time you start a new agent run or MCP session, read the persisted record by platform user ID and environment and call getAccessToken(), as shown below. It returns an access token that is still valid, or, when the token is about to expire, refreshes it serially and returns the new access token. Then inject this value into the agent framework’s MCP configuration.
When you receive authorization_required, the platform gives authorizationUrl to the current user. After the user authorizes and the callback succeeds, call startAgentRun() again. The server callback handler should first validate state, iss, and PKCE, then retry /platform/sessions and persist the access_token, refresh_token, expiration time, and scopes from the authorized response. Do not get one token at service startup and share it across all users, and do not hardcode tokens in the agent configuration. After the MCP session is established, if a request returns 401, first close or rebuild the current MCP connection, then refresh that user’s token and retry once. Do not put tokens in tool arguments. The platform server obtains and refreshes user access tokens through /platform/sessions and OAuth; see Agent Platform MCP Login for the flow. Inject tokens only on the server; do not write them into configuration files, the system prompt, or tool arguments.
After configuration, run a read-only check with get_account_state: if you can read paymentMethods, the connection works; an empty list only means the wallet has no cards yet. On 401, refresh the user token. On 403 insufficient_scope, contact Clink to add the scope, then have the user authorize again.