402 MCP server
AI agents discover, pay for, and consume any Lightning-gated API autonomously
0 stars733 downloads/wk
Reviews
Write oneNobody has reviewed 402 yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
402 tools (10, 2 write)
write = sends, deletes, buys or postsRead from the package source without running it. The installed server may list more.
l402-balanceCheck cached credit balance for a server. Returns the last known balance from the credential store without making a network request. The "stale" flag is true if the balance was last updated more than 5 minutes ago.
l402-buy-creditswrite actionBuy credits from a toll-booth server with volume discounts. Omit amountSats to discover available tiers. Provide amountSats to purchase a specific tier. Only works with toll-booth servers.
l402-configIntrospect the MCP's payment capabilities: which wallets are configured, spending limits, and stored credential count. Call this first to understand what payment methods are available.
l402-credentialsList all stored L402 credentials. Shows origin, cached credit balance, and server type. Balance values are cached and may be stale; check lastUsed timestamp.
l402-discoverProbe an endpoint to discover its L402 pricing without committing to payment. Returns the cost in sats, available payment methods, and credit tiers (if toll-booth server). The challenge is cached so a subsequent l402-pay can reuse it.
l402-fetchFetch a URL with automatic payment handling (L402 Lightning + x402 on-chain). Manages credentials, pays automatically when autoPay is true and cost is within budget, and retries. For human wallets, returns a payment page URL or QR code. For x402 services, returns payment details (receiver address, network, asset, amount) — the user pays in their wallet and provides the transaction hash. Set autoPa
l402-paywrite actionConfirm payment and store credentials. Call this after l402-fetch returns a 402 with a paymentHash — polls the payment server for settlement (up to 30s for human wallet), then stores the credential so the next l402-fetch succeeds. For human wallets, call this immediately after showing the payment URL to the user.
l402-redeem-cashuRedeem Cashu ecash tokens directly on a toll-booth server, avoiding the Lightning round-trip. Handles the two-step flow automatically (create invoice then redeem token). Only works with toll-booth servers.
l402-searchSearch for paid APIs and services. Use this when the user wants something that might be available as a paid service — jokes, data, AI, content, etc. Discovers services announced on Nostr and returns their URLs, pricing, and capabilities. Then use l402-fetch with the URL to access the service.
l402-store-tokenStore an L402 token (macaroon:preimage) obtained from a payment page. Use this when a user pastes back a token from a toll-booth payment page. The token is stored as a credential so subsequent l402-fetch calls are authenticated.
Public scan report
scanner v0.1.9 · 2026-09-27 · same rubric, same numbers if you re-run it
- Code scan85 source files scanned25/25
- –Live reliabilityno gateway calls yet and no remote to proben/a
- –Tool poisoningtools not inspected (local package is not executed); not countedn/a
- Auth qualitystatic API keys via environment variables6/15
- Maintenancelast push 3 days ago15/15
- Maintainer identityregistry namespace matches repository owner7/10
Install 402 in Claude Code, Cursor or VS Code
Runs npx -y 402-mcp on your machine. Read the scan report first; the gateway never runs local packages.
claude mcp add 402-mcp -- npx -y 402-mcp
What the publisher says
From the 402 repository's README, as published. We do not edit it. Read it on GitHub
402-mcp
Nostr: npub1mgvlrnf5hm9yf0n5mf9nqmvarhvxkc6remu5ec3vf8r0txqkuk7su0e7q2
L402 client MCP that gives AI agents economic agency. Discover, pay for, and consume Lightning and ecash payment-gated APIs within limits you set: no human registration, no API keys, no middlemen.
- Discover paid APIs on Nostr — no URLs needed upfront
- Auto-pay with Lightning (NWC), Cashu ecash, LNURLcash bearer notes, or human QR fallback
- Credentials cached and encrypted at rest (AES-256-GCM)
- Works with any L402 server — toll-booth, Aperture, or any future implementation
Quick start
1. Install
npx 402-mcp2. Connect to Claude Code
claude mcp add 402-mcp -- npx 402-mcp3. Try it
Ask Claude: "Search for paid joke APIs using l402-search" — no wallet needed, just discovery.
Ready to make paid calls? See the full quickstart guide to set up a wallet and watch your agent pay for its first API call.
Requires Node.js 22 or newer.
How it works
graph LR
A["1. l402-config()"] --> B["2. l402-discover(url)"]
B --> C["3. Agent reasons<br/>about pricing"]
C --> D["4. l402-buy-credits()<br/>or l402-fetch()"]
D --> E["5. l402-fetch(url)<br/>with credentials"]
E --> F["6. Data returned<br/>+ balance cached"]Example session:
Agent: "I need routing data from routing.example.com"
1. l402-config()
-> nwcConfigured: true, maxAutoPaySats: 1000
2. l402-discover("https://routing.example.com/api/route")
-> 10 sats/request, toll-booth detected, tiers available
3. Agent reasons: "I need ~20 requests. The 500-sat tier
gives 555 credits. Better value."
4. l402-buy-credits(url, amountSats=500)
-> Paid 500 sats, received 555 credits
5. l402-fetch("https://routing.example.com/api/route?from=...&to=...")
-> 200 OK, route data, 545 credits remainingFor detailed architecture and payment flow diagrams, see docs/architecture.md.
Configuration
Shortened. The full README is on GitHub.
Nothing above is checked by us. What we check is on the safety report.
402: common questions
- Is 402 MCP server safe?
- Mostly: it is graded B (82/100). Read the 402 safety report
- How do I install 402?
- It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
- Does 402 need an API key?
- Yes. The registry entry asks for
NWC_URI. - Is 402 maintained?
- The last commit was 4 days ago (2026-09-24). The latest release is v3.15.2.