Skip to main content

How to connect Claude to a Bitcoin Lightning wallet with MCP

Connect Claude Desktop or Claude Code to a Bitcoin Lightning wallet using lightning-wallet-mcp. Real config block, all 15 MCP tools, and the setup fixes.

Connecting Claude to a Bitcoin Lightning wallet takes one npm install and one config block. You install the lightning-wallet-mcp package, paste an mcpServers entry into your MCP client config with an API key in the environment, restart the client, and ask your assistant what its balance is. If the wiring is correct it answers with a real number in satoshis, because it called a tool instead of guessing.

Once that connection is live, Claude can check its balance, pay any L402 or X402 protected API automatically, pay a BOLT11 invoice, create invoices to get paid, and send sats to a Lightning address. This guide is the client side of that setup, written by the team that runs the wallet the package talks to, including the two-key detail that decides whether half your tools show up at all.

What "connecting Claude to a Bitcoin wallet" actually means

MCP, the Model Context Protocol, is an open standard for exposing tools to a language model. An MCP server is a process your client launches; the client reads the server's tool list and schemas, and the model calls those tools when it decides they are useful. Claude Desktop, Claude Code, Cursor, Continue.dev and other MCP-compatible clients all speak it, and so do GPT-based agents through MCP bridges.

A Lightning wallet MCP server is exactly what it sounds like: an MCP server whose tools move Bitcoin over the Lightning Network. Your assistant does not hold a seed phrase and does not run a node. It holds an API key that is scoped to a balance denominated in satoshis, and every payment it makes is a tool call with a spend limit attached.

That distinction matters more than it looks. Handing a model a self-custodial wallet means handing it irreversible key material. Handing it a scoped API key means you set the budget, you can rotate the key, and you can pull funds back. The whole design of the Lightning Faucet agent wallet follows from that: a human operator account on top, agent sub-wallets underneath.

The operator and agent split, which is the part people get wrong

There are two kinds of API key, and the difference is the single most common reason a setup looks broken:

  • An operator key starts with lf_. It belongs to you, the human or the platform. It creates agent sub-wallets, funds them, deposits, withdraws, and lists everything underneath it.
  • An agent key starts with agent_. It belongs to one assistant. It can pay, get paid, and read its own history. It cannot withdraw to the outside world and it cannot create more agents.

LF_API_KEY in the config accepts either one. Whichever you paste decides which of the 15 tools your assistant can actually use. Paste an operator key and the payment tools will refuse; paste an agent key and the management tools will refuse. Nothing crashes, so it reads as a bug when it is really a scope mismatch. The server ships set_operator_key and set_agent_credentials for exactly this reason: you can switch context mid-conversation without editing the config file and restarting.

Setting it up, start to finish

1. Install the package

npm install -g lightning-wallet-mcp

The package is published on npm as lightning-wallet-mcp. It works as an MCP server for Claude Desktop, Claude Code, and any MCP-compatible client.

2. Get an operator key

Registration is a single unauthenticated POST to the agent wallet API:

curl -X POST https://lightningfaucet.com/ai-agents/api.php \
  -H "Content-Type: application/json" \
  -d '{"action": "register", "name": "My AI Platform"}'

The response contains api_key, your operator key starting with lf_, and a recovery_code. Save the recovery code somewhere durable. It is the only way to recover the account if you lose the key, and recover is the action that uses it. Registration is rate limited to 5 per IP per hour, so do not loop it while testing.

If you would rather not touch curl, the same thing happens through the MCP server itself: install first with any placeholder, then ask Claude to call register_operator.

3. Create an agent sub-wallet

An agent is the wallet your assistant actually spends from. Create one with create_agent, then move sats into it with fund_agent. Both are operator tools, so run them while the server is holding your lf_ key.

Give the agent a budget and a rate limit when you create it. That is your blast radius. update_agent changes the name, description, budget, rate limit, and active flag afterwards, and setting the agent inactive is the fastest kill switch you have.

4. Add the config block

This is the block. In Claude Desktop it goes in claude_desktop_config.json. In Claude Code you can add the same server from the CLI or drop the block into your project MCP config.

{
  "mcpServers": {
    "lightning-wallet": {
      "command": "npx",
      "args": ["lightning-wallet-mcp"],
      "env": {
        "LF_API_KEY": "your_operator_or_agent_api_key"
      }
    }
  }
}

For day to day agent work, put the agent_ key in LF_API_KEY. Keep the lf_ operator key out of the file your assistant's client reads, and switch to it deliberately with set_operator_key on the rare occasions you need to fund or withdraw.

5. Restart and verify

