LightningEnable.Mcp 1.20.1

dotnet tool install --global LightningEnable.Mcp --version 1.20.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local LightningEnable.Mcp --version 1.20.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=LightningEnable.Mcp&version=1.20.1
                    
nuke :add-package LightningEnable.Mcp --version 1.20.1
                    

Lightning Enable MCP Server

A Model Context Protocol (MCP) server that enables AI agents to make Lightning Network payments. Wallet, invoice, L402, budget, and API-discovery tools work out of the box with just a wallet (free, no subscription). Producer tools (create_l402_challenge, verify_l402_payment) and Agent Service Agreement tools for agent-to-agent commerce over Nostr unlock with an Agentic Commerce subscription (from $99/mo) and LIGHTNING_ENABLE_API_KEY. One out-of-the-box tool, create_lightning_enable_account, self-provisions that API key — an agent with a wallet pays a ~100-sat activation fee and unlocks the subscription tools on the spot. See the MCP Complete Guide for the full tool list.

Overview

This MCP server provides tools for AI agents (like Claude) to:

  • Pay Lightning invoices — Send payments to any BOLT11 invoice
  • Manage payment budgets — Set per-request and per-session spending limits
  • Track payment history — Review all payments made during a session
  • Check wallet balance — Monitor your connected Lightning wallet
  • Discover APIs — Search the L402 API registry by keyword/category, or fetch a specific API's manifest
  • Access L402-protected APIs — Automatically pay L402 challenges for seamless API access
  • Create invoices — Generate BOLT11 invoices to receive payments
  • Exchange currency — Convert between USD and BTC (Strike)
  • Send on-chain — Send on-chain Bitcoin payments (Strike, LND)
  • Sell services (L402 Producer) — Create L402 payment challenges and verify payments, turning your agent into a full commerce participant that can both buy and sell

Installation

As a .NET global tool

dotnet tool install -g LightningEnable.Mcp

Python (pip or uvx)

pip install lightning-enable-mcp
# Or use uvx for no-install execution:
uvx lightning-enable-mcp

Docker

docker pull refinedelement/lightning-enable-mcp:latest

From source

git clone https://github.com/refined-element/lightning-enable-mcp
cd lightning-enable-mcp/dotnet
dotnet build src/LightningEnable.Mcp

Configuration

Environment Variables

Variable Required Default Description
STRIKE_API_KEY If using Strike - Strike API key
OPENNODE_API_KEY If using OpenNode - OpenNode API key
OPENNODE_ENVIRONMENT No production production or dev for testnet
NWC_CONNECTION_STRING If using NWC - Nostr Wallet Connect URI
LND_REST_HOST If using LND - LND REST API host
LND_MACAROON_HEX If using LND - LND admin macaroon in hex
LIGHTNING_ENABLE_API_KEY For producer tools - API key for create_l402_challenge and verify_l402_payment. Requires Agentic Commerce subscription.

Configure one wallet provider. If multiple are set, priority order is: LND > NWC > Strike > OpenNode.

Wallet Options

Best for users who want USD balance management, BTC price tracking, and easy on/off ramps. Supports L402 (returns preimage).

  1. Create an account at https://strike.me
  2. Get your API key from https://dashboard.strike.me
  3. Fund your account with BTC
export STRIKE_API_KEY="your-api-key"
Option 2: LND (Best for L402)

Run your own Lightning node for full control. LND always returns preimage — L402 is guaranteed to work.

export LND_REST_HOST="localhost:8080"
export LND_MACAROON_HEX="your-admin-macaroon-in-hex"
Option 3: Nostr Wallet Connect (NWC)

NWC connects to your Lightning wallet via the Nostr protocol. L402 compatibility depends on the wallet:

export NWC_CONNECTION_STRING="nostr+walletconnect://<pubkey>?relay=<relay-url>&secret=<secret>"
Option 4: OpenNode (Direct Payments Only)

Use your OpenNode account to pay invoices. Does not return preimage — cannot be used for L402.

