
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 分