Two paths, each a few minutes. Everything runs on your own machine or your own Cloudflare account, from wallets you create for this. Not investment advice.
- Try it in one minute (no wallet, nothing paid)
- Buyer: let your AI agent pay for an API (How to pay)
- Seller: get paid by AI agents
Try it without real funds first: packages/pay-mcp/examples/bond-local runs a seller and your agent against a local mainnet fork.
See live sellers and real prices from your agent before creating any wallet. Without a wallet and without trusted recipients, pay-mcp cannot pay anything.
Claude Code:
claude mcp add a402-try \
-e X402_ALLOWED_DOMAINS=agent402-tx-receipts.agent402-ebc.workers.dev \
-- npx -y @agent402-dev/pay-mcp(Other MCP clients: command npx, args ["-y", "@agent402-dev/pay-mcp"], the same env.)
First start. The first npx run downloads the server: from pay-mcp 0.17.0 one package of about 4 MB (about 65 MB more if you add the Base add-on). On Windows with an empty npm cache it answered the MCP client in about 8 seconds. Some MCP clients give up on a server that does not answer in time; if yours reports a timeout, run this once in a terminal, then restart the client. It only downloads the package and prints the help text:
npx -y @agent402-dev/pay-mcp helpOr install pay-mcp with its buy-bonded-job skill as a Claude Code plugin: claude plugin marketplace add agent402-dev/agent402-toolkit, then claude plugin install agent402-pay@agent402. In Codex: codex plugin marketplace add agent402-dev/agent402-toolkit, then codex plugin add agent402-pay@agent402 (needs git on PATH). Cursor: manifests are in .cursor-plugin/; not in the Cursor Marketplace yet, see plugins/README.md to try one locally. The plugin starts the server with no settings, so every payment is refused. The seller and token-facts plugins are listed in plugins/README.md.
Then ask your agent:
- "Run bond_find_sellers." It reads the open seller directory and each seller's live terms: price, seller bond, deposit, delivery time, review window, and which of your settings would refuse the deal.
- "Run x402_quote on https://agent402-tx-receipts.agent402-ebc.workers.dev/x402/receipts?signatures=5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW" It shows the x402 price (0.05 USDC) and the recipient, and answers
refusedbecause no recipient is trusted yet: nothing is signed. - "Run wallet_status." It shows the limits that would apply once you add a wallet.
The two sellers in the directory today are run by the toolkit developer, and are marked so. When you want to pay for real, continue below.
Skills for agents. Each MCP server also publishes its workflow as a skill through the MCP Skills extension, so a host that supports it can load the steps and the rules when needed: skill://buy-bonded-job/SKILL.md (pay-mcp), skill://sell-bonded-job/SKILL.md (bond-seller-mcp) and skill://token-facts/SKILL.md (check-mcp). Other clients see them as plain resources.
@agent402-dev/pay-mcp is an MCP server that pays x402 APIs in USDC on Solana from a wallet on your machine. It refuses every payment until you name the domains and recipients it may pay and set limits.
1. Create a small wallet just for the agent
npx -y @agent402-dev/pay-mcp initIt writes ~/.agent402/pay-wallet.json, prints the address, and shows how to fund it. Send a few USDC and about 0.01 SOL for network fees. Keep only what you are willing to let the agent spend.
2. Connect it to your agent with your own rules
Claude Code:
claude mcp add a402-pay \
-e X402_KEYPAIR_PATH="$HOME/.agent402/pay-wallet.json" \
-e X402_ALLOWED_DOMAINS=<api host you choose> \
-e X402_TRUSTED_PAY_TO=<that API's payTo address> \
-e X402_MAX_USD=0.10 -e X402_MAX_USD_PER_DAY=1 \
-- npx -y @agent402-dev/pay-mcpOther MCP clients: same command and variables (README).
Base (optional, off by default). Per-request payments can also use USDC on Base: set X402_ALLOWED_NETWORKS=solana,base and X402_EVM_KEY_PATH; the same domains, recipients and limits apply, shared across networks (details). Agent402 Bond stays on Solana. A claude mcp add example that starts on the testnets (Solana devnet and Base Sepolia) is in the pay-mcp README.
3. Ask your agent
- "Use
x402_quoteon<url>and tell me the price and recipient." Nothing is signed. - "Fetch
<url>withx402_fetch." It pays only if every rule passes and keeps a local log (payment_history,spending_report).
To find APIs, use an x402 directory such as x402scan. The seller directory lists sellers of bonded jobs (bond_find_sellers); two of them are run by this toolkit's developer and are marked as such.
Bonded jobs (optional). For work that takes time, a seller can lock a bond in Agent402 Bond and you lock a deposit. Set X402_BOND_SELLERS and X402_BOND_MAX_USD to allow it, then use bond_v2_quote → bond_v2_start → bond_v2_result → bond_v2_accept → bond_v2_settle (details).
What does a paid API answer before payment? HTTP 402 Payment Required with the terms in the JSON body and, base64-encoded, in the PAYMENT-REQUIRED header. Shortened example from the receipts API above:
{
"x402Version": 2,
"resource": { "url": "https://agent402-tx-receipts.agent402-ebc.workers.dev/x402/receipts" },
"accepts": [{
"scheme": "exact",
"network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": "50000",
"payTo": "3re9JiNpwbf3y4c4ywT1mDRnVVHfHss14Pq2xaTaTGYH",
"maxTimeoutSeconds": 60
}]
}amount is in the token's smallest unit: USDC has 6 decimals, so 50000 is 0.05 USDC. You do not need to read this yourself; x402_quote shows it as "amountDisplay": "0.05 USDC".
What do I need? A wallet file on your machine (init above) holding a little USDC for the price and about 0.01 SOL for network fees, plus three settings: the API host in X402_ALLOWED_DOMAINS, its payTo address in X402_TRUSTED_PAY_TO, and your limits (X402_MAX_USD, X402_MAX_USD_PER_DAY). Without them every payment is refused.
In what order?
x402_quoteon the URL: price, recipient, which rule would refuse, and aquoteId. Nothing is signed.- If the recipient is the one you expect, add it to
X402_TRUSTED_PAY_TOand restart the MCP server. x402_fetchon the same URL with thatquoteId: it pays only if the amount, asset and recipient still match the quote and every rule passes, then returns the response with the settlement transaction.payment_historyorspending_reportto check what was paid.
It says refused. Nothing was signed. The reasons name the setting, for example pay_to_not_trusted (recipient not in X402_TRUSTED_PAY_TO) or a limit. With X402_CONFIRM_ABOVE_USD set, a client that cannot ask you (MCP elicitation) gets confirmation_required and nothing is paid.
Pick the shape that fits your work.
| Your work | Use | Guide |
|---|---|---|
| Answers in seconds (data, lookups, conversions) | Pay per request over x402, USDC straight to your wallet | pay-server route helper |
| Takes minutes to hours, and the buyer wants a commitment from you | Bonded job: you lock a small bond, the buyer locks a deposit, the buyer accepts and pays after delivery | Workers template |
| Done by an AI agent on your machine | Bonded job sold by your agent | bond-seller-mcp |
Selling through an agent on your machine: the bond-seller-mcp install guide for agents adds the server with no settings first, shows what is missing, and takes every price and bond value from you.
To read the sell-bonded-job skill and the seller tools before setting up a wallet, install them as a Claude Code plugin: claude plugin marketplace add agent402-dev/agent402-toolkit, then claude plugin install agent402-sell@agent402.
In Codex: codex plugin marketplace add agent402-dev/agent402-toolkit, then codex plugin add agent402-sell@agent402 (needs git on PATH). The plugin starts the server with no settings, so it cannot sell until you add yours.
Fastest path: the Cloudflare Workers template (one Worker sells both per request and bonded jobs)
-
Copy
packages/pay-server/examples/bond-seller-workerand replacecheckInput()anddoWork()with your work. A ready-made example job, CSV in and JSON rows out, is injobs/csv-to-json.ts. -
Create a new seller wallet used only for this Worker. Fund it with a little SOL (fees and deal rent, returned when deals close) and USDC for your bonds.
-
Set your terms in
wrangler.toml(PROTOCOL = "2"for Bond v2, andX402_PRICE_USDto also sell per request), then:npx wrangler secret put SELLER_KEY npx wrangler secret put RPC_URL npx wrangler deploy
-
Open
https://<your-worker>/quoteto see what buyers see. -
If you set
X402_PRICE_USD, check the per-request price the way a buyer's agent reads it, with no wallet and nothing paid:x402_quotewithPOST https://<your-worker>/x402/joband no body. See Check your own 402 without a wallet. Or from a terminal:npx -y @agent402-dev/pay-server check https://<your-worker>/x402/job --post '<example input>'. -
Optional: also take USDC on Base at the same route by setting
X402_BASE_PAY_TO,X402_BASE_FACILITATOR_URLand theBASE_RPC_URLsecret (how). Unset, nothing changes.
Get found
- Add your x402 API at x402scan (it reads your
openapi.json). - Per-request x402 routes paid in USDC on Solana mainnet: open a pull request to the pay.sh catalog (how).
- Bonded jobs (Job Protocol v1 or v2): open a pull request to the seller directory. Buyers still choose who they allow; being listed is not an endorsement.
Before real money: the Bond programs were reviewed internally and not independently audited, and have per-deal and total limits (100 / 2,000 USDC). Terms: Bond v2, Bond v1.
Factual information. Not investment advice.