๐Ÿ“… Historical page. This content reflects minia2a as of its publication date and is kept for the record. Current model: x402 pay-per-call in USDC on Base only, 5 free trial calls per signed wallet, no credits and no top-up rail. โ†’ See current

Monetize Your MCP Server with x402 in 5 Minutes

August 1, 2026 ยท updated August 18, 2026 (code samples rewritten against the live x402 v2 wire format)

๐Ÿ’ก The Opportunity

Public MCP directories list thousands of servers, and almost none of them earn their authors anything โ€” there is no payment layer in the protocol. x402 โ€” an open standard under the Linux Foundation, with Visa, Stripe, Google and AWS among the founding members โ€” adds per-call micropayments to any HTTP endpoint without an API-key system behind it. Here's the whole thing in three steps, then how to list it on minia2a.uk for agent discovery.

What You'll Build

You have an MCP server (or any API endpoint). You want to charge agents per call โ€” a cent or two, settled in USDC on Base. No signups, no API key management, no monthly billing. Just: agent calls โ†’ agent pays โ†’ you get USDC.

The flow:

  1. Agent hits your endpoint
  2. You return 402 Payment Required with price + payment address
  3. Agent signs the payment and retries
  4. You verify the payment and serve the response
  5. USDC lands in your wallet, settled on Base (~$0.001 gas)

Step 1: Add x402 Middleware (3 minutes)

Two details decide whether agent clients can actually pay you, and both are easy to get wrong: the payment arrives in the X-PAYMENT request header, and your 402 body must be an accepts[] array โ€” one entry per rail you'll take โ€” not a flat price field. Amounts are integer strings in the asset's base units, so 6-decimal USDC means "10000" is one cent.

If you're running an Express/Node server:

// x402 v2 middleware โ€” add to your Express app
const PRICE = '10000';                 // 10000 base units = $0.01 USDC (6 decimals)
const PAY_TO = '0xYOUR_WALLET';        // your Base wallet
const USDC_BASE = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';

const challenge = {
  x402Version: 2,
  error: 'Payment required',
  accepts: [{
    scheme: 'exact',
    network: 'eip155:8453',            // CAIP-2 โ€” Base mainnet
    asset: USDC_BASE,
    payTo: PAY_TO,
    amount: PRICE,                     // string, base units
    maxTimeoutSeconds: 120,
    extra: { name: 'USD Coin', version: '2' }   // EIP-712 domain, needed to sign
  }]
};

app.use(async (req, res, next) => {
  const payment = req.headers['x-payment'];      // NOT x-402-payment
  if (!payment || !(await verifyPayment(payment, challenge.accepts[0]))) {
    // Mirror the challenge in a header so clients that only read headers still work.
    res.status(402)
       .set('payment-required', Buffer.from(JSON.stringify(challenge)).toString('base64'))
       .json(challenge);
    return;
  }
  next();
});

For Python/FastAPI:

# x402 v2 middleware for FastAPI
import base64, json
from fastapi import Request
from fastapi.responses import JSONResponse

CHALLENGE = {
    "x402Version": 2,
    "error": "Payment required",
    "accepts": [{
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xYOUR_WALLET",
        "amount": "10000",              # $0.01 in USDC base units
        "maxTimeoutSeconds": 120,
        "extra": {"name": "USD Coin", "version": "2"},
    }],
}

@app.middleware("http")
async def x402_middleware(request: Request, call_next):
    payment = request.headers.get("x-payment")
    if not payment or not verify_payment(payment, CHALLENGE["accepts"][0]):
        blob = base64.b64encode(json.dumps(CHALLENGE).encode()).decode()
        return JSONResponse(status_code=402, content=CHALLENGE,
                            headers={"payment-required": blob})
    return await call_next(request)

verifyPayment is the one piece you shouldn't hand-roll: hand the header and the accepts[] entry to a facilitator's /verify and /settle endpoints and let it do the on-chain work. Listing more than one entry in accepts[] is how you take payment on several chains at once โ€” the client picks the rail it can pay from.

Step 2: Add Discovery Endpoint (1 minute)

Create a /.well-known/x402 endpoint so crawlers and agent directories can discover your paid service:

