Self-hosted Next.js/TypeScript boilerplate: full OAuth 2.1 + PKCE, API key management with zero-downtime rotation, usage-based Stripe billing, and Redis rate limiting. 7 modules, 300+ tests. One-time €79, no revenue share, no platform lock-in. The metering core is free and open source on npm.
a few months ago i started building custom MCP servers on the side. the tool logic took me an afternoon; the auth and billing infrastructure took weeks. after spending four hours reading RFC 9728 at 3 AM, i ended up parking it with a static API key.
i eventually decided to build it properly using Claude Code as a pair. and yes, AI writes code insanely fast now, that’s literally how this project started. but what an LLM draft doesn't do by default is make the right architectural decisions when money is on the line. early on, the AI generated a webhook handler that returned the exact same 400 error for an invalid signature as it did for a temporary DB outage. that meant Stripe never retried the event, and billing updates vanished in silence. finding, testing, and fixing those silent failures is the actual work. generating code is cheap now; the decisions, the tests, and the edge cases someone already paid to discover are not.
you don’t have to take my word for it, though. I extracted and published the core metering logic as a standalone, free MIT package on npm (`mcp-metering`). you can install it, inspect the code, and judge the engineering quality yourself before deciding if the rest of the stack is worth €79. it’s a full proof of quality, not a stripped-down teaser.
the full boilerplate includes full OAuth 2.1 + PKCE, per-user API key management with zero-downtime rotation, usage-based Stripe billing, and Redis rate-limiting. it’s organized into 7 decoupled modules with 300+ tests. one-time payment of €79, full source code, no revenue share, no platform lock-in, and a 7-day refund policy.
would love to hear your feedback on the architecture or any of the documented trade-offs in the README!
Hey @marc_gil1 — the webhook silent-failure story in your launch note is a great flag for exactly the kind of bug that doesn't announce itself — appreciated the honesty there.
One thing I didn't see covered in the OAuth thread: how does this handle machine-only auth, where the "user" consenting is an agent acting on someone else's behalf with no human at the keyboard to click Allow? Client-credential / device-code shaped flows with no human in the loop are the case that keeps coming up as agents start initiating their own transactions.
Also curious about the runtime — the stack leans on Postgres + Redis, is this deployable on an edge runtime (Workers, etc.), or does it assume a traditional always-on Node server?
The decision to keep the metering core open source while charging for the rest is genuinely smart, basically lets people trust the math before they trust the product. Love that there's no revenue share either, feels refreshing.
The decision to ship the metering core as free open source while keeping the full stack paid is a really thoughtful move, it lets developers build trust with the hardest part before committing to the boilerplate.
The webhook story is the right thing to lead with. I shipped a Stripe integration this month where everything was green in test mode and the first real card 400'd on a currency param test mode never asked for - and separately found receipts failing silently because the send helper never throws and a try/catch was eating the reason. Money bugs don't announce themselves; you find them by walking the path with a real card and reading the logs like a skeptic.
Which is why I'd second Grace's checklist ask, and add one architectural vote: treat metering as a ledger, not a counter. Reserve before the metered call, settle exactly once keyed on the attempt, refund on failure - Gal's retry-dedupe question mostly dissolves when the settle is idempotent by construction. The counter tells you what happened; the ledger makes sure it only happened once.
Publishing mcp-metering free and inspectable is a genuinely good trust move. €79 for the edge cases someone already paid to discover is fair.
The zero-downtime API key rotation is the detail that would save the most pain in practice — keys usually get replaced when something breaks, not during planned maintenance, and any rotation downtime cascades into support tickets. The question I would ask before building on this: does the usage-based metering support different pricing tiers per API key, or is billing flat across all keys on the account? That matters when you want to give different API keys to different customer tiers without running separate instances.
The OAuth 2.1 + PKCE half is the part I'd have paid for. We ship an MCP server next to a local CLI binary, and the awkward case was authenticating a client that has no redirect target of its own — we ended up binding a loopback listener on 127.0.0.1 and handing back a http://localhost:<port>/ca... redirect URI. That took longer to get right than the billing did.
Does the boilerplate cover that non-browser client path (loopback or device code), or is it aimed at hosted MCP servers where a normal redirect URI already exists? Also curious what led you to one-time €79 with no revenue share when the metering core is already open source — that's a deliberate-looking choice.
The Stripe webhook example is a strong trust signal. For MCP servers, billing is one of those areas where AI-generated code can look complete while the edge cases quietly decide whether the product is usable.
One onboarding thing I’d want as a small builder: a checklist or test mode that proves the money path end to end — auth, metering, retry behavior, failed payments, and key rotation — before I connect a real server.
the webhook silent-failure story in your maker comment is the one that would actually keep me up at night, not the OAuth stuff everyone's asking about. on the usage-based billing side specifically: if Stripe retries a webhook (which it does on any non-2xx, including your own transient DB hiccups), does mcp-metering dedupe on the event id before incrementing usage, or is double-counting on retry something the integrator has to guard against themselves? that's the kind of bug that doesn't throw an error, it just quietly overcharges someone until they notice their invoice looks wrong
The OAuth half of this is the part I would pay for before the billing half. I connect MCP servers to my Claude setup as a user most weeks, and the pattern from that side is blunt, a server whose auth works on the first try gets used the same day, and one that fails sits unauthenticated for weeks. I have one in that exact state right now. Does your OAuth 2.1 flow cover the interactive consent dance the desktop AI clients run, or is it aimed at headless API consumers with keys?
About MCP-Billing on Product Hunt
“OAuth 2.1 + usage-based Stripe billing for MCP servers”
MCP-Billing launched on Product Hunt on July 28th, 2026 and earned 119 upvotes and 13 comments, placing #13 on the daily leaderboard. Self-hosted Next.js/TypeScript boilerplate: full OAuth 2.1 + PKCE, API key management with zero-downtime rotation, usage-based Stripe billing, and Redis rate limiting. 7 modules, 300+ tests. One-time €79, no revenue share, no platform lock-in. The metering core is free and open source on npm.
MCP-Billing was featured in API (98.5k followers), SaaS (43.4k followers), Developer Tools (516.6k followers) and GitHub (41.3k followers) on Product Hunt. Together, these topics include over 165.5k products, making this a competitive space to launch in.
Who hunted MCP-Billing?
MCP-Billing was hunted by Marc Gil. A “hunter” on Product Hunt is the community member who submits a product to the platform — uploading the images, the link, and tagging the makers behind it. Hunters typically write the first comment explaining why a product is worth attention, and their followers are notified the moment they post. Around 79% of featured launches on Product Hunt are self-hunted by their makers, but a well-known hunter still acts as a signal of quality to the rest of the community. See the full all-time top hunters leaderboard to discover who is shaping the Product Hunt ecosystem.
Want to see how MCP-Billing stacked up against nearby launches in real time? Check out the live launch dashboard for upvote speed charts, proximity comparisons, and more analytics.