export OPENNODE_API_KEY="your-api-key"
export OPENNODE_ENVIRONMENT="dev"  # Use testnet for testing

Claude Desktop Integration

Add to your Claude Desktop configuration file:

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/claude/claude_desktop_config.json

Using Strike:

{
  "mcpServers": {
    "lightning-enable": {
      "command": "dotnet",
      "args": ["tool", "run", "lightning-enable-mcp"],
      "env": {
        "STRIKE_API_KEY": "your-strike-api-key"
      }
    }
  }
}

Using NWC (CoinOS/CLINK):

{
  "mcpServers": {
    "lightning-enable": {
      "command": "dotnet",
      "args": ["tool", "run", "lightning-enable-mcp"],
      "env": {
        "NWC_CONNECTION_STRING": "nostr+walletconnect://your-pubkey?relay=wss://relay.getalby.com/v1&secret=your-secret"
      }
    }
  }
}

Using LND:

{
  "mcpServers": {
    "lightning-enable": {
      "command": "dotnet",
      "args": ["tool", "run", "lightning-enable-mcp"],
      "env": {
        "LND_REST_HOST": "localhost:8080",
        "LND_MACAROON_HEX": "your-admin-macaroon-in-hex"
      }
    }
  }
}

Available Tools

The canonical inventory is the Tools table in the root README: 26 tools (17 free / 9 gated). The sections below document a selected subset.

Deprecated aliases (accepted but unadvertised, forward to the new tool, removed in v2.0.0): confirm_paymentverify_confirmation_code; check_wallet_balance and get_all_balancesget_balance.

create_lightning_enable_account

Self-bootstrapping signup: activate a Lightning Enable account with a tiny Lightning payment (~100 sats) and get back a merchant API key. Requires NO Lightning Enable API key (it creates one) — only a connected wallet. On success the API key is merged into ~/.lightning-enable/config.json (existing keys preserved) so the producer/ASA tools unlock on the next restart. Above-threshold activation fees require a human-supplied confirmation code (same out-of-band flow as pay_l402_challenge).

Parameters:

  • email (required): Email address to register the account under
  • maxSats: Maximum sats to pay for activation (fee is ~100 sats). Default: 1000
  • confirmationNonce: Human-relayed confirmation code (only for an above-threshold fee)

Returns: { success, apiKey, merchantId, planTier, subscriptionStatus, trialEndsAt, dashboardUrl, activation, config }

pay_invoice

Pay a Lightning invoice directly and get the preimage as proof of payment.

Parameters:

  • invoice (required): BOLT11 Lightning invoice string to pay
  • maxSats: Maximum sats allowed to pay. Default: 1000

Returns:

  • success: Boolean indicating payment success
  • preimage: Hex preimage proving payment (if successful)
  • error: Error message (if failed)

SECURITY WARNING: This tool spends real Bitcoin. Always:

  • Use a dedicated wallet with limited funds
  • Set appropriate budget limits
  • Review payment history regularly

get_balance

Gets the connected wallet's balance. Supersedes check_wallet_balance and get_all_balances.

Parameters: None

Returns: A single superset shape — the scalar balance (wallet.balanceSats / wallet.balanceMsat), a balances[] array (all currencies for Strike; a single BTC entry otherwise), the session spending summary, and budget remaining.

get_receipts

Reads the durable, append-only payment receipt log at ~/.lightning-enable/receipts.jsonl. Every L402 payment appends one receipt (endpoint, amount, wallet, spend policy, session spend, and how to revoke the wallet). Unlike get_payment_history (in-memory, this session only), receipts persist across sessions — the audit + "pull the plug" record. Receipts never contain secrets (no preimage, macaroon, or connection string).

Parameters:

  • limit: Maximum number of recent receipts to return (1-200). Default: 20

Returns: { success, count, totalSatsInView, logFile, receipts, note } — the recent receipts plus a spend total and the log-file path.

get_payment_history

Lists recent payments made in the session.

Parameters:

  • limit: Maximum payments to return. Default: 10

Returns: List of payments with URL, amount, timestamp, and status

