402-mcp
v3.15.2AI agents discover, pay for, and consume any Lightning-gated API autonomously
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
l402-config
Introspect 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-discover
Probe 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.
| Parameter | Type | Description |
|---|---|---|
url * | string | The URL to probe for L402 pricing |
method | string | HTTP method to use |
l402-fetch
Fetch 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 autoPay to true for seamless access. When a 402 is returned with tiers, present the pricing options to the user and use l402-buy-credits to purchase their chosen tier. For widget hosts, call l402-fetch-pr…
| Parameter | Type | Description |
|---|---|---|
url * | string | The primary URL to request. When using search results, pass the first URL here and all URLs in the urls field. |
autoPay | boolean | Automatically pay if within MAX_AUTO_PAY_SATS budget |
body | string | Request body (for POST/PUT) |
headers | object | Additional request headers |
method | string | HTTP method |
pubkey | string | Service pubkey from l402-search results — used to share credentials across all transport URLs for the same service |
txHash | string | Transaction hash from a completed x402 on-chain payment. When provided, retries the request with X-Payment header for server verification. |
urls | array | All transport URLs from l402-search results (clearnet, onion, HNS). When present, transports are tried in preference order with automatic fallback on connection failure. |
l402-pay
Confirm 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.
| Parameter | Type | Description |
|---|---|---|
invoice | string | BOLT-11 invoice to pay. Optional if paymentHash matches a cached challenge from l402-discover. |
macaroon | string | Macaroon from the L402 challenge. Optional if paymentHash matches a cached challenge. |
method | string | Payment method override. Defaults to wallet priority: NWC > Cashu > human. |
paymentHash | string | Payment hash to look up cached challenge from l402-discover. |
l402-credentials
List all stored L402 credentials. Shows origin, cached credit balance, and server type. Balance values are cached and may be stale; check lastUsed timestamp.
l402-balance
Check 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.
| Parameter | Type | Description |
|---|---|---|
origin * | string | The server origin (e.g. https://api.example.com) |
l402-store-token
Store 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.
| Parameter | Type | Description |
|---|---|---|
token * | string | The L402 token in macaroon:preimage format |
url * | string | The service URL this token is for |
l402-buy-credits
Buy 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.
| Parameter | Type | Description |
|---|---|---|
url * | string | The toll-booth server URL |
amountSats | integer | Amount in sats to purchase. Omit to list available tiers. |
method | string | Payment method override |
l402-redeem-cashu
Redeem 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.
| Parameter | Type | Description |
|---|---|---|
token * | string | Cashu token string to redeem (e.g. cashuAey...) |
url * | string | The toll-booth server URL |
l402-search
Search 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.
| Parameter | Type | Description |
|---|---|---|
query * | string | Search query to match against service names, descriptions, and capabilities |
maxResults | integer | Maximum number of results to return (default 20) |
paymentMethod | string | Filter by payment method (e.g. "l402", "cashu", "x402", "xcashu") |
relays | array | Nostr relay URLs to query (defaults to popular public relays) |
timeout | integer | Relay subscription timeout in milliseconds (default 5000) |
topics | array | Filter by topic tags (e.g. ["ai", "data"]) |
l402-fetch-preview
Preview payment requirements for a URL without spending any sats. Returns cost, protocol, and payment method so a confirmation dialog can be shown. Use this before l402-fetch to give the user a chance to approve or cancel payment. For widget hosts, the result drives a payment confirmation dialog.
| Parameter | Type | Description |
|---|---|---|
url * | string | URL to preview payment requirements for |
headers | object | Additional request headers |
method | string | HTTP method |
pubkey | string | Nostr pubkey for xcashu auth |
urls | array | Batch: multiple URLs to preview |