402-mcp — Claude Code MCP server for paid API access
402-mcp lets an agent find L402-protected APIs, pay for access and make requests. It supports Lightning and ecash payment methods.
claude mcp add --env NWC_URI=<NWC_URI> --env MAX_AUTO_PAY_SATS=<MAX_AUTO_PAY_SATS> --transport stdio 402-mcp -- npx -y 402-mcpWhat 402-mcp does
The server lets an agent look for paid APIs on Nostr, check their prices and request data after paying. Payment options include Lightning through NWC, Cashu and LNURLcash; a person can also complete payment through a QR code.
Purchased access credentials are stored for later requests, and settings control automatic spending limits. NWC payments require Node.js 22.4 or newer and a wallet that supports NIP-44 v2 encryption. One setup detail matters: the README says startup rejects the NWC_URI environment variable, while the install commands below set it. HTTP transport is also available and requires an authorization-token file.
What it helps with
- discover paid APIs on Nostr
- check the price of an L402 API call
- pay for API access with Lightning or ecash
- reuse stored credentials for API requests
- cap an agent’s automatic spending
Example prompts for the agent
- Use
l402-searchto find paid APIs that return routing data. - Check this API’s price with
l402-discover, then fetch its data if access is paid. - Use
l402-configto inspect payment settings and stay within the spending limit.
How to install 402-mcp
Platform CLI
claude mcp add --env NWC_URI=<NWC_URI> --env MAX_AUTO_PAY_SATS=<MAX_AUTO_PAY_SATS> --transport stdio 402-mcp -- npx -y 402-mcpReplace <…> with your own values
Platform CLI
codex mcp add 402-mcp --env NWC_URI=<NWC_URI> --env MAX_AUTO_PAY_SATS=<MAX_AUTO_PAY_SATS> -- npx -y 402-mcpReplace <…> with your own values
Config file
{
"mcpServers": {
"402-mcp": {
"command": "npx",
"args": [
"-y",
"402-mcp"
],
"env": {
"NWC_URI": "<NWC_URI>",
"MAX_AUTO_PAY_SATS": "<MAX_AUTO_PAY_SATS>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"402-mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"402-mcp"
],
"env": {
"NWC_URI": "<NWC_URI>",
"MAX_AUTO_PAY_SATS": "<MAX_AUTO_PAY_SATS>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e NWC_URI=<NWC_URI> -e MAX_AUTO_PAY_SATS=<MAX_AUTO_PAY_SATS> 402-mcp npx -y 402-mcpReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about 402-mcp
How do I install 402-mcp in Claude Code?
Run claude mcp add 402-mcp -e NWC_URI=<NWC_URI> -- npx -y 402-mcp. Alternatively, run claude mcp add --env NWC_URI=<NWC_URI> --env MAX_AUTO_PAY_SATS=<MAX_AUTO_PAY_SATS> --transport stdio 402-mcp -- npx -y 402-mcp.
What does 402-mcp do?
It lets an agent discover L402-protected APIs, pay for access through Lightning or ecash, and make requests using stored credentials.
What is required for NWC auto-pay?
You need Node.js 22.4 or newer and a wallet that supports NIP-44 v2 encryption. The README also says the server rejects NWC_URI as an environment variable at startup.