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
Release files for x402-mcp-server 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| x402_mcp_server-0.1.1.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| x402_mcp_server-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.9 kB
Release files / x402_mcp_server-0.1.1.tar.gz
| Download URL | x402_mcp_server-0.1.1.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64263edefbbf7f7cfaa8c2464ec23ec566635abe2304af3d2ae1c6fff8c71cde
|
|
BLAKE2b-256 checksum How to use checksums |
6d9b3bde958ea51ca24553c68421f88a2aebd1039c4d729b2bc9e7dd824f1c0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / x402_mcp_server-0.1.1-py3-none-any.whl
| Download URL | x402_mcp_server-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ef64e6daa37fc2c48fa5ca6a3f31562c9ddbd34479640826d52389ef5e454d4
|
|
BLAKE2b-256 checksum How to use checksums |
205be4cef2c5b6437c69b5315edada5577ef7da3a77f7bb6c91c2ab62c56a534
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|