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.1.tar.gz (6.8 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.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: x402_mcp_server-0.1.1.tar.gz
  • Upload date:
  • Size: 6.8 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.1.tar.gz
Algorithm Hash digest
SHA256 64263edefbbf7f7cfaa8c2464ec23ec566635abe2304af3d2ae1c6fff8c71cde
MD5 7f622ea928e53738d1a1e69fed0a3955
BLAKE2b-256 6d9b3bde958ea51ca24553c68421f88a2aebd1039c4d729b2bc9e7dd824f1c0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for x402_mcp_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ef64e6daa37fc2c48fa5ca6a3f31562c9ddbd34479640826d52389ef5e454d4
MD5 4c8105ad6ac28e3b69d9f022e32cdf2a
BLAKE2b-256 205be4cef2c5b6437c69b5315edada5577ef7da3a77f7bb6c91c2ab62c56a534

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