
Mcp L402 Gate
io.github.zekebuilds-labPublished by GitHub account zekebuilds-labv0.1.4Updated Oct 27, 2026
L402 Lightning paywall + DoI score gate for MCP tools: challenge, verify, score.
Overview
Library that puts a Lightning L402 paywall plus a Depth-of-Identity score check in front of MCP tools, so callers must pay sats and hold a reputation score.
- What you can do
- Wrap an MCP tool so each call first returns a Lightning invoice and macaroon challenge, then runs only after payment is verified.
- Check the caller's Nostr pubkey against a Depth-of-Identity oracle and reject paid callers below a configured composite score.
- Configure amount, minimum score, macaroon scope and lifetime, fail-closed behaviour, and oracle or LNBits endpoints.
- Expose the same gate as Express middleware or as a tool wrapper, with test seams for invoice, payment and score lookups.
- When to use it
- For operators publishing paid MCP tools who want to slow down sybil or throwaway-wallet abuse, not just collect a small toll. Useful when a tool has real cost or side effects and you want a per-pubkey reputation threshold before it runs.
- Requirements
- Runs locally as an npm package on Node 18 or newer. Needs an LNBits wallet URL and invoice/read API key, an HMAC secret for macaroon signing, and reachable PowForge oracle and gate URLs (ORACLE_URL, POW_GATE_URL default to public endpoints). Network access to LNBits and the oracle.
Installation
In SourceWeft
- Open Mcp L402 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-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
Source: README.md at commit 7fc1fe1
Tools
0Version history
1- v0.1.4LatestSep 16, 2026
Score
40% 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
Declare a license in the repository or the registry entry.