Enables automatic X402 payment processing using Solana wallets on devnet, with support for checking wallet balances, tracking payment history, and setting spending limits for paid web requests.
AI42 MCP Server
X402 Payment MCP Server for Claude Desktop
Quick Start • Features • Installation • Usage
Overview
AI42 MCP Server enables Claude Desktop to automatically handle web requests with X402 payments. Fetch data from any URL and seamlessly process cryptocurrency payments when required (402 status). Includes payment tracking, balance checking, and spending limits.
Features
Automatic Payment Handling: Transparent X402 payment processing on 402 responses
GET & POST Support: Full HTTP method support for API interactions
Payment Management: Track history, check balance, set spending limits
Solana Integration: Built on Solana devnet/mainnet
Type-safe: Full TypeScript support
Zero Configuration: Works out of the box with Claude Desktop
Available Tools
Tool | Description |
| Fetch data from URLs with automatic payments |
| Check wallet SOL balance |
| View all payments made during session |
| Set maximum spending limit per request |
Installation
Prerequisites
Node.js 18+
Solana wallet private key (base58 format)
Claude Desktop
Quick Install
No manual installation needed! Just configure Claude Desktop:
Add to
Windows:
macOS:
Linux:
Config File Locations
Platform | Path |
Windows |
|
macOS |
|
Linux |
|
After adding config: Restart Claude Desktop!
Quick Start
Getting Your Private Key
Generate Solana Keypair:
Export Private Key (base58 format):
⚠️ Never commit private keys to version control!
First Request
Once configured and Claude Desktop is restarted, simply ask:
Usage
Example Conversations
Fetch Data from URL
Fetch with Payment
POST Request
Check Balance
Set Payment Limit
View Payment History
Tool Reference
1. fetch-with-payment
Fetch data from any URL with automatic payment handling.
Parameters:
url(string, required): URL to fetchmethod(string, optional): HTTP method - "GET" or "POST" (default: "GET")body(string, optional): JSON string for POST requests
Returns:
Example:
2. get-balance
Check current SOL balance in your wallet.
Parameters: None
Returns:
Example:
3. get-payment-history
View all payments made during the current session.
Parameters:
limit(number, optional): Maximum records to return (default: all)
Returns:
Example:
4. set-payment-limit
Set maximum spending limit per request. Set to 0 to remove limit.
Parameters:
limit(number, required): Maximum SOL amount (0 to remove)
Returns:
Example:
How It Works
The X402 Payment Flow
Request: Claude makes a request to a URL
402 Response: If the endpoint requires payment, it returns HTTP 402
Automatic Payment: The MCP server automatically processes the payment using your Solana wallet
Retry: The request is retried with payment proof
Success: Data is returned to Claude
Payment Tracking
All payments are logged in-memory during the session
Track amounts, recipients, timestamps, and transaction signatures
View history anytime with
get-payment-history
Spending Limits
Set a maximum amount per request to prevent overspending
Requests exceeding the limit are automatically rejected
Remove limits by setting to 0
Advanced Usage
Testing with MCP Inspector
For development and debugging:
This opens a web UI where you can:
See all registered tools
Test tool calls with custom inputs
View request/response JSON
Debug payment flows
Environment Variables
If running locally (not via npx in Claude config):
Network Configuration
Currently supports:
Solana Devnet (default): For testing with test SOL
Solana Mainnet: For production (update in source)
Security Best Practices
Private Key Safety
✅ DO:
Store private keys in environment variables
Use separate wallets for testing (devnet) and production (mainnet)
Set reasonable payment limits
Regularly check payment history
❌ DON'T:
Commit private keys to git
Share private keys in chat or screenshots
Use production wallets without payment limits
Ignore payment history
Payment Limits
Recommended limits based on usage:
Use Case | Recommended Limit |
Testing | 0.01 SOL |
Light Usage | 0.1 SOL |
Regular Usage | 0.5 SOL |
Heavy Usage | 1.0 SOL |
Troubleshooting
"Bad secret key size" error
Your private key format is incorrect. Ensure it's in base58 format:
"Module not found" error
Clear npx cache and reinstall:
"Payment failed" error
Check:
Wallet has sufficient balance (
get-balance)Network connectivity to Solana RPC
Private key is valid
Payment limit not exceeded
Tool not appearing in Claude
Verify config file location and syntax
Restart Claude Desktop completely
Check Claude Desktop logs for errors
Test with MCP Inspector
Development
Local Development
Project Structure
Contributing
Contributions welcome! Please feel free to submit a Pull Request.
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Feat: Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Links
📦 NPM Package: @ai42/mcp
💻 GitHub Repository: ai42-mcp
📖 X402 Protocol: x402.org
🔧 MCP SDK: @modelcontextprotocol/sdk
License
MIT License - see LICENSE file for details
Acknowledgments
Built with:
X402 Protocol - HTTP 402 payment standard
x402-fetch - Payment wrapper for Node.js
Model Context Protocol - MCP SDK
@solana/web3.js - Solana blockchain interaction
Made with ❤️ by keyaru