Skip to main content

x402 Payment Gateway for AI Agents — enable micropayments between agents using USDC on Solana

Project description

x402 Payment Gateway MCP Server 💰

MCP Server that enables micropayments between AI agents using USDC on Solana. Based on the x402 protocol (HTTP 402 Payment Required).

What is x402?

x402 is a protocol that lets AI agents pay for services automatically. When an agent calls a premium tool, it gets a "402 Payment Required" response with payment instructions. The agent pays via blockchain, then gets access.

Features

  • Payment Requests — Create x402-compatible payment requests for any tool
  • On-Chain Verification — Verify USDC payments directly on Solana
  • Tool Pricing — Set per-call prices for individual tools
  • Revenue Tracking — Dashboard with total revenue, per-tool breakdown
  • Payment History — Full audit trail of all transactions

Installation

pip install x402-mcp-server

Configuration

Set your merchant wallet in .env:

MERCHANT_WALLET=YourSolanaWalletAddress
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com

Usage with Claude Code

{
  "mcpServers": {
    "x402": {
      "command": "uvx",
      "args": ["x402-mcp-server"],
      "env": {
        "MERCHANT_WALLET": "YourSolanaWalletAddress"
      }
    }
  }
}

Tools

Tool Description
create_payment_request Create a 402 payment request for a tool
verify_payment Verify on-chain USDC payment
get_payment_status Check payment status
set_tool_price Set price for a tool
get_price_list View all tool prices
list_payments Payment history
get_revenue Revenue statistics

Flow

Agent A                    x402 Gateway                 Agent B (Service)
   |                           |                             |
   |-- "Use premium tool" ---->|                             |
   |                           |-- 402 Payment Required ---->|
   |<-- Payment instructions --|                             |
   |                           |                             |
   |-- USDC payment on-chain ->|                             |
   |                           |-- verify_payment ---------->|
   |                           |<-- verified ----------------|
   |<-- Access granted --------|                             |

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

x402_mcp_server-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

x402_mcp_server-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file x402_mcp_server-0.1.0.tar.gz.

File metadata

  • Download URL: x402_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for x402_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a3572a8dec3caa474dad904c5a7257701d580c0a03e9dbac46cc1f4da71c0aa
MD5 18017245d208e3476faee2f4b30b3d22
BLAKE2b-256 51400534f7b5359b55d923cb89b80394728008791ee8364864696e02dbddcdea

See more details on using hashes here.

File details

Details for the file x402_mcp_server-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for x402_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8dd8231324c39d374ad8da28642fe8252f0e1211d4cee23f3d3afc8d40bf916a
MD5 0b8bae63793cd3b70de8be5639a2757e
BLAKE2b-256 473028c5e52f4d07b442577e208d42deda3f95a782cee5be79f0e5e0771c33bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page