Templatesx402 Monetization
x402 Monetization
An MCP server with x402 payment middleware for USDC micropayments
Monetize MCP tools with x402 using USDC micropayments on Base.
Features
- x402 payment middleware for per-tool pricing
- Free and paid tools in the same server
- Custom price overrides per tool
- USDC payments on Base (Sepolia for testing, mainnet for production)
- Example tools:
greet(paid, $0.01),hash-string(paid, $0.05),random-number(free)
Getting Started
Prerequisites
You need a wallet address to receive USDC payments.
1. Create the project
2. Environment setup
Edit .env with your wallet address:
3. Install & run
How It Works
The middleware is configured in src/middleware.ts with default pricing:
- Default price:
0.01USDC per tool call - Currency: USDC
- Network:
base-sepolia(switch tobasefor production) - Facilitator:
https://x402.org/facilitator
Making Tools Paid
Wrap tools with paid() from @xmcp-dev/x402:
Tools without the paid() wrapper are free.
Deploy
For production, update your middleware to use base instead of base-sepolia.
Learn More
Other templates
GPT Monetization with Stripe
A Next.js + MCP application for monetizing ChatGPT apps using Stripe
monetization
Auth0 Authentication
An MCP server with Auth0 authentication and tools to interact with Auth0 client.
authentication
Clerk Authentication
An MCP server with Clerk authentication, session data and organization management
authentication

