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 payloadshandle_402_response– executes payments (push or permit)verify_payment– checksPaymentSettledV2receipts
Agent flow
- Agent A returns
402 Payment RequiredwithbuildFlexResponse. - Agent B selects an accept option and submits a router payment.
- Agent A verifies the receipt with
decodePaymentSettledEventor viabnbpay-api.
Session-aware agents
Agents can spend within SessionGuard limits by passing { sessionId, agent } context and tagging references. Use buildSessionContext to avoid drift.