
Mcp Pay Gate
io.github.zekebuilds-labPublished by GitHub account zekebuilds-labv0.2.0Updated Oct 25, 2026
Dual-rail Lightning paywall for MCP servers: accepts L402 and x402 bip122/exact, one LNBits backend.
Overview
Express middleware that adds a dual-rail Lightning paywall (L402 and x402 bip122/exact) to MCP server endpoints, settling both into one LNBits wallet.
- What you can do
- Gate MCP tool endpoints behind a 402 challenge advertising both L402 and x402 rails, and accept whichever the caller sends. Verify L402 tokens by forwarding to a gate URL or a custom verify function. Run a 10-step x402 bip122/exact verifier covering BOLT11 decode, expiry, amount, replay cache and LNBits paid-check. Mint invoices and confirm payment through a configured LNBits backend. Expose settlement details on the request and return a PAYMENT-RESPONSE header on success.
- When to use it
- For operators of paid MCP endpoints who want to charge per call in Bitcoin Lightning and serve both legacy L402 clients and forward-compatible x402 clients from a single wallet, without running two services.
- Requirements
- Node.js 18 or newer and a local npm install of the package. An LNBits wallet URL and invoice/read API key for settlement. A reachable gate URL, configurable via POW_GATE_URL, if the default L402 verify forwarder is used. Network access to LNBits and the gate.
Installation
In SourceWeft
- Open Mcp Pay Gate in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
@powforge/mcp-pay-gate
Drop-in Express middleware for MCP servers. Accepts L402 Lightning (legacy clients) and x402 bip122/exact (forward-compat clients) with a real 10-step verifier behind both rails. One LNBits backend serves both. v0.2.0 ships full x402 verification (BOLT11 decode, replay protection, LNBits paid-check) — no stubs.
Why dual-rail
The pay-per-call MCP space is converging. Coinbase's x402 spec has an open PR (coinbase/x402 #2258) adding bip122/exact, which moves Bitcoin Lightning settlement inside x402. That means the rail choice for paid MCP endpoints collapses into a wallet-capability decision over the next 30 to 60 days.
If you ship today and pick one rail, half your future clients break. If you ship two services, you carry double the operational surface for the same revenue.
This middleware is the third option. It advertises both rails in the 402 challenge, accepts whichever the caller sends, and settles both into the same LNBits Lightning wallet. Existing L402 clients keep working. New x402 clients also work. You ship once.
Status
As of v0.2.0 both rails are live.
- L402 rail: verification forwards to
${POW_GATE_URL}/v1/verifyby default. Production verify via@powforge/mcp-l402-gatein-process is recommended for full fidelity (this package does not duplicate the macaroon mint or HMAC code). - x402 rail: full 10-step
bip122/exactverifier per the x402-foundation/x402 PR #1311 spec, cross-checked against the Python reference impl in PR #1873. Mints a real BOLT11 invoice via the configured LNBits backend, decodes it withlight-bolt11-decoder, validates scheme / network / asset / payTo / paymentMethod / invoice consistency / expiry / exact msat amount, short-circuits replays via an in-memory settlement cache, and confirms payment via LNBits paid-check. On success, returns a base64SettlementResponsein thePAYMENT-RESPONSEheader. 29 tests passing (12 middleware + 17 verifier-unit).
Deferred to v0.3.0: in-flight HTLC detection, BOLT12 offers, multi-instance settlement cache (Redis backend).
If you need an L402-only gate today, @powforge/mcp-l402-gate is the focused product — full L402 verify, replay protection, DoI score gating. This package is the dual-rail option for operators serving both legacy L402 and forward-compat x402 clients from one LNBits wallet.
Requirements
- Node >= 18
- An LNBits wallet (URL + invoice/read API key) for actual settlement
- A reachable
POW_GATE_URLif you use the default L402 verify forwarder
Five-line integration (Express)
Behavior
Config reference
What this is not
- This is not a macaroon mint. Pair it with
@powforge/mcp-l402-gateif you want PowForge to mint and verify L402 in-process. - This is not an LNBits client. It does not create invoices or check payment status itself; the verify functions own that.
- This is not a DoI score gate. If you want identity-scored access on top of payment, compose this with
@powforge/mcp-l402-gateor@powforge/mcp-identity.
The point of this package is the dual-rail challenge response and the request-routing shape. Plug your real verify in.
Roadmap
- v0.1 (shipped): scaffold. Dual-rail challenge, L402 verify forwarder, x402 stub.
- v0.2 (current): full x402
bip122/exactverification per PR #1311 spec. Real LNBits invoice mint, BOLT11 decode, in-memory replay cache, 10-step verifier, 29 tests. - v0.3 (planned): in-flight HTLC detection (Retry-After), BOLT12 offers, Redis-backed settlement cache for multi-instance deployments.
License
MIT.
Source: README.md at commit 81bc25e
Tools
0Version history
1- v0.2.0LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts