402-mcp

v3.15.2
dev.forgesworn/402-mcp Checked 16 hours ago Published 7 months ago

AI 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.

ParameterTypeDescription
url *stringThe URL to probe for L402 pricing
methodstringHTTP 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…

ParameterTypeDescription
url *stringThe primary URL to request. When using search results, pass the first URL here and all URLs in the urls field.
autoPaybooleanAutomatically pay if within MAX_AUTO_PAY_SATS budget
bodystringRequest body (for POST/PUT)
headersobjectAdditional request headers
methodstringHTTP method
pubkeystringService pubkey from l402-search results — used to share credentials across all transport URLs for the same service
txHashstringTransaction hash from a completed x402 on-chain payment. When provided, retries the request with X-Payment header for server verification.
urlsarrayAll 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.

ParameterTypeDescription
invoicestringBOLT-11 invoice to pay. Optional if paymentHash matches a cached challenge from l402-discover.
macaroonstringMacaroon from the L402 challenge. Optional if paymentHash matches a cached challenge.
methodstringPayment method override. Defaults to wallet priority: NWC > Cashu > human.
paymentHashstringPayment 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.

ParameterTypeDescription
origin *stringThe 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.

ParameterTypeDescription
token *stringThe L402 token in macaroon:preimage format
url *stringThe 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.

ParameterTypeDescription
url *stringThe toll-booth server URL
amountSatsintegerAmount in sats to purchase. Omit to list available tiers.
methodstringPayment 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.

ParameterTypeDescription
token *stringCashu token string to redeem (e.g. cashuAey...)
url *stringThe toll-booth server URL

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.

ParameterTypeDescription
url *stringURL to preview payment requirements for
headersobjectAdditional request headers
methodstringHTTP method
pubkeystringNostr pubkey for xcashu auth
urlsarrayBatch: multiple URLs to preview