
Mcp L402 Gate
io.github.zekebuilds-lab由 GitHub 账号 zekebuilds-lab 发布v0.1.4更新于 Oct 27, 2026
L402 Lightning paywall + DoI score gate for MCP tools: challenge, verify, score.
概览
为 MCP 工具加上 Lightning L402 付费墙与身份深度评分校验的库,调用方须支付 sats 并达到信誉分数才能执行。
- 可以做什么
- 包装 MCP 工具,首次调用返回 Lightning 发票与 macaroon 挑战,验证付款后才执行工具逻辑。
- 按调用方 Nostr 公钥向身份深度预言机查询综合评分,低于设定阈值的付费调用被拒绝。
- 可配置金额、最低分数、macaroon 作用域与有效期、预言机失败时是否拒绝,以及 LNBits 与预言机地址。
- 同一套网关既可作为 Express 中间件,也可作为工具包装器使用,并提供发票、付款与评分查询的测试接缝。
- 适用场景
- 适合对外发布付费 MCP 工具、希望抑制女巫账号和一次性钱包滥用的运营者,而不只是收一点过路费。当工具本身有真实成本或副作用、需要在执行前按公钥信誉设门槛时尤其有用。
- 运行要求
- 以 npm 包形式在本地运行,需要 Node 18 或更高版本。需要 LNBits 钱包地址与发票/只读 API 密钥、用于 macaroon 签名的 HMAC 密钥,以及可访问的 PowForge 预言机与网关地址(ORACLE_URL、POW_GATE_URL 默认指向公共端点)。需要访问 LNBits 与预言机的网络。
安装
在 SourceWeft 中
- 打开 控制台中的 Mcp L402 Gate,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
@powforge/mcp-l402-gate
Identity-scored Lightning paywall for MCP server operators.
L402 alone proves the caller paid 10 sats. It does not prove the caller has a reputation, has been around for more than 10 minutes, or that pricing one tool call shifts their economics at all. A fresh wallet pays the same 10 sats as a real user.
This package adds a Depth-of-Identity check on top of the L402 invoice. Drop it in front of an MCP tool and a caller has to (a) settle a Lightning invoice and (b) carry a DoI score above your threshold before the tool body runs. Cheap sybils still pay the toll, but the toll plus the per-pubkey reputation requirement is harder to grind than either piece on its own.
See it in action
A clone-and-run example server lives at github.com/zekebuilds-lab/mcp-l402-gate-example. It exposes one tool, bitcoin_data, that fetches the BTC/USD price plus mempool fees from mempool.space, gated by L402 + DoI. Clone it, fill in your LNBits creds, npm start, and you have a Lightning-gated MCP server running locally.
The Gap
Sats4AI's own documentation states the limitation plainly:
"autonomous agents cannot build reputation or receive preferential treatment across sessions."
@powforge/mcp-l402-gate closes that gap by composing L402 payment gating with the DoI oracle's composite identity score. A paying caller is also a known caller, with a per-pubkey reputation that survives across sessions and that costs irreversible work to fake.
Why not just L402
L402 is great wire format, weak abuse control. Recent MCP billing tools (sats4ai-mcp, invinoveritas, l402-kit, 402-mcp, coinopai-mcp) all ship the same 402 -> macaroon -> paid -> tool body flow, and an attacker can replay the flow from a fresh node every minute. coinopai-mcp's own author put it: "x402 is payment transport only. It doesn't handle agent identity, rate negotiation, multi-agent splits, or reputation."
PowForge has been shipping the missing piece. The DoI oracle at https://identity.powforge.dev returns a Schnorr-signed score for any Nostr pubkey, computed from observable irreversible work across four dimensions (social, access, vouch, economic). This package wires that score into the L402 path so a paying caller is also a costly-to-fake caller.
Requirements
- Node >= 18
- An LNBits wallet (URL + invoice/read API key) for the Lightning side
- An accessible PowForge oracle URL (default:
https://identity.powforge.dev)
5-line integration (Express)
The caller passes their pubkey via the X-Caller-Pubkey header or ?pubkey= query string. v0.1.0 treats this as caller-asserted; v0.2.0 will bind it cryptographically via NIP-98.
MCP tool wrapping
Config reference
Score thresholds (composite)
Same buckets the oracle reports as rank:
Failure modes
Why this is a separate package
The L402 macaroon mint and verify code, the LNBits client, and the oracle client are all already shipping inside other PowForge packages. The point of @powforge/mcp-l402-gate is to make the composition trivial: one factory, one config object, one middleware OR one tool wrapper. Operators do not have to assemble three packages by hand to get a defended endpoint.
Tests
16 unit tests, no real network. The macaroon HMAC is real; LNBits and oracle are stubbed.
License
MIT.
Links
- PowForge oracle (live): https://identity.powforge.dev
- Identity SDK: @powforge/identity on npm
- MCP identity tools: @powforge/mcp-identity on npm
来源:README.md,提交 7fc1fe1
工具
0版本历史
1- v0.1.4最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。