A2A x402 Guard MCP
Fail-closed x402 Base/Solana USDC payee-binding, integer atomic-unit & SQLite WAL replay guard
Documentation
a2a-x402-guard-mcp
a2a-x402-guard-mcp (v1.0.0) is a zero-dependency (dependencies = [], 100% Python >= 3.10 stdlib) deterministic security guard for x402 HTTP 402 Micropayments, A2A AP2 (Agent Payments Protocol) Mandates, Integer Minor-Unit Spend Caps, and S4-REJECT-005-Safe A2A v1.0.1 agent-card.json Signing, packaged as a 1-click .mcpb desktop bundle (< 50ms cold boot).
Autonomous agents interacting with paid HTTP 402 endpoints or A2A AP2 merchants face five concrete failure modes: IEEE-754 floating-point rounding drift (0.1 + 0.2 != 0.3), rogue/spoofed ERC-20 or SPL token contracts in PAYMENT-REQUIRED challenges, EIP-3009 authorization replay or unbounded validBefore windows, tampered CartMandate line-item totals, and broken agent-card.json JWS signatures caused by placing "x402" at the ProtoJSON top level (S4-REJECT-005). a2a-x402-guard-mcp eliminates all five deterministically with zero external pip dependencies.
Core Engineering Capabilities
- Multi-Chain CAIP-2
x402Header Forensics: Parses and auditsPAYMENT-REQUIRED,X-PAYMENT, andPAYMENT-SIGNATUREheaders (JSON, base64, and base64url) acrosseip155:8453(Base Mainnet USDC EIP-3009TransferWithAuthorization),eip155:84532(Base Sepolia USDC),solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp(Solana USDC & SOL), andstacks:1(sBTCSIP-010). SPEC_CLASS_09100% Integer Minor-Unit Spend Gate: Strictly rejectsfloatinputs and negative slippage (slippage_bps < 0), computes exact integer basis-point fees (net_minor = amount_minor * (10000 - fee_bps) // 10000), enforcesmax_per_tx_minoranddaily_cap_minor, and blocks nonce replays via stateless sets or an atomic thread-safe SQLite WAL ledger (BEGIN IMMEDIATE).- Pure-Python AP2
IntentMandate&CartMandateVerifier: Verifies ISO-4217 and crypto minor-unit exponents (0JPY/VND,2USD/EUR,3KWD,6USDC,8sBTC,9SOL,18WEI), line-item sum conservation,human_confirmation_threshold_minor, and pure-Python RFC 8032 Ed25519 + RFC 8785 JCS signatures. S4-REJECT-005-Safe A2Av1.0.1agent-card.jsonScaffolder: Emits spec-compliant HTTP 402PAYMENT-REQUIREDheaders alongside an Ed25519-signed/.well-known/agent-card.json+/.well-known/jwks.jsonbundle that embedsx402andAP2metadata insidecapabilities.extensions[]andskills[]soa2a-python,@a2a-js/sdk, anda2a-goProtoJSON JWS verifiers agree bit-for-bit.SPEC_CLASS_14Settlement Webhook & DLP Guard: Verifies facilitator webhooks with constant-timehmac.compare_digest(HMAC-SHA256) orEd25519, deduplicatesidempotency_key, and automatically redacts accidental API keys, secrets, and payment card digits.
Quick Install
Option 1: 1-Click .mcpb Bundle (Claude Desktop)
Download a2a-x402-guard-mcp.mcpb from the v1.0.0 Release and open it in Claude Desktop (manifest_version: "0.3", zero pip install step).
Option 2: Zero-Install uvx Prebuilt Wheel CLI & MCP Server
# Works immediately with zero install (0 external dependencies)
uvx --from https://github.com/khoap1220-hue/a2a-x402-guard-mcp/releases/latest/download/a2a_x402_guard_mcp-1.0.0-py3-none-any.whl a2a-x402-guard-mcp selftest --json
claude mcp add a2a-x402-guard -- uvx --from https://github.com/khoap1220-hue/a2a-x402-guard-mcp/releases/latest/download/a2a_x402_guard_mcp-1.0.0-py3-none-any.whl a2a-x402-guard-mcp-server
Option 3: MCP Client Configuration (claude_desktop_config.json / Cursor / VS Code)
{
"mcpServers": {
"a2a-x402-guard": {
"command": "a2a-x402-guard-mcp-server",
"env": {
"X402_DEFAULT_MAX_TX_USDC_ATOMIC": "5000000"
}
}
}
}
6 Deterministic MCP Tools (readOnlyHint = True)
| Tool | Purpose & Enforced Invariants |
|---|---|
x402_inspect_payment_header | Audits PAYMENT-REQUIRED, X-PAYMENT, and PAYMENT-SIGNATURE headers across Base, Base Sepolia, Solana, and Stacks; flags IEEE-754 floats, rogue token contracts, payee mismatches, expired validBefore, and future validAfter. |
x402_enforce_spend_policy | Enforces SPEC_CLASS_09 integer-only minor-unit math, fee_bps, slippage_bps >= 0, per-tx & daily spend ceilings, CAIP-2/payee allowlists, and stateless or SQLite WAL idempotency_nonce replay locking. |
ap2_verify_cart_mandate | Verifies A2A AP2 IntentMandate & CartMandate line-item integer sums, currency exponents (0/2/3/6/8/9/18), TTL expiry, human confirmation gates, and pure-Python RFC 8032 Ed25519 + RFC 8785 JCS signatures. |
x402_scaffold_agent_card_extension | Generates HTTP 402 PAYMENT-REQUIRED JSON/base64 headers and an S4-REJECT-005-compliant Ed25519-signed /.well-known/agent-card.json + /.well-known/jwks.json deployment bundle. |
x402_convert_atomic_units | Exact Decimal string <-> integer minor/atomic unit converter (USD, EUR, VND, JPY, KWD, USDC, sBTC, SOL, WEI) with SUB_ATOMIC_DUST_REJECTED rounding protection. |
x402_verify_settlement_webhook | Constant-time hmac.compare_digest / Ed25519 webhook signature verifier with replay-window enforcement, idempotency_key deduplication, and SPEC_CLASS_14 DLP secret/PAN scrubbing. |
Built-in Prompts & Reference Resources
- Slash Prompts (
3):audit-402-payment-challenge,verify-ap2-cart-mandate,add-x402-pricing-to-agent-card - Resources (
2):x402-guard://spec/caip2-assets-and-decimals— Canonical Base/Sepolia USDC, Solana USDC/SOL, Stacks sBTC asset descriptors & minor-unit exponents.x402-guard://checklists/spec-class-09-payment-invariants— Production payment security invariants, linked to khoaphan.dev/a2a-iq/ and khoaphan.dev/webhooks/.
Engineering & Support Workflow (Transparent Written-First A2A Operation)
Maintained by Khoa Phan via an open, transparent A2A (AI-Orchestrated Senior Engineering) workflow:
- 100% Written Asynchronous Communication: All bug reports, integration specifications, and custom security engagements operate strictly via written channels (GitHub Issues, Pull Requests, and written async briefs at khoaphan.dev/services/ — zero live meetings) backed by deterministic Code-First PoCs and automated
pytestsuites. - Interactive Benchmarks & Guides: Explore live A2A v1.0.1 conformance benchmarks at khoaphan.dev/a2a-iq/ and webhook hardening patterns at khoaphan.dev/webhooks/.
License
MIT © 2026 Khoa Phan.