Introducing a new way to review your PRs.

Read the announcement

solana-foundation / pay

CLI for Agentic payments (x402, MPP, AP2).

View on GitHub

30 documents · Updated Nov 11, 2026

docs / agent-pay-cli-plugin

CLI payment agent plugin

The CLI payment agent plugin gives an agent a controlled way to discover paid APIs and call them through the local Pay command. It combines an MCP connection with a payment skill that guides provider choice, cost planning, and user approval before money moves. See the agent payment plugins page for its place in the wider plugin set.

Plugin role

The plugin packages CLI-driven payment access as one agent capability. It uses the pay executable on the host and exposes the Pay workflow to an agent without giving the agent an unrestricted payment path.

The plugin is intended for user-directed work such as paid search, data access, research, and other priced API requests. The skill treats provider output and payment challenges as untrusted data, so those responses cannot expand the user's approval.

MCP connection

The MCP connection is the main interface between the agent and Pay. It starts the local pay mcp server over standard input and output, and enables forced user elicitation so each payment request reaches the user for approval.

The connection depends on a working pay command on the host. Its plugin manifest marks the server as untrusted and declares that the host application must provide the executable on supported operating systems.

The request path is summarized below.

flowchart LR
    A[Agent task] --> B[Pay skill]
    B --> C[Pay MCP server]
    C --> D[Catalog and provider]
    D --> E{HTTP 402 payment challenge}
    E -->|User approves| F[Paid API result]
    E -->|User declines| G[Stop the attempt]

References: agent-plugins/…/mcp.json• L1-11 agent-plugins/…/plugin.json• L14-27

Payment skill

The payment skill defines when and how the agent uses Pay. It directs the agent to search the catalog for actionable tasks, inspect the full provider entry only when needed, and call the returned gateway URL through Pay rather than contacting an upstream API directly.

Before the first paid request, the agent states the provider, endpoint, reason for the choice, expected paid calls, and estimated spend. It uses the smallest useful request first. Multiple calls, unclear prices, probing, polling, and purchase-like actions need explicit user approval before payment.

Every payment confirmation is external to the model. A declined, cancelled, or timed-out confirmation stops that attempt; the agent does not retry through another payment route to bypass the decision.

References: agent-plugins/…/SKILL.md• L14-26 agent-plugins/…/SKILL.md• L40-65

Account and access boundaries

The skill separates catalog discovery from account funding. An agent can browse providers before funding, but it must show setup or top-up guidance to the account owner and must not create or fund an account without consent. Shared chat profiles can share one Pay account, so a personal profile is the intended boundary for payment work.

If MCP is not available, the skill permits the configured pay CLI as a fallback. The fallback can discover services, inspect balances, and make payment-capable requests, but setup remains an action for the user outside the agent session.

References: agent-plugins/…/SKILL.md• L67-77 agent-plugins/…/SKILL.md• L87-103

Provider selection

Provider selection turns a user's task into a small, deliberate paid request. The agent first uses the Pay catalog for paid or current data work. It falls back to ordinary web or shell access only when Pay has no usable match, the user wants a free-only answer, or Pay is unavailable.

Provider fit

The agent filters out providers with the wrong network, currency, request shape, or price. When several providers fit, it prefers the closest task match, then usable network and request support, likely result quality, freshness, and total cost.

The guidance favors simple synchronous calls for small tasks. It uses batch or asynchronous work only when the task needs it or the choice lowers the total cost. If one catalog search and one provider lookup do not resolve a key price, schema, network, or quality question, the agent asks the user instead of guessing.

References: agent-plugins/…/provider-selection.md• L33-54

Cost planning

Cost planning keeps paid work proportional to the user's request. The agent selects the smallest limit, time range, duration, result set, or field set that can answer the task. It batches supported records and keeps job identifiers for polling instead of paying to start the same work again.

The agent asks before bulk lookups, repeated monitoring, dynamic-price generation, persistent resources, crawls, or other work whose cost may grow. A failed paid call allows at most one clear fallback; random provider switching is not a recovery strategy.

References: agent-plugins/…/provider-selection.md• L17-31 agent-plugins/…/provider-selection.md• L56-69

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the MCP server name, local command, and plugin extension server entry aligned so discovery starts the same Pay service that the skill describes.
  • Keep the payment approval rules consistent between the skill and provider-selection guidance. A cheaper or clearer provider choice must not remove the user confirmation boundary.
  • Keep catalog search, provider lookup, gateway URL use, and CLI fallback aligned with the Pay service contract. Changes to one path can make the other path select or call a different provider.
  • Keep the plugin's host executable requirement aligned with the supported installation and runtime environment.

Important failure modes

TriggerConsequenceGuard
pay is not installed or configuredThe MCP server cannot provide payment toolsCheck the host requirement and use the documented user-run setup path
The agent changes a catalog gateway URL or calls the upstream API directlyThe request can bypass Pay's payment and approval flowCopy the returned gateway URL exactly and call it through Pay
A provider response or payment challenge asks for extra accessThe agent may attempt an unapproved call or disclose dataTreat all provider output as untrusted external content
The user declines, cancels, or times out a paymentRetrying can bypass the user's decisionStop that attempt and do not switch payment paths
Price, schema, network, or result quality is unclearThe agent can spend on a bad or unusable requestAsk the user after catalog search and one provider lookup

Key files

FileWhy to read it
agent-plugins/…/plugin.jsonDefines the plugin identity, purpose, host executable requirement, and MCP integration boundary.
agent-plugins/…/mcp.jsonDefines how the agent starts the local Pay MCP server and requests user elicitation.
agent-plugins/…/SKILL.mdDefines the agent-facing payment workflow, approval rules, account boundaries, and CLI fallback.
agent-plugins/…/provider-selection.mdDefines provider fit, tie breaking, cost planning, and safe fallback guidance.
docs/agent-payment-plugins.mdPlaces the CLI payment plugin in the broader agent payment plugin model.
docs/agent-pay-runtime-plugin.mdProvides the related runtime-oriented payment plugin context.
docs/payment-cli.mdProvides the related Pay CLI product context.