Skip to main content
X4

x402

v0.1.2API Key

HTTP-native micropayments by Coinbase. USDC on Base and Solana. Machine-to-machine payments with HTTP 402.

10 tools1 env vars๐ŸŒ GLOBALstable on npm

Install

terminal
$ npm install @codespar/mcp-x402

Quickstart

Add this entry to your claude_desktop_config.json (or any MCP-compatible client config).

claude_desktop_config.json
{
  "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.

Environment variables ยท 1

Required to authenticate the server. Stored encrypted when using CodeSpar managed hosting.

X402_API_KEY
requiredsecret

API key for x402

Available tools ยท 10

Each tool is independent โ€” your agent loads only what it needs to reduce context and response time.

WRITEpay_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.
WRITEverify_payment
Verify if a x402 payment was received and settled on-chain
WRITEcreate_paywall
Create a x402 paywall configuration for an endpoint. When requests hit this endpoint, they receive HTTP 402 with payment instructions.
WRITEget_paywall
Get paywall configuration for a specific URL
WRITElist_paywalls
List all configured x402 paywalls
DELETEdelete_paywall
Remove a x402 paywall from an endpoint
READget_balance
Get available USDC balance for x402 payments
WRITElist_payments
List x402 payment history with optional filters

Compatible frameworks

MCP is a protocol โ€” any framework that speaks it can mount this server.

Claude Agent SDKAnthropic
OpenAI AgentsOpenAI
Vercel AI SDKVercel
LangChainLangChain
LlamaIndexLlamaIndex
CrewAICrewAI
MastraMastra
Any MCP clientProtocol

Frequently asked questions

All credentials are encrypted at rest in an isolated vault scoped per organization. OAuth2 tokens are automatically refreshed before expiry. Your agent code never sees raw secrets โ€” it receives scoped, short-lived session tokens.
Servers โ€” Every LatAm commerce API your agent needs | CodeSpar