402 MCP is a free, open-source MCP server for developers and teams building AI agents that need to pay for web APIs. It is an npm package released under the MIT license, and the project lists Windows among its supported platforms. If you want an agent to find a paid endpoint, settle the fee over Lightning or Cashu, and then keep using the answer, this is the tool that handles that loop.
The program speaks two payment standards, L402 and x402, which both use the HTTP 402 Payment Required status to request a fee before returning data. Discovery happens through Nostr, so an agent can find services without you pasting a list of URLs first. The rest of this page explains what the server does, how to start it, and where it fits compared with the Nostr clients that dominate this catalog.
What Is 402 MCP and Who Is It For?
402 MCP sits between an AI agent and the paid web. The Model Context Protocol (MCP) is a way for AI assistants to call external tools, and this server adds tools for finding, paying for and consuming L402 and x402 APIs. The agent does not need custom payment code; it calls the tools and receives JSON text in return.
The main audience is developers and agent builders who already run MCP clients and want their agents to act on paid data or services. A typical case is an agent that needs a short-lived data lookup, such as a price check or a signed record, and should pay a few satoshis for it without a person stepping in. Hobbyists who simply want to chat with a Nostr feed will find the tool less relevant.
The project also positions itself as the wallet-provider agnostic option in this space. It is meant for setups where you do not want a full Lightning node running next to the agent, and where you may prefer to switch wallets later without rewriting the integration.
How L402 and x402 Payments Work for AI Agents
L402 combines the HTTP 402 status code with Lightning payments. A server that wants a fee answers a request with 402 Payment Required and includes a Lightning invoice. The client pays the invoice, collects proof of payment, and presents that proof with later requests to the same service. This is what makes pay-per-request access possible without accounts or subscriptions.
x402 follows the same basic idea of charging for an individual HTTP request, but it is a separate standard. Supporting both means an agent does not have to know in advance which scheme a given API uses. The server handles the negotiation so the agent can focus on the task.
For an AI agent, the important point is that each payment is small and specific to one request. Setting a sensible spending limit in the connected wallet, and watching what the agent is allowed to buy, keeps this model under control.
Why Nostr Helps Agents Find Paid Services
Nostr is a decentralized protocol in which users and services publish signed events to relays. Discovery through Nostr means a service can announce itself once, and any client that reads the same events can see it. The project uses kind 31402 announcements for this purpose, and they are part of how the server learns about available paid APIs.
The benefit is independence from a single directory. A bot or agent does not have to rely on one company's marketplace to find a service. If one relay is slow or offline, the same announcements may still be available from others, depending on how a service publishes them.
The trade-off is that discovery is only as good as the announcements. Agents should check what a service does and what it costs before paying, and builders should treat announced endpoints as unverified until they have tested them.
Key Terms Worth Knowing Before You Start
A seed phrase is the set of words that restores a wallet. Anyone who holds it can spend the funds, so it should never be typed into a website or sent in a chat. Nostr Wallet Connect (NWC) is a way for an app to request payments from a wallet that you control, without giving the app your seed phrase.
Cashu is an ecash protocol in which funds are held as blinded tokens issued by a mint. LNURLcash bearer notes are a related way to carry value that can be redeemed by whoever holds the note, which is why they should be treated like cash. A bearer instrument that is lost or leaked is generally gone.
The developer fee concept also matters in the wider ecosystem. Some services charge a fee on top of the API price, while others do not. Read each service's terms before letting an agent pay, because the server's own job is to handle the payment flow, not to set prices.
Key features
Discovery of Paid APIs on Nostr
Automatic Payments Through Several Routes
Encrypted Credential Cache
Compatibility With Any L402 Server
Supported coins
The project works with the Lightning Network and Nostr, and its documentation also mentions Polygon as a network. Ledger is named among hardware wallets in the same documentation. Lightning is the main payment rail for L402 flows, while Cashu and LNURLcash cover additional ways to settle small amounts. Keep in mind that a hardware wallet protects keys on the device, so it fits best when you manage funds yourself and connect them to the agent through a supported route.
How to install 402 MCP on Windows
- 1
Install Node.js
The server runs through npx, which is included with Node.js. Download Node.js only from the official website at nodejs.org and install the current LTS release. Once it is installed, open a terminal and confirm that npx responds, because your MCP client will call it to launch 402 MCP.
- 2
Add 402 MCP to Your MCP Client
In your MCP client's configuration, add a server entry that runs the command npx 402-mcp as a local stdio server. The exact file location depends on the client you use, so follow its documentation for adding a stdio server. Save the configuration and restart the client.
- 3
Let the First Launch Fetch the Package
You do not install 402 MCP separately. The first time your client starts the server, npx downloads the 402-mcp package and caches it locally. Later launches are quicker because the package is already present. Keep the internet connection on during this first start.
-
Check the Launch by Hand (Optional)
In Command Prompt or PowerShell, run npx 402-mcp. The server starts and waits for a client on standard input, so the window may look idle. Press Ctrl+C to stop it. This check only confirms that the launch works; in normal use, your MCP client starts and manages the server for you.
System requirements
- Windows, which the project lists among its supported platforms
- Node.js, because the server is an npm package started through npx on the command line
- An MCP-compatible client that can launch a local stdio server
- A Lightning wallet with Nostr Wallet Connect support, only if you want automatic payments
How to use 402 MCP
Once your MCP client launches 402 MCP, the agent can use its tools during a conversation or task. You do not need to run the server by hand. The steps below describe the usual flow.
- Start your MCP client so it launches 402 MCP through npx.
- Give the agent a task that requires a paid API, such as retrieving a specific record.
- Let the agent call the discovery tools to find services announced on Nostr.
- When a service asks for payment, check which route applies: an automatic Nostr Wallet Connect payment, Cashu, LNURLcash, or the QR fallback that a person must scan.
- Review the JSON text each tool returns. Parameters marked as required must be supplied in every call.
- If a response has the isError flag set, read the message in the JSON before retrying, because the failure may come from a missing parameter or a declined payment.
- Reuse cached credentials for repeated requests to the same service while they remain valid.
- Review your wallet's history after a session, so you can see what the agent paid for and adjust spending limits if needed.
Pros & cons
- Free and released under the MIT license, so the code can be read and modified
- No separate install step beyond Node.js, since npx fetches the package on first start
- Several payment routes, including Nostr Wallet Connect, Cashu, LNURLcash and a QR fallback
- Credentials are encrypted at rest with AES-256-GCM
- Works with any L402 server rather than one vendor's stack
- No Lightning node required, and multiple wallets are supported
- Aimed at developers and agent builders, not at people who want a graphical app
- Automatic payments mean an agent can spend from a connected wallet, so wallet limits matter
- Requires Node.js and comfort with command-line tools and client configuration
- Windows is among the listed platforms, but the setup is entirely command-line based, so expect to troubleshoot paths and environment issues yourself
Is 402 MCP safe?
402 MCP handles keys and payments, so treat it with the same care as a wallet. Download it only from the official GitHub repository at github.com/forgesworn/402-mcp or from the npm package the project publishes, and review the repository before you trust it. Where a checksum or signature is published, verify the SHA-256 value or signature against the file you received. Check the latest release on the official website and keep your installation current. Never enter a seed phrase on third-party websites, and never paste Nostr Wallet Connect strings or cached credentials into forums, chats or support requests. Encryption at rest protects the cache, but it cannot protect a computer that someone else controls.
- Official source only. Download from github.com/forgesworn/402-mcp. Ignore ads and lookalike domains.
- Check the SHA-256. Compare the installer hash with the value the developer publishes before running it.
- Never share your seed phrase. No developer, support agent or website — including CryptApps — will ever ask for it.
Alternatives
Most programs in this Nostr category are client apps for people, such as Amethyst, Vega, Nostrid, Nostrmo and Notedeck. They let you read, post and follow other users, so their focus is screens, feeds and profiles. 402 MCP has no feed or interface. It is a background server that an AI agent uses to find and pay for APIs. If you want to browse social Nostr, one of those clients is the better fit. If you are building an agent that needs paid data, 402 MCP is the closer match, and it positions itself as a wallet-agnostic alternative to Lightning Labs' lightning-agent-tools.
Specifications
- Price
- Free
- Type
- Open source
- License
- MIT
- Latest version
- v4.4.2
- Last update
- 26 Oct 2026
- Windows support
- Unverified (Windows mentioned in docs)
- Source code
- github.com/forgesworn/402-mcp
Frequently asked questions
Yes. The program is listed as free and is released under the MIT license, which allows reuse and modification under its terms. Any payments you make are the fees charged by the APIs your agent calls, and those prices are set by each service rather than by this server. Read the license file in the repository for the full terms.
The project lists Windows among its supported platforms, alongside macOS and Linux. The server runs as a command-line process started by npx, so the setup happens in a terminal. Install Node.js, run npx 402-mcp once to check the launch, and then add the server to your MCP client and test a simple call before relying on it.
The code is open source under the MIT license, so it can be reviewed, and stored credentials are encrypted with AES-256-GCM. Safety still depends on your setup. Download only from the official repository, keep spending limits on your wallet, and never share a seed phrase. The safety section above lists the steps in more detail.
L402 is a standard for pay-per-request web APIs. A server replies with HTTP 402 Payment Required and a Lightning invoice, and once the client pays, it receives a credential for later requests. 402 MCP lets AI agents handle that flow through their MCP client without manual copying of invoices or tokens.
No. The project states that no Lightning node is required and that several wallets are supported. You can connect a wallet that supports Nostr Wallet Connect, use Cashu or LNURLcash for payments, or rely on the QR fallback when a person wants to approve each payment manually.
Lightning Labs' lightning-agent-tools is the alternative that 402 MCP positions itself against. The main difference is that 402 MCP is wallet-provider agnostic, does not require a Lightning node, and works with multiple wallets. Encrypted credential caching is part of its design as well.
402 MCP can work with any MCP client that can launch a local stdio server, because that is how it communicates. Check your client's documentation for where to add a server entry. The server itself does not depend on a single AI vendor.
Verdict
402 MCP is a focused tool for developers who want AI agents to find and pay for L402 and x402 APIs without building payment plumbing by hand. It is free, MIT-licensed, and supports several payment routes along with Nostr-based discovery. It suits builders who are comfortable with Node.js and MCP configuration. People looking for a graphical app should choose a different program. Before connecting a funded wallet, set spending limits and check the latest version on the official website.