Get 402-mcp running and make your first paid API call in under 5 minutes.
npx 402-mcpYou should see the MCP server start. Press Ctrl+C to stop it — your MCP client will manage the process.
One command:
claude mcp add 402-mcp -- npx 402-mcpDone. 402-mcp is now available in your Claude Code sessions.
Claude Desktop
Add to your Claude Desktop MCP configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"l402": {
"command": "npx",
"args": ["402-mcp"]
}
}
}Restart Claude Desktop to pick up the change.
Cursor
Add the same JSON block to your Cursor MCP configuration. See Cursor MCP docs for the config file location.
Ask your AI agent:
"Search for paid joke APIs using l402-search"
The agent will query Nostr relays for kind 31402 service announcements and return a list of live paid APIs — URLs, pricing, and capabilities. No wallet, no cost. This is just discovery.
Try other searches too — l402-search("AI inference") will find satgate (pay-per-token AI inference) and any other services announcing on Nostr.
To make paid calls, you need a payment method. Pick one:
NWC — Nostr Wallet Connect (recommended)
The fastest path to fully autonomous payments. Your agent pays from your Lightning wallet without asking.
- Use a wallet that supports NWC (e.g. Alby)
- Generate an NWC connection URI from your wallet
- Add it to your MCP config:
Claude Code:
claude mcp remove 402-mcp
claude mcp add 402-mcp -e NWC_URI="nostr+walletconnect://..." -e MAX_AUTO_PAY_SATS=1000 -- npx 402-mcpClaude Desktop / Cursor: Add the env block to your config:
{
"mcpServers": {
"l402": {
"command": "npx",
"args": ["402-mcp"],
"env": {
"NWC_URI": "nostr+walletconnect://...",
"MAX_AUTO_PAY_SATS": "1000"
}
}
}
}MAX_AUTO_PAY_SATS caps any single payment. Above this, the agent asks you first.
Cashu — ecash tokens
If you have Cashu tokens, point 402-mcp at your token file:
Claude Code:
claude mcp remove 402-mcp
claude mcp add 402-mcp -e CASHU_TOKENS="/path/to/tokens.json" -- npx 402-mcpThe agent melts tokens to pay invoices — fully autonomous, no Lightning node needed.
No wallet — human-in-the-loop
No setup needed. When the agent needs to pay, it presents a Lightning invoice with a QR code. Scan it with any Lightning wallet (Phoenix, Strike, Cash App, etc.) and the agent continues automatically once payment settles.
Now ask your agent:
"Get me a joke from sats-for-laughs using the l402 tools"
Watch what happens:
- The agent discovers the endpoint and its pricing
- It checks your spend limits via
l402-config - It calls
l402-fetch— 402-mcp pays the invoice automatically (or shows you a QR) - The joke comes back, and the credential is cached for future requests
That's it. Your AI agent just paid for an API call autonomously.
- More APIs — try satgate for pay-per-token AI inference
- Tool reference — see the full tool list in the README
- Architecture — detailed diagrams in docs/architecture.md
- Security — spend safety, SSRF protection, encryption in docs/security.md
- Contributing — development setup and guidelines in CONTRIBUTING.md
Service unavailable? Use l402-search to find other live services — the Nostr relay network has a growing catalogue.
Payment failed? Check your wallet balance and that your NWC URI is correct. Try l402-config to verify your payment methods are detected.
Want to see what's stored? Use l402-credentials to list cached credentials and l402-balance to check remaining credits.