| name | x402 |
| description | Set up, manage, and troubleshoot the x402 MCP payment server for Claude Code. Use when the user wants to configure x402 payments, check wallet status, manage budgets, fix MCP connection issues, or integrate paid APIs into their project. |
| argument-hint | [setup|status|budget|topup|troubleshoot] |
| disable-model-invocation | true |
| allowed-tools | Bash(node *), Read, Write, Edit, Glob, AskUserQuestion |
/x402 โ x402 Payment MCP Server Management
You are managing the x402 MCP Server โ an MCP server that gives Claude the ability to call paid APIs automatically using the x402 protocol (HTTP 402 + ERC-3009 USDC payments on Base).
Skill resources
This skill bundles supporting files. Load them when needed โ do NOT load all upfront.
Scripts are executed via Bash: node ${CLAUDE_SKILL_DIR}/scripts/<name>.mjs
What x402 MCP provides
Once configured, Claude gains 4 MCP tools:
| Tool | Purpose |
|---|
fetch_paid_api | Fetch any URL with automatic x402 payment โ probe for 402, sign ERC-3009, retry with payment header |
check_balance | Query on-chain USDC balance and wallet address |
check_price | Probe a URL's x402 pricing without paying |
discover_resources | List available paid API resources on a gateway (Bazaar protocol) |
Subcommand routing
Parse $ARGUMENTS to determine the action. Default to setup if empty.
Setup flow
Step 1: Check existing configuration
Search for an existing x402 MCP server entry in these locations (in priority order):
.mcp.json in the current project directory
~/.claude/settings.json (global user settings)
If found, display the current config (mask the private key: show first 6 + last 4 chars) and ask:
x402 MCP is already configured:
- Wallet: 0xABC...1234
- Network: Base Sepolia
- Budget: $0.01/call, $1.00/hour, $50.00 total
What would you like to do?
- Reconfigure โ start fresh
- Update budget โ change spending limits only
- Keep current โ no changes needed
If not found, proceed to Step 2.
Step 2: Choose installation scope
Ask:
Where should I configure the x402 MCP server?
- This project only (
.mcp.json) โ recommended for project-specific use
- All projects (
~/.claude/settings.json) โ available everywhere
Step 3: Wallet configuration
Ask:
To make payments on the Base network, you need a wallet with USDC.
- Use existing wallet โ paste your private key (0x...)
- Generate new wallet โ I'll create a fresh wallet (you'll need to fund it)
If generating a new wallet, run the bundled script:
node ${CLAUDE_SKILL_DIR}/scripts/generate-wallet.mjs
Show the user their private key and warn them to save it securely โ it cannot be recovered.
To derive the address (if viem is available in the project):
node -e "const { privateKeyToAccount } = require('viem/accounts'); console.log(privateKeyToAccount('<PRIVATE_KEY>').address);"
If using an existing wallet, ask for the private key. Validate it starts with 0x and is 66 characters long.
Step 4: Network selection
Ask:
Which network?
- Base Sepolia (testnet) โ free test USDC, for development. Network ID:
eip155:84532
- Base Mainnet โ real USDC, for production. Network ID:
eip155:8453
Step 5: Budget limits
Ask:
Set spending safety limits (all in USDC, leave blank to skip):
- Max per call: Maximum for a single API request (recommended:
0.01)
- Max per hour: Rolling hourly cap (recommended:
1.00)
- Max total: Lifetime total cap (recommended:
50.00)
All limits are optional. If the user skips all, warn that there are no spending guardrails.
Step 6: Write configuration
Choose the config template based on the user's environment:
-
Check if developing locally: Look for src/sdk/mcp/index.ts in the current project.
-
Replace all {{PLACEHOLDER}} values with user input from previous steps. Omit env vars that the user left blank โ do not include keys with empty string values.
-
Merge, don't overwrite: If the target config file already exists, read it first, merge the x402 entry into the existing mcpServers object, then write back. Do not clobber other MCP servers.
For ~/.claude/settings.json (global scope): same mcpServers.x402 structure nested under the global settings format.
Step 7: Verify and report
After writing the config:
- Tell the user to restart Claude Code (or run
/mcp to reload MCP servers)
- Show a summary:
x402 payment configured!
- Wallet: 0xABC...1234
- Network: Base Sepolia (testnet)
- Budget: $0.01/call, $1.00/hour, $50.00 total
- Config:
.mcp.json
Next steps:
- Restart Claude Code to load the MCP server
- Fund your wallet with USDC on Base Sepolia
- Ask me to fetch any x402 paid API โ I'll handle payment automatically
Quick test after restart:
Check my x402 wallet balance
Status check
When the user runs /x402 status:
- Read the MCP config from
.mcp.json or ~/.claude/settings.json
- If not configured, suggest running
/x402 setup
- If configured, display:
- Wallet address (derive from private key if possible, otherwise mask key)
- Network
- Budget limits
- Config file location
- Try to invoke
check_balance MCP tool if available to show live balance
Budget management
When the user runs /x402 budget:
- Read current config
- Show current limits
- Ask which limits to change
- Update the config file in place (preserve all other settings)
Top-up guide
When the user runs /x402 topup:
- Read config, extract wallet address and network
- Provide network-specific funding instructions:
Base Sepolia (testnet):
To get test USDC on Base Sepolia:
- Get testnet ETH from Base Sepolia Faucet
- Get test USDC from a USDC faucet or bridge
- Send to your wallet:
<address>
Base Mainnet:
To fund your wallet with real USDC:
- Send USDC on Base network to:
<address>
- You can bridge USDC from Ethereum/other chains via Base Bridge
- Minimum recommended: $5 USDC for testing
Troubleshooting
When the user runs /x402 troubleshoot:
Automated checks
Run the bundled validation script first:
node ${CLAUDE_SKILL_DIR}/scripts/validate-config.mjs
This checks: config file exists โ JSON valid โ x402 entry present โ wallet key format โ network ID โ budget values. Report the output verbatim.
If all checks pass but the MCP server still isn't working, run the health check:
node ${CLAUDE_SKILL_DIR}/scripts/health-check.mjs <path-to-entry-from-config>
This spawns the MCP server process and verifies it responds to an initialize handshake.
Manual checks (if scripts fail)
- Config exists? โ Read
.mcp.json and ~/.claude/settings.json. Report if x402 entry is found.
- Config valid? โ Check
command, args, COINWALL_WALLET_KEY (starts with 0x, 66 chars), COINWALL_NETWORK (valid CAIP-2).
- Entry point exists? โ Verify the file path in
args resolves to an existing file.
- Dependencies? โ Run
node -e "require('@modelcontextprotocol/sdk')" etc.
Common issues
| Symptom | Cause | Fix |
|---|
| "COINWALL_WALLET_KEY is required" | Missing env var in MCP config | Add COINWALL_WALLET_KEY to the env section |
| MCP server not showing up | Config not loaded | Restart Claude Code or run /mcp |
| "insufficient_balance" on every call | Wallet has no USDC | Run /x402 topup for funding instructions |
| "budget_exceeded" | Spending limit hit | Run /x402 budget to adjust limits, or wait for hourly window reset |
| "payment_failed" | Server rejected payment | Check network matches the API's expected network |
| Tool calls timeout | MCP process crashed | Check args path is correct, try running the entry point manually |
Report all findings with pass/fail status and actionable fixes for any failures.
Environment variable reference
| Variable | Required | Default | Description |
|---|
COINWALL_WALLET_KEY | Yes | โ | Wallet private key (0x...) for ERC-3009 signing |
COINWALL_NETWORK | No | eip155:84532 | CAIP-2 network ID (Base Sepolia or Base Mainnet) |
COINWALL_MAX_PER_CALL | No | unlimited | Max USDC per single API call |
COINWALL_MAX_PER_HOUR | No | unlimited | Max USDC per rolling hour window |
COINWALL_MAX_TOTAL | No | unlimited | Max USDC lifetime total |
COINWALL_RPC_URL | No | public Base RPC | Custom RPC endpoint for balance queries |