
MCPay.fun
MCPay.fun: Pay-per-use APIs! Leveraging x402 and MCP for a new payment web.
Demo
About
MCPay is a new payment layer for the internet, built for humans and autonomous agents (LLMs, bots, scripts). It enables pay-per-use API access without API keys, OAuth, or subscriptions — using only standard HTTP + crypto payments. At the heart of MCPay is the long-dormant HTTP 402 Payment Required status code. We bring it to life with x402, a spec that lets servers respond with pricing metadata. When a client (human or AI) gets a 402, they pay in stablecoins (like USDC or EUROe) and instantly retry the request. No account creation. No web forms. No checkout. Plus MCPs! We are bringing payments rails for MCP servers.
How it's made
*MCPay.fun* simplifies and modernizes API monetization by replacing traditional subscriptions with straightforward pay-per-use. It breathes life into the long-dormant **HTTP 402 Payment Required** status using the emerging **x402 protocol**, enabling seamless, machine-readable payments—perfect for LLMs, scripts, or any client that can speak HTTP. --- ## Core Philosophy — HTTP 402 for Native Web Payments * **Respond with 402, not OAuth** An API simply replies with **HTTP 402** plus pricing details rather than forcing a Stripe checkout or token exchange. * **Instant, on-the-fly settlement** The client pays (typically in a stablecoin such as **USDC**) and transparently retries the request. * **Optimized for microtransactions & M2M** Zero‐UX, machine-friendly flow lets services bill fractions of a cent without friction. ## The x402 Flow (Step-by-Step) 1. **Client request** → API 2. API (or *MCPay Proxy*) replies **`402 Payment Required`** with `{ price, currency, destination }`. 3. **`js-sdk`** intercepts the 402, signs & broadcasts payment (e.g., send 0.01 USDC on **Base**). 4. On-chain **confirmation** → `js-sdk` **retries** original request, adding proof (tx hash / signed msg). 5. Proxy/API **verifies** payment → processes request → returns data. 6. Usage & revenue events stream to dashboards/analytics (optional). --- ## Partner Tech & Why It Matters * **x402 Protocol** – open, vendor-neutral spec for native web payments. * **Layer-2 networks (e.g., Base)** – low fees make micropayments practical. * **Stablecoins (USDC)** – stable unit of account; shields users from crypto volatility. * **Viem** – modern TypeScript EVM library powering wallet & transaction logic in the SDK. --- ## Notable “Hacks” 1. **Reanimating HTTP 402** – repurposes a forgotten status code to solve API billing elegantly. 2. **CLI Proxy Adapter** – one-command wrapper adds pay-per-use to *any* API, no code changes. 3. **Invisible Payment Loop** – SDK auto-handles 402 → pay → retry, so devs integrate once and forget. --- ## Architecture Highlights * **Modular monorepo** with shared TypeScript types across frontend, backend, and SDK. * **Edge-friendly**: the CLI proxy can run at the network edge for minimal latency. * **Developer-centric**: straightforward CLI, typed SDK, and real-world examples to copy-paste.