Dev.to
6/16/2026

I built an MCP server that charges AI agents per call using x402 micropayments
Short summary
The author implemented HTTP 402 micropayments (x402 protocol) to charge AI agents per MCP tool call using USDC on Base blockchain. Agents auto-sign EIP-3009 transfers without human intervention, settling within 2 seconds at ~$0.001 gas. Key lesson: flat pricing yielded zero revenue; tiered pricing by compute cost ($0.005–$0.50 per tool) is the working model.
- •HTTP 402 x402 protocol enables machine-to-machine micropayments for agent tool calls
- •Implementation uses Cloudflare Workers + EIP-3009 USDC transfers, settling in <2 seconds
- •Tiered pricing by tool compute cost outperforms flat pricing model
Generated with AI, which can make mistakes.
Is this a good recommendation for you?


