Use this when Apify mcpc is about to pay an x402 MCP server. Published mcpc signs automatically if you pass --x402; it does not yet expose a before-sign hook, so run the guard yourself before you connect or before mcpc x402 sign. This guide does not import or print a private key (mcpc x402 init / import stays on your machine, undocumented here).
curl -fsSL -o moneytools_x402_guard.py https://moneytools.dev/products/payment-safety/examples/x402-guard.py# 1. Pre-check the paid MCP server (or any x402 HTTP endpoint) before connecting.
python3 - <<'PY'
from moneytools_x402_guard import before_pay
decision = before_pay(
{"seller_url": "https://mcp.example.com/mcp", "method": "POST"},
{"payer": "0xYourAgentWallet", "max_usd": 0.05, "daily_max_usd": 1, "escalate": "high"},
)
print(decision["proceed"], decision.get("reason") or "ok")
if not decision["proceed"]:
raise SystemExit(1)
PY
# 2. Only if the hook printed True / ok, start the paid session yourself:
# mcpc connect mcp.example.com @paid --x402
# 3. For a one-off HTTP 402 you already fetched, pre-check then sign with mcpc:
# REQ=$(curl -s -D - -o /dev/null "$URL" | awk -F': ' 'tolower($1)=="payment-required"{print $2}' | tr -d '\r\n')
# python3 -c "from moneytools_x402_guard import before_pay; ..."
# SIG=$(mcpc x402 sign "$REQ" --json | jq -r .paymentSignature)
--x402-max-amount has been proposed in apify/mcpc#372 but is not in the current published README. Until it ships, use max_usd / daily_max_usd in this hook for caps, plus Pay Precheck and optional Approval Relay.Install is free. Checks are billed per call at 0.005 USDC via x402 after the live free tier (Pay Precheck: 5/IP/endpoint/day; Settle: trial 50 calls / 7 days; Approval Relay: 3/day). The guard never loads a key, never signs, and never pays MoneyTools automatically. Docs: https://moneytools.dev/products/payment-safety/