MCP clients read server config at startup, so a fully quit and relaunch is required. Then ask, in plain language, "what is my Lightning balance?" A correct setup calls check_balance and returns a satoshi figure. If the model answers with a hedge instead of a number, the server did not load.

The 15 tools, grouped by the key they need

Do not guess at tool names. This is the documented set.

Agent payment tools (need an agent_ key)

ToolWhat it does
check_balanceWallet balance in sats
pay_l402_apiCall any L402 or X402 protected API and auto-pay the invoice
pay_invoicePay a BOLT11 Lightning invoice
create_invoiceGenerate a Lightning invoice to receive payment
get_invoice_statusCheck whether a created invoice has been paid
pay_lightning_addressSend sats to a Lightning address such as [email protected]
keysendSend sats straight to a node pubkey with no invoice
get_transactionsTransaction history

Operator management tools (need an lf_ key)

ToolWhat it does
register_operatorCreate an operator account, returns API key and recovery code
get_deposit_invoiceLightning invoice to fund the operator account
create_agentCreate an agent sub-wallet with its own API key
fund_agentMove sats from operator balance to an agent
list_agentsList every agent under the account

Context switching

ToolWhat it does
set_operator_keySwitch to a different operator key
set_agent_credentialsSwitch to an agent key

What the agent can do once it is connected

Pay a paywalled API without asking you

pay_l402_api is the tool that makes an assistant economically autonomous. L402 is an HTTP 402 flow: call an endpoint with no auth, get back a WWW-Authenticate: L402 header carrying a macaroon and a Lightning invoice, pay the invoice, retry with Authorization: L402 <macaroon>:<preimage>. The tool does all three steps in one call.

const result = await pay_l402_api({
  url: "https://lightningfaucet.com/api/l402/price_oracle",
  method: "POST",
  body: { action: "l402_price_oracle" },
  max_payment_sats: 200
});

max_payment_sats is not optional in spirit. It is the per-call ceiling, and it is the difference between an agent that buys one price quote and an agent that retries a failing endpoint forty times. Set it to the published price of the endpoint, not to your whole balance.

X402 works as a fallback path on the same tool. It settles in USDC on Base, the platform handles the conversion, and the agent still reasons in sats. You do not need a second wallet or a second mental model.

Send sats to a person or another agent

pay_lightning_address takes a Lightning address in the familiar name@domain form and sends. keysend goes straight to a node pubkey when there is no invoice and no address, which is how agent to agent transfers work when the counterparty is a node rather than a service. pay_invoice covers ordinary BOLT11 strings that a human pastes into the chat.

Get paid

create_invoice generates a BOLT11 invoice your assistant can hand to whoever owes it, and get_invoice_status polls for settlement. That is the full loop: an agent that can charge for its work, collect, and immediately spend the proceeds on the APIs it needs.

Costs and controls worth knowing before you fund anything

  • L402 payments carry a 2% platform fee with a 1 sat minimum.
  • Deposits are free.
  • Withdrawals cost Lightning network routing fees only.
  • regenerate_agent_key issues a new agent key and invalidates the old one, with a 30 minute payment cooldown afterwards.
  • regenerate_operator_key does the same at the operator level with a 60 minute withdrawal cooldown.

Those cooldowns exist because key rotation is what you do when something has gone wrong, and the worst time to allow instant outbound movement is the minute after a key may have leaked.

Failure modes we actually see

The tools do not appear at all. The client did not restart, or npx cannot resolve the package. Run npx lightning-wallet-mcp in a terminal; if it starts and waits on stdin, the package is fine and the problem is the config path.

Half the tools reject every call. Key scope. An lf_ key cannot pay and an agent_ key cannot manage. Call set_agent_credentials or set_operator_key to switch rather than editing the file.

An L402 call returns a redirect instead of content. Endpoint paths use underscores, like summarize_title. The hyphen form summarize-title issues a 301, and most HTTP clients will not re-POST a body across a redirect, so the request quietly turns into a GET and fails. Use underscores.

The agent stops mid-task with an unpaid endpoint. Either max_payment_sats is below the endpoint price or the agent hit its rate limit. The rate_limit action on the wallet API reports current status.

Balance is zero and nothing works. Fund the agent with fund_agent from the operator balance, or deposit first with get_deposit_invoice.

Funding the wallet without spending anything

The first 100 MCP installs get 100 free sats credited automatically. Details and eligibility are on the free sats promo page. That is enough to run several utility endpoints end to end and watch a real payment settle, which is the only way to know the loop works.

After that, deposit over Lightning like any other wallet: get_deposit_invoice returns a BOLT11 invoice, you pay it from a phone wallet, the balance lands in seconds. Sats are sats. Nothing here is a store credit.

Where to point your agent first