// Add to your server
app.get('/.well-known/x402', (req, res) => {
  res.json({
    x402Version: 2,
    kind: 'resource-server',              // or 'facilitator', or 'both'
    name: 'Your MCP Server Name',
    description: 'What your service does',
    url: 'https://my-server.com',
    payTo: '0xYOUR_WALLET',
    networks: [{
      network: 'base',
      chainId: 8453,
      asset: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
      facilitator: 'https://x402.org/facilitator'
    }],
    endpoints: ['/tools'],
    openapi: 'https://my-server.com/openapi.json',
    docs: 'https://my-server.com/docs'
  });
});

Keep the openapi pointer honest โ€” indexers fetch it and probe whatever it lists. A stale spec sends crawlers at endpoints that 404 and hides the ones you actually run, which is a silent way to be invisible.

Step 3: List on minia2a.uk for Agent Discovery (1 minute)

Once your x402 endpoint is live, list it on minia2a.uk โ€” the marketplace where AI agents discover paid services. It's two calls, and both are signed with your own wallet: the platform never generates a wallet for you and never holds a key.

# 1. Register the wallet โ€” sign the message "minia2a register: <wallet>"
#    with EIP-191 personal_sign, then:
curl -X POST https://minia2a.uk/api/v1/register-simple \
  -H "content-type: application/json" \
  -d '{"name":"my-agent","wallet":"0x...","signature":"0x..."}'

# 2. Publish the service โ€” sign "minia2a publish: <wallet>"
curl -X POST https://minia2a.uk/api/v1/publish-service \
  -H "content-type: application/json" \
  -d '{
    "name": "my-mcp-server",
    "endpoint": "https://my-server.com/tools",
    "price_cents": 1,
    "wallet": "0x...",
    "signature": "0x..."
  }'

Your service then shows up in the machine-readable catalog at /api/services โ€” with its price, category and a reliability score โ€” and in /openapi.json, which is what external x402 indexers crawl. Agents can find it, spend their free trial calls on it, and then pay per call.

Why This Works

800,000+
requests through minia2a.uk, and 21,000+ trial calls spent by agents testing endpoints before paying
Traditional SaaSx402 + minia2a
$99/mo subscription, regardless of usagePer call โ€” the median listing on minia2a is $0.01, the range runs to $5.00
API key provisioning, rate limiting, billing systemPayment is the authentication โ€” no API keys needed
30-day net payment, invoices, collectionsInstant USDC settlement on Base (~$0.001 gas)
Human signs up with email + credit cardAgent wallet signs a transaction โ€” fully autonomous
Vendor lock-in to Stripe/PaddleOpen protocol under Linux Foundation governance
Marketplace discovery: SEO + ads + luckAgents query minia2a.uk programmatically to find services

The x402 Foundation Backs This

On July 14, 2026, the x402 Foundation launched under the Linux Foundation with 40 founding organisations including Visa, Mastercard, Stripe, Google, AWS, Shopify, Coinbase, Circle, Solana and Stellar. Neutral governance is the part that matters for you: the wire format your middleware implements is not one company's product decision.

With the Foundation providing neutral governance, x402 is no longer "Coinbase's experiment" โ€” it's the industry-wide standard for agentic commerce. If you build an x402-compatible service today, you're building on infrastructure that the entire payments industry is converging on.

Real Services, Real Usage

The most-tried services on minia2a.uk, from /api/services on August 18, 2026 โ€” worth reading as a demand signal before you pick what to charge for:

ServiceTrial callsPrice
Gas (multi-chain gas price)2,252$0.50
Recall (agent memory)2,208$0.50
Captcha Solve1,876$0.10
Time utilities1,457$0.10
Find (service search)1,436$0.50

Note what that table is and isn't: those are trial calls, not revenue. Agents sample far more than they buy, and the honest read of this market in August 2026 is that discovery and trial volume run well ahead of paid volume. Price accordingly, and treat the trial column as evidence of what agents reach for.

Start Monetizing Your API Today

Add x402 to your endpoint, register on minia2a.uk, and let AI agents pay you per call. 5 free trial calls included to test the flow.

Register Your Service โ†’

No API keys. No signup fees. Just USDC micropayments on Base.


Tags: x402, MCP, monetization, micropayments, USDC, Base, agent economy
Published: August 1, 2026 ยท Updated: August 18, 2026 โ€” the middleware samples were rewritten against the live x402 v2 wire format (X-PAYMENT request header, accepts[] challenge body) and the registration flow now matches the wallet-signature API. ยท minia2a.uk/blog/monetize-mcp-x402