DEV Community

UltraStarz
UltraStarz

Posted on

An MCP server that charges your AI a penny per call

I built an MCP server that lets AI agents extract structured product data from any URL — and it charges them $0.01 USDC per call, automatically, with no API key. The whole thing went from idea to public-on-npm in 36 hours.

Demo: Claude Desktop calling extract_product, paying 0.01 USDC, returning structured Product JSON

If you have Claude Desktop, Cursor, or Windsurf, you can install it right now:

{
  "mcpServers": {
    "x402-extract": {
      "command": "npx",
      "args": ["-y", "x402-extract-mcp"],
      "env": {
        "BUYER_PRIVATE_KEY": "0x..."
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Restart your client. Ask your agent:

Extract this product page: https://stormkeep-odl.bandcamp.com/album/the-nocturnes-of-iswylm-2

You'll get back a clean JSON blob — name, brand, price, availability, all 14 format variants — and your wallet will be 0.01 USDC lighter, on-chain on Base Sepolia. No accounts, no signups, no subscriptions.

What's actually happening

The protocol behind this is x402. It uses HTTP status code 402 — "Payment Required" — which has been reserved in the spec since 1991 but never had a real use until last year. Coinbase shipped a protocol that finally puts it to work.

The handshake:

  1. Client requests /extract with no payment.
  2. Server returns HTTP 402 with a JSON body describing the cost: amount, recipient, asset, network, a nonce.
  3. Client signs an EIP-3009 USDC transfer authorization (no gas, just a signature).
  4. Client retries with the signed payload in the X-PAYMENT header.
  5. Server passes the signature to a "facilitator" which broadcasts the on-chain transfer.
  6. Server releases the response.

Total round trip: about 3 seconds on Base. The buyer never gets an API key. The seller never holds buyer credentials. Settlement is on-chain USDC. The whole "subscribe, get an API key, configure billing, hit rate limits" gauntlet just... isn't there.

Why this is interesting now

Because of agents.

When the buyer is a human dev, the friction of "create an account, paste API key, manage billing" is annoying but tractable. When the buyer is an autonomous AI agent — which increasingly it is — that friction is the whole problem. Agents can't pass captchas. They can't read confirmation emails. They can't enter credit cards. Every signup hoop breaks them.

x402 routes around all of it. The agent has a wallet. The wallet has USDC. When the agent needs data, it pays the toll and gets the data. The seller writes the same kind of code they'd write for a free API; the protocol does the billing.

Cloudflare is now serving over a billion 402 responses a day. Stripe shipped x402 on Base in February. The Coinbase Bazaar lists 69,000 active agent wallets and 165 million transactions through April. The infrastructure is real and growing fast — what's missing is interesting paid endpoints for agents to spend money on.

So I built one.

What x402-extract-mcp does

A focused, narrow product. Three steps:

  1. Agent gives it a URL.
  2. The seller renders that URL through a real headless Chromium (defeating most basic anti-bot), strips noise, and feeds the visible text to Claude Haiku with a strict schema.org/Product extraction prompt.
  3. You get back structured JSON — name, description, brand, SKU, price, currency, availability, image URLs, and a list of variants (formats, colors, sizes, whatever the page exposes).

What I think makes this useful at agent scale, vs. the dozen general scraping APIs that already exist:

  • MCP-native distribution, so any Claude Desktop / Cursor / Windsurf user can install it with one config block — no SDKs, no integration code.
  • No account, no key. The agent's own wallet pays.
  • Pay-per-call economics, not subscription tiers. An agent that runs once a week doesn't waste a $50/mo plan; an agent that runs 10K times a day pays exactly for what it uses.
  • Schema-shaped output, not raw HTML. The agent doesn't have to do its own parsing.

What it doesn't do (yet):

  • Bot-bypass on aggressively-protected sites (Amazon, Walmart, Cloudflare-shielded luxury). v2 will add residential proxies.
  • Search. You give it a URL, not a query. The companion search-and-extract endpoint is on the roadmap.
  • Image extraction. Currently returns the structured fields but not image URLs (text-only extraction strips <img src> attributes). Trivial to add; was just out of scope for v1.

The stack, end to end

Claude Desktop
  → MCP server (x402-extract-mcp on npm)
    → x402-fetch signs USDC payment with buyer wallet
      → POST /extract on Railway
        → Hono server with x402-hono middleware
          → x402.org facilitator verifies + settles on Base Sepolia
          → Playwright renders the URL
          → Claude Haiku extracts schema.org/Product JSON
        → returns JSON
      → returns JSON
    → returns to MCP
  → returns to Claude Desktop
Enter fullscreen mode Exit fullscreen mode

The MCP client (what installs into Claude Desktop) is open source under MIT. The seller backend runs as a hosted service on Railway.

Try it

  1. Install the config block above into your MCP client.
  2. Get a wallet funded with Base Sepolia USDC. Generate a throwaway key, then claim from faucet.circle.com (select Base Sepolia) and a Base Sepolia ETH faucet for gas.
  3. Restart your client. Ask the agent to extract a product. Watch the JSON come back.

The on-chain transfer is visible at sepolia.basescan.org. Mainnet support is coming once Base mainnet support stabilizes in the v1 packages.

If you build something on top of this, I'd love to hear about it.

Top comments (0)