What it is
A starter kit for selling metered access to an MCP server. Your clients call your tools, and every call is billed through a Stripe Billing Meter โ with the auth, billing and safety wiring already done. It is original code written for this pack, not a resale of another boilerplate.
What is inside
- OAuth 2.1 + PKCE โ authorization-code flow (
/api/oauth/authorize,/api/oauth/token). S256 PKCE required, codes single-use and 10 minutes, refresh tokens rotate. - API keys โ
mcp_live_โฆkeys stored as SHA-256 hashes only; rotation keeps the old key valid for a 24-hour grace window. - Metered Stripe billing โ every tool call claims usage with an idempotency key, so retries never double-bill. Claims are reported to a Stripe Billing Meter and reconciled if a report fails.
- Stripe webhook dedup โ signature-verified webhooks, deduped by event id, so redeliveries never double-apply.
- Redis rate limiting โ fixed-window limiting (100 req/min per customer by default) with
Retry-After. - Supabase / Postgres schema โ one migration for customers, keys, usage events, OAuth codes/tokens and webhook events.
- 18 tests โ including the key one: 20 concurrent claims with the same idempotency key bill exactly once. Plus a README, a test report, and a single-buyer licence.
How it works โ the interface
- Set up the services (about an hour the first time). Create a Supabase project and run the included migration, create a Stripe Billing Meter named
mcp_calls, point a Stripe webhook at/api/webhooks/stripe, and add a Redis URL. Copy.env.exampleto.env.localand fill it in. - Run the tests.
npm installthennpm testโ 18 tests run with no services needed (in-memory stores).npm run typecheckandnpm run buildboth pass. - Swap in your tools. The demo endpoint (
POST /api/mcp) ships with two demo tools,pingandecho. Replace the tool handlers with your own โ the auth, rate-limit and metering wrapper stays. - Deploy to Vercel (or any Next.js host), set the same environment variables there, and your MCP server bills per call.
npm test from the included suite: 18 tests pass, 0 fail โ including the idempotency test (20 concurrent claims, one key, billed once).Requirements
- Node.js 20 or later, and
npm install. - A Supabase project (Postgres), a Stripe account, and a Redis instance (Upstash free tier works). All three are free to start; you pay those providers, not us.
- A host for Next.js (Vercel works). You self-host โ this is a code pack, not a hosted service.
Honest limits
- You self-host, and setup is required. This is a starter boilerplate, not a plug-and-play service. Budget about an hour for the first setup.
- Demo auth shortcut: the key routes and the authorize endpoint take
customerIdfrom the request so the flow can be tried without a login page. In production, take the customer from your own authenticated session โ the code comments mark every such spot. - The metering core is free as a library. The standalone metering library mcp-metering is free MIT. This pack does not copy it โ it implements the same claim-then-report pattern directly against Postgres + Stripe, because the value here is the assembled, tested wiring (OAuth, keys, webhooks, rate limits, schema). You are paying for the assembled stack, not for the idea of metering.
- Hosted alternative exists: MCP Meter (mcpmeter.com) offers hosted MCP billing at $29/month. This pack is a one-time $79 purchase โ you pay once, host it yourself, and owe us nothing per month.
- Live-service end-to-end was not run by us. The unit tests, typecheck and production build all pass; live Stripe meter reporting, live webhook delivery, live Supabase inserts and live Redis limiting need your own credentials, which did not exist at pack time. The README lists the exact setup steps.
- Single-buyer licence: use it in your own products (commercial use allowed), modify it freely; do not resell or redistribute the boilerplate itself.
Buy โ $79 one-time
One-time payment, no subscription. After paying, come back here and redeem with your PayPal transaction ID.
I already paid
Honest limits โ this purchase
- One-time payment, no subscription.
- Download token lasts 24 hours. Your download link is valid for 24 hours. Keep your PayPal transaction ID โ you need it to redeem.
- Packs are delivered as zip downloads via the gated endpoint only. There are no direct file links on this site.