MAILGENT
Mailgent Index

How AI agents pay for MCP tools
automatically.

No accounts, no API keys, no human approving a charge. An agent gets a 402, signs a USDC payment, and gets its result — in about two seconds. Here's the protocol underneath, x402, explained plainly: the handshake, what's in the receipt, why USDC on Base, and why card rails can't do this.

HTTP has always had a status code reserved for exactly this: 402 Payment Required. It sat unused for decades because there was no good way for a machine to actually pay — card rails need accounts, forms, and human approval, and they charge fixed fees that dwarf a small transaction. Stablecoins and fast L2 settlement changed that, and x402 is the protocol that wires the two together.

The result is a payment that happens inside a single request/response exchange — no redirect to a checkout, no invoice, no card. The agent asks, the server says 'that costs $0.01', the agent signs, the server settles and answers. This page traces that exchange step by step and explains the pieces around it.

The flow: 402, sign, settle

An agent calls a tool. The server responds with 402 and a challenge describing the price, the asset (USDC), the network (Base), and where to pay. The agent's x402 client signs a payment authorization for that exact amount and retries the request with the payment attached. The server verifies the signature and the amount, settles on-chain, and returns the result.

Verification is the important part: the server checks that the signed authorization matches the challenge it issued — right amount, right recipient, not replayed — before doing any work. The agent never paused for a human, and no long-lived credential changed hands. End to end, this takes roughly two seconds, dominated by Base block time.

the exchange
POST /mcp/web_search            -> 402 Payment Required
  WWW-Authenticate: x402
  { amount: "0.01", asset: "USDC", network: "base", payTo: "0x..." }

POST /mcp/web_search            -> 200 OK
  X-Payment: <signed USDC authorization>
  { results: [ ... ] }            + signed receipt

What's in the challenge and the receipt

The 402 challenge is a small, machine-readable object: the amount, the asset and network, the recipient address, and a nonce that ties the payment to this specific request so it can't be replayed against another call.

The response carries an Ed25519-signed receipt linked to the on-chain settlement transaction. For the buyer that's a verifiable spend record; for the seller it's an audit-ready log entry. Nobody has to trust a dashboard — the receipt and the chain agree, and either party can prove a call happened and was paid.

Why USDC on Base

Base is a low-fee, fast-finality Ethereum L2 with broad wallet support. Transaction fees are fractions of a cent, which is the entire reason cent-level tool pricing is viable — the network cost of settling a $0.01 call is a rounding error rather than a dealbreaker.

USDC gives both sides a stable unit of account, so a price set today means the same thing tomorrow. Mailgent settles on Base today and has more networks on the roadmap; the x402 protocol itself is network-agnostic.

Why card rails can't do this

Card networks charge a fixed fee of roughly $0.30 per transaction plus a percentage. On a $0.01 call that fixed fee is 30x the transaction — the economics are simply impossible, which is why no card-based system offers true per-call pricing for micro-amounts.

Cards also require an account, a stored credential, and (often) a human in the loop for setup and disputes. x402 removes all three: the payment is the authorization, it clears in seconds, and it costs a fraction of a cent to settle. That combination is what makes autonomous, pay-as-you-go tool use practical.

Security and spend control

Because there's no shared secret, there's nothing to leak — each payment authorizes exactly one call for a known amount. On the buyer side, the agent's x402 client enforces a per-call cap and can only spend the wallet's funded balance, so exposure is bounded by design. On the seller side, replay protection in the challenge means a captured payment can't be reused.

The net effect is a payment model where the worst case is small and contained, rather than a leaked key that grants open-ended access.

FAQ

What is x402?

An open payment protocol built on the HTTP 402 status code. A server challenges a request with a price; the client signs a stablecoin payment and retries; the server verifies, settles, and responds. It turns 'payment' into a property of an HTTP call.

How fast is settlement?

About two seconds, set mostly by Base block time. The payment happens within the request, so there's no separate checkout step.

Why not just use a credit card?

Card networks charge a fixed fee (around $0.30) per transaction plus a percentage, which makes per-call pricing for $0.01 tools impossible. USDC on Base settles for a fraction of a cent, so micro-payments actually work.

Can a payment be replayed or reused?

No. The 402 challenge includes a nonce that ties the signed payment to that specific request, so a captured authorization can't be replayed against another call.

Does the agent need an account with each tool?

No. The agent's wallet is its credential. It pays per call, so there's nothing to register or rotate per provider.

What proof do I have that a call was paid?

Every settled call produces an Ed25519-signed receipt linked to the on-chain transaction. Both buyer and seller can verify it independently against the chain.

Browse Mailgent Index.

Every tool is x402-ready — your agent pays per call.

Last updated: 2026-05-27