A demo MCP server with paid tools. Built to showcase the experimental x402 agentic payments in mcpc, the Apify-maintained MCP CLI client.
x402-mcpc-demo is an early-stage TypeScript project in the AI payments / x402 ecosystem. It currently has 0 GitHub stars and 0 forks.
A demo MCP server with paid tools. Built to showcase the experimental x402 agentic payments in mcpc, the Apify-maintained MCP CLI client.
This is a companion server for mcpc's --x402 flag.
When an AI agent calls a paid tool, mcpc automatically signs a USDC payment on Base and retries — no human needed. This server is the other side of that handshake.
402 Payment Required with on-chain payment instructions_meta signaling — tool definitions advertise payment requirements so mcpc can pay proactivelyIt's a single index.ts. Read it.
mcpc --x402 talks to this servermcpc (--x402) this server Facilitator
│ │ │
├─ tools/list ─────────────────►│ │
│◄─ free-tool, paid-tool ──────┤ (paid-tool._meta has x402) │
│ │ │
├─ tools/call paid-tool ───────►│ │
│◄─ 402 + PAYMENT-REQUIRED ────┤ │
│ │ │
│ (mcpc auto-signs payment) │ │
│ │ │
├─ tools/call paid-tool ───────►│ │
│ + PAYMENT-SIGNATURE header ├─ verify(signature) ──────────►│
│ │◄─ { isValid: true } ─────────┤
│ ├─ settle(signature) ──────────►│
│◄─ 200 + premium data ────────┤◄─ { tx: 0x… } ───────────────┤
Three things happen on a paid tool call:
402 + base64-encoded payment requirements in the PAYMENT-REQUIRED headerPAYMENT-SIGNATURE header? → Middleware decodes it and injects the payment payload into params._meta on the JSON-RPC messageWhen tools advertise pricing in _meta.x402, mcpc can proactively sign on the first request, skipping the 402 round-trip.
git clone <this-repo>
cd demo-x402
cp .env-local .env
# Set EVM_ADDRESS in .env
npm install
npm run dev
Server starts at http://localhost:4021/mcp.
mcpcnpm install -g @apify/mcpc
# Set up an x402 wallet (one-time)
mcpc x402 init
# Fund the wallet with USDC on Base Sepolia
# Connect with x402 enabled
mcpc localhost:4021/mcp connect @demo --x402
# Call the free tool — no payment
mcpc @demo tools-call free-tool name:=World
# Call the paid tool — mcpc auto-pays $0.001 USDC
mcpc @demo tools-call paid-tool query:="hello world"
That's it. mcpc sees the 402, signs payment, retries, and returns the result.
| Tool | Cost | What it does |
|---|---|---|
free-tool |
Free | Returns a greeting |
paid-tool |
$0.001 USDC | Returns premium search results — requires x402 payment on Base Sepolia |
_meta signalingTool definitions include payment info in _meta so mcpc knows what to pay before calling:
{
"name": "paid-tool",
"_meta": {
"x402": {
"paymentRequired": true,
"scheme": "exact",
"network": "eip155:84532",
"amount": "1000",
"asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"payTo": "0x…"
}
}
}
Free tools signal "paymentRequired": false. Start the server with ?nometa query param to disable _meta — payment is still enforced via the HTTP 402 middleware, but mcpc won't pre-sign.
HTTP/1.1 402 Payment Required
PAYMENT-REQUIRED: <base64-encoded JSON>
Decoded:
{
"x402Version": 2,
"accepts": [{
"scheme": "exact",
"network": "eip155:84532",
"amount": "1000",
"asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"payTo": "0x…"
}],
"error": "Payment required"
}
{
"query": "hello world",
"results": [
{ "id": 1, "title": "Premium Result A", "score": 0.97 },
{ "id": 2, "title": "Premium Result B", "score": 0.91 }
],
"metadata": {
"paymentVerified": true,
"cost": "$0.001",
"network": "eip155:84532"
}
}
Network identifiers use CAIP-2:
eip155:84532 — Base Sepolia (testnet, used here)eip155:8453 — Base Mainnet (production)EVM_ADDRESS=0x… # Required — your payment receiving address
PAYAI_API_KEY_ID=… # Optional — for authenticated facilitator access
PAYAI_API_KEY_SECRET=… # Optional — get keys at merchant.payai.network
Create a merchant account at merchant.payai.network, set your API key env vars, and switch the network from eip155:84532 to eip155:8453. No code changes needed.
npm run dev # start server with tsx
npm run lint # eslint
npm run format # prettier
mcpc — the CLI client that pays this servermcpc --x402 works under the hoodThe living ecosystem where AI agents complete tasks through workflow loops, improve through iterative execution, are evaluated by mentor agents or humans in the loop, and turn completed work into reusable work experience and data to improve future agents.
Daydreams is a set of tools for building agents for commerce
The first agentic payment network: policy-controlled, gasless, and real money-ready. OmniClaw CLI + Financial Policy Engine let autonomous agents pay and earn safely at machine speed.
Agent behavior that compiles
The A2A x402 Extension brings cryptocurrency payments to the Agent-to-Agent (A2A) protocol, enabling agents to monetize their services through on-chain payments. This extension revives the spirit of HTTP 402 "Payment Required" for the decentralized agent ecosystem.
Live data for AI agents — search, research, markets, crypto, X/Twitter. Pay-per-call via x402 micropayments.