get_budget_status

View current budget configuration and session spending (read-only).

Parameters: None

Returns: Budget tiers, limits, and current session spending

configure_budget

Tightens the session spending limits. Tighten-only: an agent can only LOWER its caps — it can never raise them above the operator's ~/.lightning-enable/config.json limits (or an existing tighter runtime cap). To raise limits, the operator edits the config file. This prevents a prompt-injected agent from loosening its own caps and then draining the wallet.

Parameters:

  • perRequest: Max sats per single request. Default: 1000
  • perSession: Max total sats for the session. Default: 10000

create_invoice

Create a Lightning invoice to receive payments.

Parameters:

  • amountSats (required): Amount in satoshis
  • memo: Description for the invoice
  • expirySecs: Invoice expiry in seconds. Default: 3600

check_invoice_status

Check if a previously created invoice has been paid.

Parameters:

  • invoiceId (required): Invoice ID from create_invoice

access_l402_resource

Fetches a URL, automatically paying any L402 challenge. Requires a wallet that returns preimage (Strike, LND, CoinOS, CLINK, Alby Hub).

Parameters:

  • url (required): The URL to fetch
  • method: HTTP method (GET, POST, PUT, DELETE). Default: GET
  • headers: Optional headers as JSON object
  • body: Optional request body
  • maxSats: Maximum sats to pay. Default: 1000

test_l402_payment

Self-tests the wallet by paying the public 1-sat L402 test endpoint (/l402/test/ping) end to end. Proves the wallet is connected, returns a preimage, and can complete an L402 payment — the one-line answer to "is my wallet actually working?". Costs about 1 satoshi. Returns a plain verdict (passed / needs_confirmation / inconclusive / failed with a reason code). If your budget config requires confirmation for this amount, re-run with confirmationNonce set to the code the server prints to its console.

Parameters:

  • confirmationNonce: Confirmation code from the server console, if a prior call returned test="needs_confirmation". Omit on the first call.

pay_l402_challenge

Manually pays an L402 invoice when you have the macaroon and invoice separately.

Parameters:

  • invoice (required): BOLT11 invoice string
  • macaroon (required): Base64-encoded macaroon
  • maxSats: Maximum sats to pay. Default: 1000

Returns: L402 token for use in Authorization header

get_btc_price (Strike only)

Get the current Bitcoin price in USD.

exchange_currency (Strike only)

Convert between USD and BTC within your Strike wallet.

send_onchain (Strike, LND)

Send an on-chain Bitcoin payment to a Bitcoin address.

create_l402_challenge (Agentic Commerce)

Create an L402 payment challenge to charge another agent or user for accessing a resource. Returns a Lightning invoice and macaroon that the payer must pay before you grant access.

Requires: LIGHTNING_ENABLE_API_KEY with an Agentic Commerce subscription (from $99/mo).

Parameters:

  • resource (required): Resource identifier — URL, service name, or description of what you're charging for
  • priceSats (required): Price in satoshis to charge
  • description: Description shown on the Lightning invoice

Returns:

  • challenge.invoice: BOLT11 Lightning invoice for the payer
  • challenge.macaroon: Base64-encoded macaroon
  • challenge.paymentHash: Payment hash for tracking
  • challenge.expiresAt: Invoice expiration time
  • instructions: Instructions for the payer and verification steps

verify_l402_payment (Agentic Commerce)

Verify an L402 token (macaroon + preimage) to confirm payment was made. Use this after receiving an L402 token from a payer to validate they paid before granting access.

Requires: LIGHTNING_ENABLE_API_KEY with an Agentic Commerce subscription (from $99/mo).

Parameters:

  • macaroon (required): Base64-encoded macaroon from the L402 token
  • preimage (required): Hex-encoded preimage (proof of payment)

Returns:

  • valid: Boolean — whether the payment is verified
  • resource: The resource identifier the payment was for

See AI Spending Security for full security guidance.

L402 Wallet Compatibility

L402 requires the payment preimage to create credentials. Not all wallets return it:

