Skip to main content
Glama

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 x402 Header Forensics: Parses and audits PAYMENT-REQUIRED, X-PAYMENT, and PAYMENT-SIGNATURE headers (JSON, base64, and base64url) across eip155:8453 (Base Mainnet USDC EIP-3009 TransferWithAuthorization), eip155:84532 (Base Sepolia USDC), solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp (Solana USDC & SOL), and stacks:1 (sBTC SIP-010).

  • SPEC_CLASS_09 100% Integer Minor-Unit Spend Gate: Strictly rejects float inputs and negative slippage (slippage_bps < 0), computes exact integer basis-point fees (net_minor = amount_minor * (10000 - fee_bps) // 10000), enforces max_per_tx_minor and daily_cap_minor, and blocks nonce replays via stateless sets or an atomic thread-safe SQLite WAL ledger (BEGIN IMMEDIATE).

  • Pure-Python AP2 IntentMandate & CartMandate Verifier: Verifies ISO-4217 and crypto minor-unit exponents (0 JPY/VND, 2 USD/EUR, 3 KWD, 6 USDC, 8 sBTC, 9 SOL, 18 WEI), line-item sum conservation, human_confirmation_threshold_minor, and pure-Python RFC 8032 Ed25519 + RFC 8785 JCS signatures.

  • S4-REJECT-005-Safe A2A v1.0.1 agent-card.json Scaffolder: Emits spec-compliant HTTP 402 PAYMENT-REQUIRED headers alongside an Ed25519-signed /.well-known/agent-card.json + /.well-known/jwks.json bundle that embeds x402 and AP2 metadata inside capabilities.extensions[] and skills[] so a2a-python, @a2a-js/sdk, and a2a-go ProtoJSON JWS verifiers agree bit-for-bit.

  • SPEC_CLASS_14 Settlement Webhook & DLP Guard: Verifies facilitator webhooks with constant-time hmac.compare_digest (HMAC-SHA256) or Ed25519, deduplicates idempotency_key, and automatically redacts accidental API keys, secrets, and payment card digits.


Related MCP server: Lumière PayCheck

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: pip / uvx CLI & MCP Server

pip install a2a-x402-guard-mcp
a2a-x402-guard-mcp selftest --json

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 pytest suites.

  • 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.

Available Tools

6 tools
ap2_verify_cart_mandateA
Read-onlyIdempotent

Verify A2A AP2 (Agent Payments Protocol) IntentMandate & CartMandate envelopes: validates line-item integer minor-unit sum == total_amount_minor, ISO-4217 & crypto currency exponents (0 JPY/VND, 2 USD/EUR, 3 KWD, 6 USDC, 8 sBTC, 9 SOL, 18 WEI), payee_id binding, TTL expiry, human_confirmation_threshold_minor, and pure-Python RFC 8032 Ed25519 + RFC 8785 JCS signatures.

Inputs: mandate_json (required), jwks_json, public_key, expected_payee_id, +4 more.

x402_convert_atomic_unitsA
Read-onlyIdempotent

Exact Decimal string <-> integer minor/atomic unit converter (USD 2, EUR 2, VND 0, JPY 0, KWD 3, USDC 6, sBTC 8, SOL 9, WEI 18) with explicit SUB_ATOMIC_DUST_REJECTED rounding rejection whenever fractional sub-atomic dust is supplied.

Inputs: amount (required), currency (required), direction, allow_negative.

x402_enforce_spend_policyA
Read-onlyIdempotent

Deterministic SPEC_CLASS_09 spend-cap & integer fee-math gate (net_minor = amount_minor * (10000 - fee_bps) // 10000, strictly rejecting IEEE-754 floats and slippage_bps < 0). Enforces max_per_tx_minor, cumulative_spent_minor + amount_minor <= daily_cap_minor, allowed_payees, allowed_caip2_networks, and idempotency_nonce replay rejection (stateless batch or optional thread-safe SQLite WAL ledger).

Inputs: payee (required), amount_minor (required), caip2_network (required), idempotency_nonce (required), +12 more.

x402_inspect_payment_headerA
Read-onlyIdempotent

Parse & audit HTTP 402 PAYMENT-REQUIRED, X-PAYMENT, and PAYMENT-SIGNATURE headers (JSON, base64, or base64url JSON) across CAIP-2 networks (eip155:8453 Base USDC EIP-3009 TransferWithAuthorization, eip155:84532 Base Sepolia, solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp, stacks:1 sBTC). Flags IEEE-754 floats, zero/negative atomic amounts, expired validBefore, future validAfter, untrusted asset contracts, and payee mismatch.

Inputs: header_value (required), header_name, expected_payee, reference_unix_ts, +3 more.

x402_scaffold_agent_card_extensionB
Read-onlyIdempotent

Generate spec-compliant HTTP 402 PAYMENT-REQUIRED JSON/base64 headers and a strict S4-REJECT-005-safe A2A v1.0.1 /.well-known/agent-card.json + /.well-known/jwks.json bundle with x402 & AP2 extensions signed in pure Python (RFC 8032 Ed25519 + RFC 8785 JCS) without breaking ProtoJSON JWS verification.

Inputs: agent_name (required), description (required), price_minor (required), endpoint_url (required), +12 more.

x402_verify_settlement_webhookA
Read-onlyIdempotent

Verify x402 / facilitator settlement webhooks via constant-time hmac.compare_digest (HMAC-SHA256) or pure-Python RFC 8032 Ed25519, enforcing timestamp skew limits, mandatory idempotency_key deduplication (SPEC_CLASS_14), integer settlement math (SPEC_CLASS_09), and automatic redaction of accidental API keys, secrets, and payment card digits.

Inputs: raw_body (required), signature_header (required), scheme, ledger_db_path, +6 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 6 tools

    Disambiguation4/5

    Each tool targets a distinct phase of the payment lifecycle: policy enforcement, header parsing, mandate verification, artifact scaffolding, unit conversion, and webhook verification. Only minor overlap exists between x402_enforce_spend_policy and ap2_verify_cart_mandate, since both validate amounts, payees, and thresholds, but their inputs (transactions vs. mandate envelopes) are clearly separated.

    Naming Consistency4/5

    All six names follow a verb_noun pattern (enforce_spend_policy, inspect_payment_header, convert_atomic_units, etc.), so they are predictable and readable. The only deviation is the ap2_ prefix on ap2_verify_cart_mandate versus x402_ elsewhere, though this usefully signals the protocol family the tool handles.

    Tool Count5/5

    Six tools is well-scoped for a focused x402/AP2 guard server, and each maps to a distinct responsibility (enforce, inspect, verify mandates, scaffold, convert, verify webhooks). No tool appears redundant or vestigial.

    Completeness4/5

    The surface covers the core guard workflow: policy enforcement, header audit, mandate verification, artifact generation, unit math, and webhook verification. Minor gaps remain: there is no payer-side X-PAYMENT payload construction or signing tool, and no way to query or reset the cumulative spend ledger that x402_enforce_spend_policy maintains, but agents can work around these with the scaffolding and enforcement tools.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to discover and safely call any x402/AgentCash pay-per-call endpoint with hard budget caps, idempotency keys, spend ledgers, pre-flight cost estimation, and offline-verifiable signed receipts. Exposes search, discovery, paid-call, spend, plan, and receipt tools, plus optional hosted-account balance, recharge, and proxy tools.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to make per-call paid tool requests over HTTP 402, with request-bound payments and replay protection, while returning auditable provenance and self-checks for every answer.
      MIT