HTTP-native micropayments by Coinbase. USDC on Base and Solana. Machine-to-machine payments with HTTP 402.
x402 gives your agent 10 tools it calls directly β pick the ones it needs, in Claude, Cursor, or any MCP client.
pay_request β Pay for a 402-protected resource. Sends USDC payment via x402 protocol and returns the resource content. The agent automatically handles the 402 handshake.verify_payment β Verify if a x402 payment was received and settled on-chaincreate_paywall β Create a x402 paywall configuration for an endpoint. When requests hit this endpoint, they receive HTTP 402 with payment instructions.// Your agent calls a tool directly β no glue code.
// CodeSpar's managed tier handles OAuth2, token rotation and rate limits.
const result = await session.call("pay_request", { /* ... */ });$ npm install @codespar/mcp-x402Add this entry to your claude_desktop_config.json (or any MCP-compatible client config).
{
"mcpServers": {
"x402": {
"command": "npx",
"args": [
"-y",
"@codespar/mcp-x402"
],
"env": {
"X402_API_KEY": "<your_x402_api_key>"
}
}
}
}After restart, your agent can call any of the 10 tools below β try pay_request first.
Required to authenticate the server. Stored encrypted when using CodeSpar managed hosting.
X402_API_KEYAPI key for x402
Each tool is independent β your agent loads only what it needs to reduce context and response time.
pay_requestverify_paymentcreate_paywallget_paywalllist_paywallsdelete_paywallget_balancelist_paymentsMCP is a protocol β any framework that speaks it can mount this server.