x402 Conformance Tools

v0.1.2
io.github.DrVelvetFog/x402-conformance-mcp Checked 6 hours ago Published 14 days ago

Non-custodial x402 checks: decode 402s, verify settlements on-chain, lint specs, test facilitators.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

decode_402

Parse and validate an x402 PaymentRequired (HTTP 402) response and explain every field. Flags missing economic fields (scheme/network/asset/payTo/amount), number-typed or human-decimal amounts (must be atomic-integer strings), and missing explicit decimals. Provide ONE of: `url` (does an unpaid GET and decodes the 402), `raw` (a JSON or base64-encoded-JSON body string), or `json` (an object). Deterministic; the only network is the optional unpaid GET.

ParameterTypeDescription
jsonobjectA PaymentRequired as an object.
rawstringA PaymentRequired as a JSON string or base64-encoded JSON.
urlstringResource URL to GET unpaid; expects a 402 with a PaymentRequired body.

inspect_payment_response

Decode and validate an x402 PAYMENT-RESPONSE, surfacing success, settlement id, payer, network, and amount. Optionally recomputes the on-chain truth: pass `rpcUrl` + `expectedPayTo` for a sui:* network (queries sui_getTransactionBlock balanceChanges), or `observedBalanceChanges` + `expectedPayTo` for any chain, and it confirms the net balance change to payTo equals the advertised atomic amount (the "recomputed, not trust-the-operator" check). Provide the response via `raw` (JSON/base64) or `json`.

ParameterTypeDescription
expectedAmountstringOptional. Expected atomic amount; defaults to the response amount.
expectedAssetstringOptional. Asset/coin type to filter on (defaults to 0x2::sui::SUI for Sui).
expectedPayTostringOptional. The recipient address to sum net balance change for.
jsonobjectPAYMENT-RESPONSE as an object.
observedBalanceChangesarrayOptional. A balanceChanges array (any chain) to recompute net-to-payTo from, instead of an RPC call.
rawstringPAYMENT-RESPONSE as a JSON string or base64-encoded JSON.
rpcUrlstringOptional. Chain RPC URL; used for the on-chain net-balance check on sui:* networks.

check_compliance

Heuristically scan x402 code (a file or directory) for the high-severity classes: hardcoded chain id, hardcoded decimals, magic-number decimal scaling (10**N, 1eN, *1_000_000), human-decimal/float amounts, and literal asset/token addresses. Returns findings with file:line and severity. Heuristic — a documented default may be a false positive; every finding cites a location for human judgement. No network.

ParameterTypeDescription
path *stringA file or directory to scan.
maxFilesnumberCap on files scanned (default 2000).
maxFindingsnumberCap on findings returned (default 300).

lint_scheme_spec

Lint a draft scheme spec (markdown) against the bundled scheme_template.md: reports missing/extra template sections and whether the draft pins down the load-bearing concepts a scheme must specify (value/recipient assertion, settlement identifier, replay protection, atomic+decimals amount encoding, verify/settle flow). Reads the bundled corpus; no network.

ParameterTypeDescription
path *stringPath to the draft scheme markdown.
templatestringOptional template path relative to the plugin root (default .x402-specs/scheme_template.md).

validate_extension

Structurally validate an x402 extension payload: checks the typed { info, schema } envelope and runs light known-extension field checks (offer-and-receipt, payment_identifier, gas-sponsoring, sign-in-with-x, builder_code). Pass `payload` as a single entry (with `name`), an extensions map keyed by name, or an array. Full JSON-schema validation needs the extension’s published schema; this is the structural gate plus a spec pointer. No network.

ParameterTypeDescription
payload *An extension entry, an extensions map, or an array of entries.
namestringOptional extension name when `payload` is a single entry.

run_conformance

Drive the x402 conformance sequence against a facilitator. Holds NO keys: automates the 402 negotiation (with `resourceUrl`), facilitator reachability (GET /supported), and malformed-verify rejection. The keyed steps (verify happy-path, tampered-reject, settle, idempotent re-settle) run ONLY when you supply a pre-signed `paymentPayload` + `paymentRequirements`; settle additionally requires `allowSettle: true` (it settles real testnet value). Assumes the standard facilitator API (POST /verify, POST /settle). Returns a pass/fail/skip line per step.

ParameterTypeDescription
facilitatorUrl *stringBase URL of the facilitator (POST /verify, /settle).
allowSettlebooleanOptional. Must be true to actually settle (settles real testnet value). Default false.
paymentPayloadobjectOptional. A pre-signed payment payload (produced by your keyed SDK) to run the happy/tampered paths.
paymentRequirementsobjectOptional. The paymentRequirements the payload pays.
resourceUrlstringOptional. A payment-gated resource URL to test 402 negotiation.