Skip to main content

Agents + MCP

Agents can both issue and satisfy x402 challenges by using the same SDK helpers as human clients.

MCP server

/mcp-server exposes tools that wrap SDK helpers for agents:

  • create_402_payment – builds HTTP 402 payloads
  • handle_402_response – executes payments (push or permit)
  • verify_payment – checks PaymentSettledV2 receipts

Agent flow

  1. Agent A returns 402 Payment Required with buildFlexResponse.
  2. Agent B selects an accept option and submits a router payment.
  3. Agent A verifies the receipt with decodePaymentSettledEvent or via bnbpay-api.

Session-aware agents

Agents can spend within SessionGuard limits by passing { sessionId, agent } context and tagging references. Use buildSessionContext to avoid drift.