Wallet Returns Preimage L402 Works
LND Always Yes
Strike Yes Yes
CoinOS (NWC) Yes Yes
CLINK (NWC) Yes Yes
Alby (NWC) Yes Yes
OpenNode No No
Primal (NWC) No No

Try It: Lightning Enable Store

The Lightning Enable Store is a live L402-powered web store where AI agents can purchase physical merchandise using Bitcoin Lightning payments.

Ask Claude: "Buy me a Lightning Enable t-shirt from store.lightningenable.com"

The store demonstrates the full L402 flow: browse catalog, checkout (get 402), pay invoice, claim with L402 credential.

Usage Examples

Paying a Lightning Invoice

You: Pay this Lightning invoice: lnbc100n1p3...

Claude: I'll pay that invoice for you.
[Calls pay_invoice with invoice="lnbc100n1p3..."]

Payment successful! Here's the preimage as proof of payment: abc123...

L402 API Access

You: Use access_l402_resource to fetch data from https://api.paywall.example.com/data

Claude: I'll fetch that URL with L402 payment support.
[Calls access_l402_resource with url="https://api.paywall.example.com/data"]

The request required a payment of 50 sats which was automatically paid.
Here's the response: ...

Selling a Service (L402 Producer Flow)

With the producer tools, your agent can charge other agents for services — making it a full commerce participant that can both buy and sell.

Agent B: I need weather data for New York.

Agent A (seller): I'll create a payment challenge for that.
[Calls create_l402_challenge with resource="weather/new-york", priceSats=10, description="NYC weather data"]

Here's your invoice — pay 10 sats to get the data:
  Invoice: lnbc100n1p3...
  Macaroon: AgELbGl...

Agent B: [Pays the invoice using pay_invoice or pay_l402_challenge, gets preimage]
Here's my L402 token: AgELbGl...:abc123def...

Agent A: Let me verify that payment.
[Calls verify_l402_payment with macaroon="AgELbGl...", preimage="abc123def..."]

Payment verified! Here's your weather data: Temperature: 72°F, Humidity: 45%...

This enables agent-to-agent commerce: any agent with an Agentic Commerce subscription can create paywalls, and any agent with a Lightning wallet can pay them.

Setting Budget Limits

You: Configure the budget to allow max 500 sats per request and 5000 sats total

Claude: I'll configure those budget limits.
[Calls configure_budget with perRequest=500, perSession=5000]

Budget configured:
- Max per request: 500 sats
- Max per session: 5000 sats
- Currently spent: 0 sats

Security Considerations

  1. Protect your wallet credentials: NWC strings, API keys, and macaroons grant access to your wallet
  2. Set appropriate budget limits: Start with low limits and increase as needed
  3. Review payment history: Check what payments are being made
  4. Use a dedicated wallet: Never use your main wallet or business funds for AI agents

Troubleshooting

"No wallet configured"

Set one of: STRIKE_API_KEY, LND_REST_HOST + LND_MACAROON_HEX, NWC_CONNECTION_STRING, or OPENNODE_API_KEY.

"Budget check failed"

The requested payment exceeds your configured limits. Use configure_budget or get_budget_status to check.

"Payment failed"

Check:

  • Wallet has sufficient balance
  • Invoice hasn't expired
  • Wallet connection is working

"L402 payment succeeded but access failed"

Your wallet doesn't return preimage. Switch to LND, Strike, CoinOS, or CLINK.

Development

Building from source

cd lightning-enable-mcp/dotnet
dotnet build src/LightningEnable.Mcp

Running tests

dotnet test tests/LightningEnable.Mcp.Tests

Publishing

