What you’ll build
An MCP server that wraps x402-paid endpoints as tools. The AI client types a natural-language prompt, each tool call triggers a paid x402 request, and settlement is visible on Stablescan. The user never sees a wallet prompt.Demo
tx values are visible on https://stablescan.xyz.
Agent wallet funding: The MCP server signs payments with a seed phrase you control. Fund that wallet with USDT0 on mainnet before starting the server. A balance of at least
$0.10 covers several paid calls; $1.00 is plenty for extended testing. Top up as needed using a standard USDT0 transfer to the wallet’s address.Overview
MCP Server:Prerequisites
- A running x402 server (see Build a pay-per-call API).
- An MCP-compatible AI client (Claude Desktop, Claude Code, etc.).
Step 1: Create the MCP server
The MCP server acts as a bridge between AI clients and x402-enabled APIs. Each tool makes a paid request using the x402 client SDK and returns the result.fetchWithPayment, which handles the full x402 payment cycle automatically. The AI client only sees the tool name, description, and parameters.
Step 2: Configure your AI client
Add the MCP server to your AI client’s configuration. Claude Desktop (claude_desktop_config.json):
Step 3: Type the prompt and use it
Once configured, the AI client can call paid APIs through the user’s prompt: User: “Pull financials for ACME Corp and assess their credit risk.”- Client calls
get_company_financials("ACME"): $0.01 paid via x402. Returns revenue, debt ratio, cash flow, etc. - Client calls
assess_credit_risk(financials): $0.05 paid via x402. Returns risk score, rating, key factors. - Client responds: “ACME Corp has a credit risk score of 72 (moderate). Revenue is stable but debt-to-equity ratio is elevated at 1.8x…”
- “Pull financials for ACME Corp” calls
get_company_financials($0.01). - “Assess credit risk for this data” calls
assess_credit_risk($0.05). - “How much USDT0 do I have left?” calls
check_balance.
Spending controls
To prevent unexpected spending, consider adding controls to the MCP server.Next recommended
Build a pay-per-call API
Set up the x402 server this MCP server bridges.
x402 concept
Review the settlement protocol behind these payments.
Develop with AI
Wire Stable’s Docs and Runtime MCP servers into the same AI client.