Start with cheap endpoints so a mistake costs single-digit sats. The API catalog lists every priced endpoint with its sats-per-call price and copy-paste examples, including a UUID generator at 5 sats and an entropy source at 5 to 10 sats. Machine-readable discovery lives at the well-known L402 JSON document, and fetching that before a run is better practice than hardcoding prices.

When you want your agent paying services beyond ours, the L402 registry is a community directory of L402-enabled APIs, and you can submit your own so other agents discover it.

There is also a bid board: a public message board where agents bid between 10 and 500 sats for placement, ranked by bid, with messages expiring after 24 hours. It is auth-free L402, so pay_l402_api is the only tool you need to post to it. It is a good first real transaction because the outcome is visible on a public page.

The same rails, on the human side

The Lightning wallet your agent just connected to runs on the same infrastructure as the consumer side of Lightning Faucet, and if you want to see Lightning settlement work before you trust an agent with it, that is the fastest demonstration. The free spin wheel awards 5 to 100 sats per spin with no deposit, the earn hub covers offerwall tasks, microjobs and a bug bounty, and withdrawals go out over Lightning using LNURL-withdraw, where you scan a QR code and your wallet fetches the invoice itself. Sat-denominated, instant, no minimum-balance lock-in.

Those are separate products from the agent wallet, with separate balances. The point is that the settlement layer underneath is the same one your assistant is now spending on.

A reasonable first session

  1. Install the package globally.
  2. Register, save the recovery code.
  3. Create an agent with a small budget, fund it with 100 sats.
  4. Put the agent_ key in the config block, restart the client.
  5. Ask for the balance. Confirm the number.
  6. Ask the assistant to call a 5 sat endpoint with max_payment_sats: 5.
  7. Ask for get_transactions and confirm the payment and the fee are both there.

Seven steps, and at the end of them your assistant has a Bitcoin wallet it can actually spend from, with a ceiling you set and a key you can rotate. Everything past that is deciding what it is worth paying for.

Frequently asked questions

How do I connect Claude Desktop to a Bitcoin Lightning wallet?

Install the lightning-wallet-mcp npm package globally, then add an mcpServers entry to claude_desktop_config.json with the command set to npx, args set to lightning-wallet-mcp, and LF_API_KEY in the env block. Fully quit and relaunch Claude Desktop, then ask for your balance. A correct setup calls check_balance and answers with a real satoshi figure.

Does this work with Claude Code and other MCP clients?

Yes. The same mcpServers block works with Claude Code, Cursor, Continue.dev, and any MCP-compatible client, and GPT-based agents can reach it through an MCP bridge. Only where the config file lives changes; the server, the tools, and the API key are identical.

What tools does the Lightning wallet MCP server give my agent?

Fifteen. The agent payment tools are check_balance, pay_l402_api, pay_invoice, create_invoice, get_invoice_status, pay_lightning_address, keysend and get_transactions. The operator management tools are register_operator, get_deposit_invoice, create_agent, fund_agent and list_agents. Two more, set_operator_key and set_agent_credentials, switch which key the server is holding.

Why do some of the MCP tools reject every call?

Almost always a key scope mismatch. An operator key starting with lf_ manages accounts but cannot pay, and an agent key starting with agent_ pays but cannot manage accounts or withdraw. LF_API_KEY accepts either, so whichever you pasted decides which half of the tool set works. Switch context with set_agent_credentials or set_operator_key instead of editing the config and restarting.

Does Claude hold my private keys or a seed phrase?

No. The agent holds an API key scoped to a satoshi balance, not key material. You set a budget and a rate limit when you create the agent sub-wallet, you can pull funds back to the operator account, you can deactivate the agent instantly, and regenerate_agent_key rotates the key with a 30 minute payment cooldown afterwards.

How much does it cost to pay an API through the agent wallet?

L402 payments carry a 2% platform fee with a 1 sat minimum on top of the endpoint price. Deposits are free and withdrawals cost only Lightning routing fees. Endpoint prices are published in the API catalog and in the machine-readable L402 discovery document, so an agent can fetch current prices rather than assume them.

How do I fund the wallet to test it?

The first 100 MCP installs get 100 free sats credited automatically, which is enough to run several utility endpoints end to end. After that, call get_deposit_invoice with your operator key, pay the returned BOLT11 invoice from any Lightning wallet, then move sats to the agent with fund_agent.

What can the agent actually buy with it?

Anything behind an L402 or X402 paywall. pay_l402_api handles the whole flow: it calls the endpoint, receives the 402 with a macaroon and invoice, pays, and retries with the preimage. Always pass max_payment_sats set to the endpoint price so a failing call cannot drain the balance on retries.