402-mcp
MCP server by forgesworn Verified · forgesworn.dev
402-mcp is an MCP server that lets AI agents find, pay for and call Lightning and ecash payment-gated APIs. Spending stays within limits the user sets. It suits people who want their AI assistant to use paid APIs without registering or managing API keys.
Install 402-mcp
Built from the published package, never by AI.
claude mcp add 402-mcp -- npx -y 402-mcpRun in your terminal. Add --scope user to use it in every project.
{
"mcpServers": {
"402-mcp": {
"args": [
"-y",
"402-mcp"
],
"command": "npx"
}
}
}Settings, Developer, Edit config. Paste into claude_desktop_config.json and restart.
{
"mcpServers": {
"402-mcp": {
"args": [
"-y",
"402-mcp"
],
"command": "npx"
}
}
}Add to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (this project).
{
"servers": {
"402-mcp": {
"args": [
"-y",
"402-mcp"
],
"command": "npx"
}
}
}Add to .vscode/mcp.json. VS Code uses "servers", not "mcpServers".
codex mcp add 402-mcp -- npx -y 402-mcp{
"mcpServers": {
"402-mcp": {
"args": [
"-y",
"402-mcp"
],
"command": "npx"
}
}
}Add to ~/.gemini/config/mcp_config.json (all projects) or .agents/mcp_config.json (this project).
gemini mcp add 402-mcp npx -y 402-mcpGemini CLI was replaced by Antigravity CLI in June 2026 and remains only for enterprise licences and paid API keys.
MCP servers run with your permissions and can read what you give them access to. Some need an API key: check the README and add it under env in the 402-mcp block.
About
402-mcp is an L402 client MCP server. It lets AI agents discover paid APIs on Nostr, pay for calls, and consume the data returned. Payment options include Lightning through Nostr Wallet Connect (NWC), Cashu ecash, LNURLcash bearer notes, or a human QR fallback. Stored credentials are cached and encrypted at rest with AES-256-GCM.
Spending is capped by settings the user chooses, including a maximum per automatic payment, a per-minute limit and a rolling daily limit. The server works with any L402 server, such as toll-booth or Aperture. It is aimed at people who want an AI assistant to use paid APIs within set limits, without human registration or API keys.
Written from the project's README and checked against it.
Tools it gives your assistant
l402-configIntrospects payment capabilities, including wallets, limits and credential count.l402-searchDiscovers paid APIs listed on Nostr, without needing URLs up front.l402-discoverProbes an endpoint to discover its pricing without paying.l402-fetch-previewShows what an endpoint costs without paying.l402-fetchSends an HTTP request and pays a 402 challenge when autoPay is set and the price is within limits.l402-buy-creditsBuys a credit balance from a service so later calls use the stored credential.l402-payPays a challenge by its payment hash. Other invoices need the human's approval.l402-reconcileLists or resolves payments with unknown outcomes and pauses auto-pay until they are resolved.l402-credentialsLists stored credentials and cached balances.
What you need
- Node.js 22.4 or newer
- An NWC wallet with pay_invoice permission and a spending budget, for paid calls
- A wallet that supports NIP-44 v2 encryption
| Setting | Needed | What it is |
|---|---|---|
NWC_Environment variable, secret | Optional | Nostr Wallet Connect URI for autonomous Lightning payments |
MAX_Environment variable | Optional | Maximum sats to auto-pay per request |
From the publisher's entry in the official MCP Registry. Required settings are already in the install config below as placeholders.
Try asking
- Search for paid joke APIs using l402-search
- Check what this paid endpoint costs before paying with l402-fetch-preview
- Show my stored L402 credentials and cached balances
Good to know
- Paid calls need an NWC, Cashu or LNURLcash wallet, and the wallet must support NIP-44 v2 for NWC.
- A raw NWC_URI variable is refused; the URI must be read from a private file.
- Auto-pay to a service is paused while any payment outcome is unknown.
- SOCKS5 proxy support is marked experimental by Node and prints an ExperimentalWarning.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: README.md, package.json. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to 402-mcp
All alternatives →Connects AI assistants to Stripe through the hosted Stripe MCP server at mcp.stripe.com. It is for developers building AI-powered products and businesses on Stripe.
Gives AI assistants market data, technical analysis, backtests, options activity and news sentiment for stocks, crypto, FX and metals. Built for traders and developers using Claude, ChatGPT, Cursor or other MCP clients. Its outputs are informational, not financial advice.
CCXT is an official MCP server for market data and trading across more than 100 exchanges and prediction markets. It is aimed at developers, traders and AI agents.
Calculates over 1400 transparent financial methods from raw statements and exposes them to AI assistants through an MCP server. Suited to analysts and developers who want to see how each metric is computed.
Lets an AI assistant search x402 APIs and pay for them in USDC from a local, non-custodial wallet. Built for people and agents that need to pay APIs per call under spend caps.
Lets AI assistants explore a free database of over 300,000 symbols, including equities, ETFs, funds, indices, currencies and cryptocurrencies, categorised by sector, industry and country. It suits private investors who want to discover products rather than look up fundamentals or stock data.
Compare with mcp, TradingMCP or CCXT
402-mcp: common questions
Does 402-mcp need API keys or accounts with each API?
The source says no human registration, no API keys and no middlemen are needed. Payment is made per call to the L402 server.
How does 402-mcp limit how much an agent can spend?
Settings such as MAX_AUTO_PAY_SATS, MAX_SPEND_PER_MINUTE_SATS and MAX_SPEND_PER_DAY_SATS cap automatic spending. Payments above the cap are not made and the challenge is returned to the agent.
Can 402-mcp work over Tor?
Yes. Setting TOR_PROXY or SOCKS_PROXY routes .onion and paid-API requests through a SOCKS5 proxy such as Tor.
How do I install 402-mcp?
In Claude Code run claude mcp add 402-mcp -- npx -y 402-mcp. For Claude Desktop, Cursor and VS Code, paste the config shown above and restart. See the install guides.
Is 402-mcp the official server?
402-mcp is published by forgesworn.dev from its verified domain in the official MCP Registry.
Is 402-mcp free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is 402-mcp safe to use?
It scores 84 of 100. Grades: maintenance A, licence A, quality C. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to 402-mcp?
Similar MCP servers: mcp, TradingMCP, CCXT, Finance Toolkit.
Does 402-mcp work with ChatGPT?
Not directly. It runs locally, and ChatGPT only connects to remote servers with a URL. Use it in Claude Code, Claude Desktop, Cursor, VS Code or Codex.