cd dotnet/src/LightningEnable.Mcp
# Clear any prior packed artifacts BEFORE packing, so the wildcard push
# below targets only this build's output. `dotnet pack -o` writes the new
# .nupkg in but does NOT clear pre-existing files — the rm step is what
# makes the push deterministic.
rm -f ./artifacts/*.nupkg
dotnet pack -c Release -o ./artifacts
dotnet nuget push ./artifacts/LightningEnable.Mcp.*.nupkg --source nuget.org

License

MIT License - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.20.1 64 7/30/2026
1.20.0 39 7/30/2026
1.19.0 128 7/25/2026
1.18.0 104 7/24/2026
1.17.0 100 7/24/2026
1.16.2 95 7/24/2026
1.16.1 102 7/23/2026
1.16.0 98 7/17/2026
1.15.0 122 7/7/2026
1.14.0 115 7/5/2026
1.13.0 108 7/4/2026
1.12.13 121 6/8/2026
1.12.12 114 6/8/2026
1.12.11 125 6/6/2026
1.12.10 121 6/6/2026
1.12.9 136 5/9/2026
1.12.8 127 5/4/2026
1.12.7 107 5/4/2026
1.12.6 108 5/3/2026
1.12.5 111 5/3/2026
Loading failed

v1.16.1: Fixes a settled-but-unprovable payment being reported as a retryable failure, which could invite the caller to retry and double-pay. On a settled payment (no provider error), any unusable preimage — missing, empty, null, wrong-type, or undecodable base64 — is now reported as a success WITHOUT a preimage (the spend is recorded once, with a tracking id and a do-not-retry instruction), on both ports and both the NWC and LND wallets; a genuine (non-settled) failure stays a retryable failure with no phantom spend. — v1.16.0: Payment-correctness fixes — upgrade recommended if you pay through OpenNode, Strike, or Coinos. (1) Fixes OpenNode payments reporting a fabricated preimage (an internal withdrawal ID) as proof of payment — L402 treats that field as proof, so the resulting Authorization header was always rejected: money spent, no access, and a payment record that falsely claimed a valid preimage. A settled payment with no preimage now reports preimage: null plus a tracking ID and a warning that it cannot authenticate. Same fix for the Strike payment ID. (2) Fixes in-flight (pending/processing) payments being reported as completed successfully — a payment that can still FAIL is now its own outcome (success: false, status: "pending") with a tracking ID to poll and an instruction not to retry; it still counts against the budget. (3) Preimages are now validated (64-char hex) at every wallet boundary — OpenNode, Strike, NWC and LND, in both ports. This closes the .NET NWC wallet accepting a Coinos UUID as a preimage after detecting it; the Python NWC wallet, which checked that every character was a hex digit but never the length, so a short value like "deadbeef" passed; and both LND wallets (Python and .NET), which returned whatever arrived unchecked on the assumption LND always returns a real preimage. A settled payment whose "preimage" fails the check is reported as a success WITHOUT a preimage, never as proof. (4) A zero/malformed price in a third-party API manifest no longer reads as affordable_calls: "unlimited" — an unknown price reads "unknown". (5) check_budget no longer invents a 100,000-sat per-request limit when no cap is configured. (6) PriceService docs corrected: there is no stale-price fallback; it fails closed (no behavior change). No hardcoded BTC rate anywhere. — v1.12.11: (Python packaging) secp256k1 is now an OPTIONAL dependency — `pip install lightning-enable-mcp` works on every platform with no build toolchain (it was failing on Windows because secp256k1 is a C-extension with no Windows wheel). NWC wallet users add the extra: `pip install lightning-enable-mcp[nwc]`. .NET is unaffected (managed crypto). No functional change vs 1.12.10. — v1.12.10: Funds-safety hardening of the agent payment path. (1) Out-of-band confirmation — the confirmation code for above-threshold payments is now printed only to the server console/stderr (visible to the human operator), never returned in a tool result, so a prompt-injected agent cannot read and self-approve its own payment. (2) send_onchain (irreversible) ALWAYS requires confirmation and fails closed if the budget service is unavailable. (3) Confirmation codes are bound to the exact amount AND tool they approved (no cross-tool / cross-amount replay). (4) configure_budget added to .NET, tighten-only — an agent can lower its caps but never raise them above the operator's ~/.lightning-enable/config.json limits. (5) Budget checks fail closed when the BTC price feed is unavailable (3 sources, no stale fallback). (6) NWC response preimage no longer logged.