x402 over MCP

Paid MCP tool calls work two ways on the same /mcp URL: in-band, like @x402/mcp, or over HTTP 402 headers, like OKX's CLI. How each works and how Roundlot picks.

MCP over streamable HTTP is JSON-RPC on one endpoint, so Roundlot prices each tool call, not the endpoint. initialize, tools/list and catalog never ask for payment.

In-band carrier#

  1. Call a paid tool. The result has isError: true and carries the x402 PaymentRequired object in structuredContent (and JSON-encoded in content[0].text).
  2. Sign the payment exactly as for REST.
  3. Call the same tool again with the payload in _meta["x402/payment"].
  4. The result arrives with the settlement receipt in _meta["x402/payment-response"].
JSON
{ "jsonrpc": "2.0", "id": 2, "method": "tools/call",
  "params": { "name": "quote",
    "arguments": { "symbol": "NVDA", "side": "buy", "size": "250" },
    "_meta": { "x402/payment": { "x402Version": 2, "payload": { "signature": "0x…", "authorization": { } } } } } }

This is the wire format of Coinbase's @x402/mcp, so its clients can pay Roundlot. The server side is built on OKX's @okxweb3/app-x402-core rather than @x402/mcp, which is built on a different x402 core.

HTTP carrier#

  1. Call a paid tool. The HTTP response is 402 with a PAYMENT-REQUIRED header; the body is the same JSON-RPC result.
  2. Repeat the same tools/call with a PAYMENT-SIGNATURE header.
  3. The response is 200 with the tool result and a PAYMENT-RESPONSE header.

This is what OKX's onchainos payment CLI and the OKX Agent Payments skill expect.

How Roundlot picks#

RequestCarrier
Has a PAYMENT-SIGNATURE headerHTTP
Has a payment in _meta["x402/payment"]in-band
Sends MCP-Protocol-Version (the official MCP SDKs do)in-band
Doesn't send it (OKX's CLI)HTTP
URL has ?payment=http or ?payment=metathe one you ask for

The official SDKs reject non-2xx responses, which is why they get the in-band carrier. Both carriers go through the same payment gate, so pricing, verification and "refused calls are never charged" are identical.

Shell
curl -i https://api.roundlot.0xo.in/mcp -H 'content-type: application/json' -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"quote","arguments":{"symbol":"NVDA","side":"buy","size":"250"}}}'
# HTTP/2 402 + payment-required header
Clients that can't sign.

Claude Desktop, Cursor and other MCP clients without a wallet see the price and the REST alternative in a second text block.

Last updated 25 Sep 2026

Roundlot

Pay-per-call market data and trade plans for tokenized equities on X Layer. Built for OKX Dev Day 2026.

Payments settle on X Layer testnet. Data and trade plans are X Layer mainnet. Not investment advice.