Give your AI agents
a Solana wallet

x402-pay is an MCP server that lets AI agents autonomously discover, pay for, and fetch HTTP 402 paywalled resources using Solana. No human in the loop.

HTTP 402 + Solana
Agent --> x402_fetch("api.example.com/data") | +--> GET /data | 402 Payment Required | X-Payment-Amount: 1000000 | X-Payment-Token: SOL | +--> Send 0.001 SOL on Solana | tx: 5kR...confirmed | +--> GET /data + X-Payment-Signature | 200 OK + content | Agent <-- { content, receipt }
The gap

AI agents can browse the web. They can't pay for anything.

The "autonomous agent economy" has no payment rail. When an agent hits a paywall, it stops and asks a human.

The problem

AI agents can reason, write code, search the web, and call APIs. But the moment a resource costs money, autonomy ends. The agent stalls, escalates to a human, and waits. Every paid API is a dead end.

0 MCP servers

implement autonomous x402 payments

The solution

x402-pay gives any MCP-compatible agent a Solana wallet. When it encounters HTTP 402, it reads the price from response headers, sends SOL or USDC on-chain, attaches the tx signature, and fetches the content. Under 2 seconds, end to end.

< 2s

discover, pay, and fetch -- fully autonomous

HTTP 402 "Payment Required" has been reserved since 1997 but never used -- because there was no programmable money fast enough. Solana changes that.
-- x402 protocol rationale
6 tools

Everything an agent needs to operate in a paid internet

Install once, add a keypair, and your agent can pay for anything. Zero config beyond that.

x402_discover

Probe a URL for x402 payment requirements without paying. Returns paywall status, price, token, and recipient address.

read-only
x402_pay

Send a Solana payment to satisfy an x402 paywall. Auto-discovers requirements or accepts manual overrides for amount and recipient.

payment
x402_fetch

One-shot x402 flow: discover paywall, pay on Solana, fetch content. The primary tool for agents -- handles the full handshake.

primary
x402_balance

Check the agent's Solana wallet balances. Returns SOL and USDC holdings so the agent can reason about what it can afford.

read-only
x402_history

Query the local payment ledger. Shows past x402 payments with URLs, amounts, token types, and transaction signatures.

read-only
x402_serve

Register a resource behind an x402 paywall. Makes your agent a seller -- it responds with 402, verifies on-chain payment, then serves content.

seller
Quick start

Add to Claude Desktop in 30 seconds

Works with Claude, Cursor, Windsurf, or any MCP-compatible client.

claude_desktop_config.json
{
  "mcpServers": {
    "x402-pay": {
      "command": "npx",
      "args": ["x402-pay"],
      "env": {
        "SOLANA_KEYPAIR_PATH": "~/.config/solana/id.json",
        "SOLANA_RPC_URL": "https://api.devnet.solana.com"
      }
    }
  }
}

Three steps to autonomous payments

  1. Install with npm install x402-pay or use npx directly -- no global install needed.
  2. Point SOLANA_KEYPAIR_PATH at a funded keypair. Create one with solana-keygen new and airdrop devnet SOL.
  3. Ask your agent to fetch a paid resource. It calls x402_fetch, handles the 402, pays on-chain, and returns the data.
See it work

75 seconds from idea to payment

Watch an AI agent discover a paywall, pay on Solana, and fetch the content — no human in the loop.

6
MCP tools
< $0.001
per transaction
< 2s
discover to content
MIT
open source