buy — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited buy (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
This skill sets up the buyer side of the x402 payment protocol. It configures an AI agent (or any HTTP client) to automatically detect 402 Payment Required responses, pay on-chain in USDC on Solana, and retry the request with proof of payment — all transparently.
Result: The user's AI agent or script can call any x402-gated API and auto-pay.
ag402 serve gateway from the buyer sideCheck that ag402 is installed. Only speak if something is missing.
ag402 --versionIf this fails:
pip install ag402-coreFor AI tool integration (MCP), also install:
pip install ag402-client-mcpIf the user is present and can interact with the terminal, ask them to choose:
ag402 upgradeFor option A (vast majority of users), run:
ag402 setupag402 setup is an interactive wizard with prompts (password input, confirmations). Let the user run it directly — do not try to automate or pipe input to it.
If you are operating autonomously (no human in the loop), use ag402 init instead:
ag402 initag402 init is non-interactive — it creates a test wallet and deposits $100 USDC with zero prompts. This is the correct command for AI agents acting autonomously.
After either command, verify:
ag402 balanceExpected: shows $100.00 test balance.
For option B, start with option A first (test mode), verify everything works, then upgrade:
ag402 upgradeag402 upgrade is also interactive (private key input, password, daily limit). Let the user run it directly.
Ask the user how they want to use ag402:
ag402 pay (simplest, test a single endpoint)ag402 install (MCP integration)ag402 run or the SDKThe simplest way to test. Point ag402 pay at any x402 gateway:
ag402 pay <gateway_url>Example:
ag402 pay http://127.0.0.1:4020/weather?city=TokyoWhat happens (the CLI shows every step):
402 Payment Required200 OK + dataIf the user doesn't have a gateway to test against, they can start one locally first:
ag402 serve &
sleep 3
ag402 pay http://127.0.0.1:4020/For Claude Code, Cursor, or OpenClaw — ag402 provides an MCP server that gives the AI tool a fetch_with_autopay tool.
Ask the user which tool:
ag402 install claude-codeag402 install cursorag402 install openclawag402 install claude-desktopRun the install command:
ag402 install <tool>After install, tell the user:
fetch_with_autopay tool will appear in the AI toolTo verify the MCP server works:
ag402 mcp --sse --port 14021This starts the MCP server on SSE transport. If it starts without errors, the MCP integration is working. Stop it with Ctrl+C — the AI tool will manage the server lifecycle from now on.
For users who want auto-pay in their own Python code.
Option 1: Wrap with `ag402 run` (zero code changes):
ag402 run -- python my_agent.pyThis injects ag402_core.enable() via sitecustomize.py, so all urllib/httpx/requests calls that receive 402 will be auto-paid. Works for any Python script.
Option 2: SDK in code (explicit):
import ag402_core
ag402_core.enable()
# Now any HTTP request that gets 402 will be auto-paid
import httpx
response = httpx.get("http://gateway:4020/data")
# response is 200 — payment happened transparentlyAfter any integration mode, confirm the system works.
ag402 balanceExpected: shows a positive balance (e.g., $100.00 in test mode).
ag402 pay <gateway_url>Expected: shows the full 402 → pay → 200 flow with no errors.
ag402 historyExpected: shows the transaction just made, with amount, target, and status.
If all three pass, tell the user: "Your agent is ready to pay for API calls!"
Ask the user:
ag402 balance, ag402 history, ag402 config ag402 env set X402_DAILY_LIMIT 10 # max $10/day (default)
ag402 env set X402_PER_MINUTE_LIMIT 2 # max $2/minute
ag402 env set X402_PER_MINUTE_COUNT 5 # max 5 tx/minuteag402 upgrade (interactive)ag402 doctor| Error | Cause | Fix |
|---|---|---|
ag402: command not found | Not installed | pip install ag402-core |
ag402-client-mcp not installed | Missing MCP package | pip install ag402-client-mcp |
Insufficient balance | Wallet empty | ag402 setup to get test funds |
Cannot connect to <url> | Gateway not running | Check the gateway URL is correct and reachable |
Non-standard 402 response | Server returns 402 but not x402 | Not an x402 API — ag402 can only auto-pay x402-compatible gateways |
On-chain payment failed | RPC / network issue | Check internet; for localnet: solana-test-validator --reset |
Request timed out | Gateway or RPC slow | Retry; check ag402 doctor for RPC connectivity |
| MCP tool not appearing in AI tool | Config not written or tool not restarted | Re-run ag402 install <tool> and restart the AI tool |
ag402 upgrade or ag402 setup — STOP, explain these are the only safe places for key inputag402 history to audit transactionsFastest path — AI agent autonomous (no human needed):
pip install ag402-core
ag402 init # Non-interactive wallet + $100 test funds
ag402 pay http://127.0.0.1:4020/ # Pay for an API call
ag402 balance # Check balanceFastest path — human-guided test mode:
pip install ag402-core
ag402 setup # Interactive wizard
ag402 pay http://127.0.0.1:4020/ # Pay for an API call
ag402 balance && ag402 history # Check balance + historyFastest path — Claude Code MCP integration:
# Install
pip install ag402-core ag402-client-mcp
# Setup wallet
ag402 setup
# Install MCP into Claude Code
ag402 install claude-code
# Restart Claude Code — done. Ask Claude to call any x402 API.~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.