
Mcp Pay Gate
io.github.zekebuilds-lab由 GitHub 账号 zekebuilds-lab 发布v0.2.0更新于 Oct 25, 2026
Dual-rail Lightning paywall for MCP servers: accepts L402 and x402 bip122/exact, one LNBits backend.
概览
为 MCP 服务器端点添加双通道 Lightning 付费墙(L402 与 x402 bip122/exact)的 Express 中间件,两条通道结算到同一个 LNBits 钱包。
- 可以做什么
- 为 MCP 工具端点加上 402 挑战,同时公布 L402 与 x402 两条通道,并接受调用方所选的一条。通过转发到网关地址或自定义校验函数来校验 L402 令牌。执行 10 步 x402 bip122/exact 校验,涵盖 BOLT11 解码、过期、金额、重放缓存与 LNBits 支付确认。通过配置的 LNBits 后端开具发票并确认付款。在请求上暴露结算信息,成功时返回 PAYMENT-RESPONSE 头。
- 适用场景
- 适合为 MCP 端点按次收取 Bitcoin Lightning 费用的运营者,用一个钱包同时服务旧版 L402 客户端和向前兼容的 x402 客户端,而无需运行两套服务。
- 运行要求
- Node.js 18 或更高版本,并在本地通过 npm 安装该包。用于结算的 LNBits 钱包地址与 invoice/read API 密钥。若使用默认 L402 校验转发器,需要可访问的网关地址,可通过 POW_GATE_URL 配置。需要访问 LNBits 与网关的网络连接。
安装
在 SourceWeft 中
- 打开 控制台中的 Mcp Pay Gate,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
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.
来源:README.md,提交 81bc25e
工具
0版本历史
1- v0.2.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分