LightningEnable.Mcp
1.12.13
dotnet tool install --global LightningEnable.Mcp --version 1.12.13
dotnet new tool-manifest
dotnet tool install --local LightningEnable.Mcp --version 1.12.13
#tool dotnet:?package=LightningEnable.Mcp&version=1.12.13
nuke :add-package LightningEnable.Mcp --version 1.12.13
Lightning Enable MCP Server
A Model Context Protocol (MCP) server that enables AI agents to make Lightning Network payments. 15 tools work out of the box (free, no subscription). 8 tools require an Agentic Commerce subscription (from $99/mo) and LIGHTNING_ENABLE_API_KEY: 2 producer tools (create_l402_challenge, verify_l402_payment) and 6 Agent Service Agreement tools for agent-to-agent commerce over Nostr.
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
Option 1: Strike (Recommended)
Best for users who want USD balance management, BTC price tracking, and easy on/off ramps. Supports L402 (returns preimage).
- Create an account at https://strike.me
- Get your API key from https://dashboard.strike.me
- 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:
- CoinOS (https://coinos.io) — Free, L402 works
- CLINK (https://clink.tools) — Nostr-native, L402 works
- Alby Hub (https://albyhub.com) — Self-custody, L402 verified
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
pay_invoice
Pay a Lightning invoice directly and get the preimage as proof of payment.
Parameters:
invoice(required): BOLT11 Lightning invoice string to paymaxSats: Maximum sats allowed to pay. Default: 1000
Returns:
success: Boolean indicating payment successpreimage: 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
check_wallet_balance
Checks the connected wallet balance and session spending.
Parameters: None
Returns: Wallet balance in satoshis, session spending summary, budget remaining
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: 1000perSession: Max total sats for the session. Default: 10000
create_invoice
Create a Lightning invoice to receive payments.
Parameters:
amountSats(required): Amount in satoshismemo: Description for the invoiceexpirySecs: 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 fetchmethod: HTTP method (GET, POST, PUT, DELETE). Default: GETheaders: Optional headers as JSON objectbody: Optional request bodymaxSats: Maximum sats to pay. Default: 1000
pay_l402_challenge
Manually pays an L402 invoice when you have the macaroon and invoice separately.
Parameters:
invoice(required): BOLT11 invoice stringmacaroon(required): Base64-encoded macaroonmaxSats: 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.
get_all_balances (Strike only)
Get all currency balances (USD and BTC).
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 forpriceSats(required): Price in satoshis to chargedescription: Description shown on the Lightning invoice
Returns:
challenge.invoice: BOLT11 Lightning invoice for the payerchallenge.macaroon: Base64-encoded macaroonchallenge.paymentHash: Payment hash for trackingchallenge.expiresAt: Invoice expiration timeinstructions: 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 tokenpreimage(required): Hex-encoded preimage (proof of payment)
Returns:
valid: Boolean — whether the payment is verifiedresource: 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
- Protect your wallet credentials: NWC strings, API keys, and macaroons grant access to your wallet
- Set appropriate budget limits: Start with low limits and increase as needed
- Review payment history: Check what payments are being made
- 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
dotnet pack -c Release
dotnet nuget push bin/Release/LightningEnable.Mcp.1.6.2.nupkg --source nuget.org
License
MIT License - see LICENSE for details.
Related Projects
- L402-Requests (Python) - Auto-paying L402 HTTP client for Python
- L402-Requests (.NET) - Auto-paying L402 HTTP client for .NET
- Lightning Enable API - L402-protected API server
- Lightning Enable Store - Live L402 commerce demo
- Lightning Enable Docs - Full documentation
- Model Context Protocol - MCP specification
- Nostr Wallet Connect - NIP-47 specification
| Product | Versions 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. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.12.13 | 87 | 6/8/2026 |
| 1.12.12 | 93 | 6/8/2026 |
| 1.12.11 | 99 | 6/6/2026 |
| 1.12.10 | 96 | 6/6/2026 |
| 1.12.9 | 124 | 5/9/2026 |
| 1.12.8 | 116 | 5/4/2026 |
| 1.12.7 | 94 | 5/4/2026 |
| 1.12.6 | 98 | 5/3/2026 |
| 1.12.5 | 98 | 5/3/2026 |
| 1.12.4 | 128 | 4/28/2026 |
| 1.12.3 | 120 | 4/18/2026 |
| 1.12.2 | 166 | 4/10/2026 |
| 1.12.1 | 157 | 3/22/2026 |
| 1.12.0 | 136 | 3/21/2026 |
| 1.11.5 | 141 | 3/19/2026 |
| 1.11.4 | 144 | 3/17/2026 |
| 1.11.3 | 149 | 3/16/2026 |
| 1.11.2 | 143 | 3/15/2026 |
| 1.11.1 | 142 | 3/15/2026 |
| 1.11.0 | 138 | 3/15/2026 |
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.