x402-price-check
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
x402-price-check
An inference endpoint answers 402 Payment Required with an x402 quote. Before your agent pays it, is it a fair price? x402-price-check reads the quote, works out what it costs in USD, compares that with what justweight lists for the same model and token counts, and approves only if it's within your max premium and your agent-spendcap budget. It ships as a library, a CLI and an MCP tool.
It never pays. It holds no keys, signs nothing and never touches a chain. When a quote passes, your own wallet code makes the payment.
Page and in-browser checker: https://xbtmelchizedek.github.io/x402-price-check/
Quickstart
npx -y github:xbtMelchizedek/x402-price-check demoThe demo starts a local mock x402 endpoint, has it quote list price +10% and then 3x list, and runs both quotes through the check against today's justweight prices. The fair quote is paid with a mock payment; the other is refused before anything is sent. With the justweight snapshot of 2026-11-24 21:38 UTC:
APPROVE $0.000335 USDC on eip155:84532 (exact) vs cheapest list $0.0003042 (openrouter deepseek/deepseek-v4.1-flash; median $0.0003521 of 2), premium 10.13% (max 25%)
REJECT $0.000913 USDC on eip155:84532 (exact) vs cheapest list $0.0003042 (openrouter deepseek/deepseek-v4.1-flash; median $0.0003521 of 2), premium 200.14% (max 25%)Check a real endpoint's quote without paying it:
npx -y github:xbtMelchizedek/x402-price-check probe https://api.example.com/v1/chat/completions --body request.jsonNode 22 or later. Exit code 0 means approve, 1 reject, 2 bad input.
Related MCP server: paypulse
Which x402
Written from the spec text at x402-foundation/x402 @ 0e6e8c5 (2026-10-15):
Where the quote comes from | Spec | Field read |
HTTP | x402 v2 (Protocol Version 2, v2.0 of 2025-12-9), |
|
HTTP 402 JSON body | x402 v1, |
|
MCP tool result, |
|
|
The spec's own examples for all three are in the tests. Settlement is read from PAYMENT-RESPONSE (v2) or X-PAYMENT-RESPONSE (v1).
How the check works
Quote in USD. Each
exactoruptooption is priced only if its asset is in x402's own table of USD-pegged default assets (USDC, USDT, PYUSD and others on 32 networks; the same reverse lookup the x402 SDK suggests for client-side USD caps).amount / 10^decimals, rounded up. Anything else is left unpriced with the reason: fiat codes such asUSD, unknown tokens, and thebatch-settlementandauth-captureschemes. The cheapest priced option is the one checked.List price. The cost in justweight's snapshot for the same model at your input tokens and your
max_tokens, at the cheapest listing (default) or the median. Batch-only tiers are skipped. Without an input token count, the request's byte length stands in. A token is at least one byte, so this is an upper bound, and the premium shown is then a lower bound. Pass--input-tokenswhen you know it.Premium.
(quote − list) / list, rounded up. Over--max-premium(default 25%) is a reject. A model justweight doesn't list is a reject unless you pass--allow-unlisted.Budget. With
--max-call/--max-dayor an agent-spendcap--policy, an approved quote must also pass the policy. It then places a hold on a local ledger (mode 600) that you settle or release.
Output is always compared at your maximum output, which is the price the seller is entitled to ask. For upto, the amount is a ceiling. guardedFetch settles the hold at the amount the server reports.
Library
import { guardedFetch, PaymentRefused } from 'x402-price-check';
const res = await guardedFetch(url, { method: 'POST', body }, {
request: { model: 'deepseek/deepseek-v4.1-flash', inputTokens: 2000, maxOutputTokens: 1000 },
snapshot, // a justweight snapshot: await loadSnapshot(SNAPSHOT_URL)
cap, // optional agent-spendcap SpendCap
maxPremiumPct: '25',
pay: async ({ option, paymentRequired }) => yourWallet.paymentHeader(option), // your code; this package never signs
});
// throws PaymentRefused (with .result) before pay() is called if the quote is unfair or over budgetAlso exported:
readPaymentRequired,parsePaymentRequired,parseMcpPaymentRequiredandparseSettlementfor parsing.check(pr, request, opts)for the verdict with a budget hold.evaluatefor the pure price check, which is browser-safe.referencePrice,usdOf,loadSnapshotandSPEC.
x402-price-check/mock is the mock endpoint used by the tests and the demo. It accepts mock payments only.
MCP
{ "mcpServers": { "x402-price-check": { "command": "npx", "args": ["-y", "github:xbtMelchizedek/x402-price-check", "mcp", "--max-day", "1"] } } }The server exposes four tools:
x402_price_check({ quote, request | body, maxPremiumPct?, reference? }).quotecan be the header value, the v1 body, the PaymentRequired object or the whole MCP tool result.x402_settleandx402_releasefor holds.x402_budget.
CLI
x402-price-check demo
x402-price-check check --quote <file|base64|-> (--body req.json | --model <id> --max-tokens <n> [--input-tokens <n> | --prompt-file <f>])
x402-price-check probe <url> --body req.json
x402-price-check status | settle --id <hold> --usd <paid> | release --id <hold>
x402-price-check mcpOptions: --max-premium <pct>, --reference cheapest|median, --allow-unlisted, --max-call <usd>, --max-day <usd>, --policy <file>, --ledger <file> (default ~/.x402-price-check/ledger.jsonl), --snapshot <url|file>, --json.
Limits
USD-pegged assets only. The table is x402's own list of defaults. A quote in another token is not converted at a market rate; it is refused with the reason.
List price is not a guarantee. justweight lists what venues publish. A seller may add real value, such as privacy, latency or no account, which is what
--max-premiumis for.Token counts are yours to give. The quote doesn't say how many tokens it covers, so the comparison assumes your
max_tokens.Not a payment client. No
PAYMENT-SIGNATUREorX-PAYMENTis made here except the mock one in tests and the demo. Pair it with an x402 client that signs.
Part of the agent inference kit
x402-price-check is one of a set of small tools for agents that pay for inference. Each does one job, and they work together. The full list is sorted by job, with a one-line command and a live number for each: https://xbtmelchizedek.github.io/agent-inference-kit/. Its source is kit.json, so adding a tool takes one change there.
Develop
git clone https://github.com/xbtMelchizedek/x402-price-check && cd x402-price-check
npm install && npm test
node scripts/sync-assets.mjs /path/to/x402 # refresh src/assets.json from an x402 checkout35 tests, using the mock endpoint and mock payments only: no network, no keys, no chain. Dependencies: agent-spendcap and justweight. See CONTRIBUTING.md and SECURITY.md.
MIT, with x402 data under Apache-2.0 (see NOTICE). The page uses Arc UI foundation tokens (MIT, see web/arc/LICENSE).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Call before signing an x402 payment: advisory budget check, 0.005 USDC/call
Governed agent execution: x402 payments, budgets, receipts, verification, and audit.
Find and quote agent capabilities, then pay only the selected x402 execution URL.
402xAgent is the check an agent calls before paying any x402 endpoint. It probes the endpoint's 402 without paying and returns a pay / skip / recheck verdict with a reason. Every check leaves a public receipt. It never pays the target.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceRead-only MCP server that performs deterministic local preflights of agent-payment boundary documents and x402 v2 PaymentRequired JSON, and prepares unsubmitted public quote-request drafts without network calls or fund movement.1-
- AlicenseNot gradedqualityCmaintenanceEnables agents to list, preview, confirm, and pay for HTTP resources via x402, while providing a payment ledger and Binance account/market-data context.MIT
- AlicenseAqualityAmaintenanceEnables agents and developers to check x402 endpoints, assess scores and wallet risks, authorize payments with spending rules, and report outcomes before an agent pays.62MIT
- AlicenseBqualityAmaintenanceEvaluates proposed x402 payments against a local policy and returns pay, review, or do_not_pay, while also listing and evaluating outstanding authorizations to flag double-pay or limbo risk.56MIT