@lightninglabs/lightning-mcp-server 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +36 -0
- package/.claude-plugin/plugin.json +12 -0
- package/README.md +307 -0
- package/bin/lightning-mcp-server +15 -0
- package/docs/architecture.md +455 -0
- package/docs/commerce.md +357 -0
- package/docs/l402-and-lnget.md +267 -0
- package/docs/mcp-server.md +285 -0
- package/docs/quickref.md +263 -0
- package/docs/security.md +298 -0
- package/docs/two-agent-setup.md +394 -0
- package/package.json +52 -0
- package/postinstall.js +160 -0
- package/skills/aperture/SKILL.md +330 -0
- package/skills/aperture/scripts/install.sh +68 -0
- package/skills/aperture/scripts/setup.sh +155 -0
- package/skills/aperture/scripts/start.sh +81 -0
- package/skills/aperture/scripts/stop.sh +57 -0
- package/skills/aperture/templates/aperture-regtest.yaml +36 -0
- package/skills/aperture/templates/aperture.yaml.template +64 -0
- package/skills/aperture/templates/docker-compose-aperture.yml +59 -0
- package/skills/commerce/SKILL.md +211 -0
- package/skills/lib/config-gen.sh +127 -0
- package/skills/lib/rest.sh +69 -0
- package/skills/lightning-security-module/SKILL.md +253 -0
- package/skills/lightning-security-module/references/architecture.md +133 -0
- package/skills/lightning-security-module/scripts/docker-start.sh +117 -0
- package/skills/lightning-security-module/scripts/docker-stop.sh +53 -0
- package/skills/lightning-security-module/scripts/export-credentials.sh +268 -0
- package/skills/lightning-security-module/scripts/install.sh +178 -0
- package/skills/lightning-security-module/scripts/setup-signer.sh +307 -0
- package/skills/lightning-security-module/scripts/start-signer.sh +152 -0
- package/skills/lightning-security-module/scripts/stop-signer.sh +240 -0
- package/skills/lightning-security-module/templates/docker-compose-signer.yml +35 -0
- package/skills/lightning-security-module/templates/signer-lnd.conf.template +69 -0
- package/skills/lnd/SKILL.md +441 -0
- package/skills/lnd/profiles/debug.env +4 -0
- package/skills/lnd/profiles/default.env +3 -0
- package/skills/lnd/profiles/regtest.env +4 -0
- package/skills/lnd/profiles/taproot.env +3 -0
- package/skills/lnd/profiles/wumbo.env +3 -0
- package/skills/lnd/references/security.md +156 -0
- package/skills/lnd/scripts/create-wallet.sh +464 -0
- package/skills/lnd/scripts/docker-start.sh +256 -0
- package/skills/lnd/scripts/docker-stop.sh +109 -0
- package/skills/lnd/scripts/import-credentials.sh +145 -0
- package/skills/lnd/scripts/install.sh +195 -0
- package/skills/lnd/scripts/lncli.sh +150 -0
- package/skills/lnd/scripts/start-lnd.sh +241 -0
- package/skills/lnd/scripts/stop-lnd.sh +218 -0
- package/skills/lnd/scripts/unlock-wallet.sh +134 -0
- package/skills/lnd/templates/docker-compose-regtest.yml +122 -0
- package/skills/lnd/templates/docker-compose-watchonly.yml +71 -0
- package/skills/lnd/templates/docker-compose.yml +49 -0
- package/skills/lnd/templates/litd-regtest.conf.template +61 -0
- package/skills/lnd/templates/litd-watchonly.conf.template +57 -0
- package/skills/lnd/templates/litd.conf.template +88 -0
- package/skills/lnd/templates/lnd.conf.template +91 -0
- package/skills/lnget/SKILL.md +288 -0
- package/skills/lnget/scripts/install.sh +69 -0
- package/skills/macaroon-bakery/SKILL.md +179 -0
- package/skills/macaroon-bakery/scripts/bake.sh +337 -0
- package/skills/mcp-lnc/SKILL.md +280 -0
- package/skills/mcp-lnc/scripts/configure.sh +130 -0
- package/skills/mcp-lnc/scripts/install.sh +103 -0
- package/skills/mcp-lnc/scripts/setup-claude-config.sh +162 -0
- package/skills/mcp-lnc/templates/env.template +16 -0
- package/versions.env +23 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
> How Lightning Agent Tools is structured and how its components interact.
|
|
4
|
+
|
|
5
|
+
Lightning Agent Tools is composed of seven skills and an MCP server. Each skill
|
|
6
|
+
manages a distinct piece of Lightning infrastructure (running a node, baking
|
|
7
|
+
credentials, fetching paid content, hosting paid endpoints) and they compose
|
|
8
|
+
together to give agents a full-stack payment capability. The skills are shell
|
|
9
|
+
scripts and documentation that work with any agent framework capable of
|
|
10
|
+
executing commands (Claude Code, Codex, or custom tooling). The MCP server
|
|
11
|
+
follows the Model Context Protocol standard and works with any compatible
|
|
12
|
+
client. This document explains how the pieces fit together.
|
|
13
|
+
|
|
14
|
+
## Component Overview
|
|
15
|
+
|
|
16
|
+
The kit has three layers: the Claude Code plugin interface, the skills that
|
|
17
|
+
manage infrastructure, and the daemons and tools those skills operate.
|
|
18
|
+
|
|
19
|
+
```mermaid
|
|
20
|
+
graph TD
|
|
21
|
+
CC["Claude Code"] --> Skills
|
|
22
|
+
|
|
23
|
+
subgraph Skills["Skills Layer"]
|
|
24
|
+
lnd["lnd"]
|
|
25
|
+
lsm["lightning-security-module"]
|
|
26
|
+
mb["macaroon-bakery"]
|
|
27
|
+
lnget_skill["lnget"]
|
|
28
|
+
ap["aperture"]
|
|
29
|
+
mcp["mcp-lnc"]
|
|
30
|
+
com["commerce"]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
subgraph Daemons["Runtime Layer (Docker containers by default)"]
|
|
34
|
+
lnd_daemon["litd (Lightning Terminal)<br/>HTTPS :8443 / gRPC :10009 / P2P :9735"]
|
|
35
|
+
signer["lnd signer<br/>gRPC :10012"]
|
|
36
|
+
aperture_daemon["aperture proxy<br/>HTTP :8081"]
|
|
37
|
+
mcp_server["mcp-lnc-server<br/>stdio"]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
subgraph External["External"]
|
|
41
|
+
ln["Lightning Network"]
|
|
42
|
+
mailbox["LNC Mailbox Relay"]
|
|
43
|
+
backend["Backend Service<br/>:8080"]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
lnd --> lnd_daemon
|
|
47
|
+
lsm --> signer
|
|
48
|
+
mb --> lnd_daemon
|
|
49
|
+
lnget_skill --> lnget_cli["lnget CLI"]
|
|
50
|
+
ap --> aperture_daemon
|
|
51
|
+
mcp --> mcp_server
|
|
52
|
+
|
|
53
|
+
lnd_daemon <-->|"remote signing"| signer
|
|
54
|
+
lnd_daemon <--> ln
|
|
55
|
+
lnget_cli -->|"pays invoices via"| lnd_daemon
|
|
56
|
+
aperture_daemon -->|"generates invoices via"| lnd_daemon
|
|
57
|
+
aperture_daemon -->|"proxies to"| backend
|
|
58
|
+
mcp_server <-->|"encrypted WebSocket"| mailbox
|
|
59
|
+
mailbox <-->|"LNC tunnel"| lnd_daemon
|
|
60
|
+
|
|
61
|
+
com -.->|"orchestrates"| lnd
|
|
62
|
+
com -.->|"orchestrates"| lnget_skill
|
|
63
|
+
com -.->|"orchestrates"| ap
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The runtime layer runs inside Docker containers by default. The primary
|
|
67
|
+
container runs [litd](https://github.com/lightninglabs/lightning-terminal)
|
|
68
|
+
(Lightning Terminal), which bundles lnd, Loop, Pool, Taproot Assets (tapd), and
|
|
69
|
+
Faraday into a single process. The signer runs plain lnd in a separate
|
|
70
|
+
container. All container images are pinned in `versions.env`.
|
|
71
|
+
|
|
72
|
+
The `commerce` skill is a meta-skill. It doesn't manage any infrastructure
|
|
73
|
+
directly but orchestrates `lnd`, `lnget`, and `aperture` together into buyer
|
|
74
|
+
and seller workflows.
|
|
75
|
+
|
|
76
|
+
## Plugin Discovery
|
|
77
|
+
|
|
78
|
+
The kit ships as a Claude Code plugin but the underlying skills are
|
|
79
|
+
framework-agnostic shell scripts. Any agent that can run bash commands can use
|
|
80
|
+
them directly.
|
|
81
|
+
|
|
82
|
+
For Claude Code, discovery happens through two mechanisms:
|
|
83
|
+
|
|
84
|
+
**Plugin manifest.** The `.claude-plugin/plugin.json` file declares the plugin
|
|
85
|
+
identity (name, version, author). Claude Code reads this when loading the
|
|
86
|
+
project.
|
|
87
|
+
|
|
88
|
+
**Skill symlinks.** The `.claude/skills/` directory contains symlinks pointing
|
|
89
|
+
to each skill's directory under `skills/`:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
.claude/skills/
|
|
93
|
+
├── aperture → ../../skills/aperture
|
|
94
|
+
├── commerce → ../../skills/commerce
|
|
95
|
+
├── lightning-security-module → ../../skills/lightning-security-module
|
|
96
|
+
├── lnd → ../../skills/lnd
|
|
97
|
+
├── lnget → ../../skills/lnget
|
|
98
|
+
├── macaroon-bakery → ../../skills/macaroon-bakery
|
|
99
|
+
└── mcp-lnc → ../../skills/mcp-lnc
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Each skill directory contains a `SKILL.md` file with YAML frontmatter declaring
|
|
103
|
+
the skill's name, description, and whether it can be invoked directly by users.
|
|
104
|
+
The skill's content (shell scripts, templates, reference docs) lives
|
|
105
|
+
alongside it. In Claude Code, `SKILL.md` is injected into the agent's context
|
|
106
|
+
when the skill is activated. In other frameworks, agents can read the `SKILL.md`
|
|
107
|
+
directly and execute the shell scripts it references.
|
|
108
|
+
|
|
109
|
+
## The Lightning Node
|
|
110
|
+
|
|
111
|
+
The `lnd` skill manages a
|
|
112
|
+
[litd](https://github.com/lightninglabs/lightning-terminal) (Lightning Terminal)
|
|
113
|
+
instance, which bundles lnd with Loop, Pool, Taproot Assets, and Faraday in a
|
|
114
|
+
single daemon. litd serves as the foundation for everything else in the kit. The
|
|
115
|
+
node uses two lightweight backends to avoid requiring a full Bitcoin node:
|
|
116
|
+
|
|
117
|
+
- **Neutrino** (BIP 157/158) for chain data. Fetches compact block filters
|
|
118
|
+
from a set of btcd peers rather than downloading the full blockchain.
|
|
119
|
+
(Regtest mode uses a Bitcoin Core container instead.)
|
|
120
|
+
- **SQLite** for local storage. All channel state, invoices, and routing data
|
|
121
|
+
live in a single SQLite database rather than the default bbolt.
|
|
122
|
+
|
|
123
|
+
### Container-First Deployment
|
|
124
|
+
|
|
125
|
+
The default deployment runs litd inside a Docker container. The install script
|
|
126
|
+
(`skills/lnd/scripts/install.sh`) pulls the
|
|
127
|
+
`lightninglabs/lightning-terminal` image from Docker Hub. Image versions are
|
|
128
|
+
pinned in `versions.env` at the repo root and can be overridden at runtime via
|
|
129
|
+
environment variables.
|
|
130
|
+
|
|
131
|
+
For native builds, pass `--source` to `install.sh`, which builds lnd from source
|
|
132
|
+
with the required build tags: `signrpc walletrpc chainrpc invoicesrpc routerrpc
|
|
133
|
+
peersrpc kvdb_sqlite neutrinorpc`.
|
|
134
|
+
|
|
135
|
+
### Configuration
|
|
136
|
+
|
|
137
|
+
The kit uses a config-file-driven approach. Config templates live in
|
|
138
|
+
`skills/lnd/templates/` and are processed at container startup by
|
|
139
|
+
`skills/lib/config-gen.sh`, which substitutes the network, debug level, node
|
|
140
|
+
alias, UI password, and any extra arguments. The generated config is
|
|
141
|
+
bind-mounted into the container as a read-only file. This avoids the fragility
|
|
142
|
+
of long `docker run` command-line flag lists.
|
|
143
|
+
|
|
144
|
+
Three Docker Compose files define the container topology for each mode:
|
|
145
|
+
|
|
146
|
+
| File | Mode | Containers |
|
|
147
|
+
|------|------|-----------|
|
|
148
|
+
| `docker-compose.yml` | Standalone | litd (neutrino) |
|
|
149
|
+
| `docker-compose-regtest.yml` | Regtest | litd + Bitcoin Core (+ optional litd-bob) |
|
|
150
|
+
| `docker-compose-watchonly.yml` | Watch-only | litd + signer lnd |
|
|
151
|
+
|
|
152
|
+
### Profiles
|
|
153
|
+
|
|
154
|
+
Profile files in `skills/lnd/profiles/` let you customize behavior without
|
|
155
|
+
editing templates. Each profile is a `.env` file that sets `LND_DEBUG`,
|
|
156
|
+
`LITD_EXTRA_ARGS`, and optionally `LITD_ALIAS`. Available profiles:
|
|
157
|
+
|
|
158
|
+
| Profile | Purpose |
|
|
159
|
+
|---------|---------|
|
|
160
|
+
| `default.env` | Standard operation (info-level logging) |
|
|
161
|
+
| `debug.env` | Verbose per-subsystem tracing |
|
|
162
|
+
| `regtest.env` | Local development on regtest |
|
|
163
|
+
| `taproot.env` | Enables simple taproot channels |
|
|
164
|
+
| `wumbo.env` | Large channels up to 10 BTC |
|
|
165
|
+
|
|
166
|
+
Start with a profile: `skills/lnd/scripts/start-lnd.sh --profile debug`
|
|
167
|
+
|
|
168
|
+
### Native Mode
|
|
169
|
+
|
|
170
|
+
All wrapper scripts (`start-lnd.sh`, `stop-lnd.sh`, `lncli.sh`) accept a
|
|
171
|
+
`--native` flag to bypass Docker and use a locally installed lnd binary. In
|
|
172
|
+
native mode, the config template at `skills/lnd/templates/lnd.conf.template`
|
|
173
|
+
is deployed to `~/.lnget/lnd/lnd.conf`.
|
|
174
|
+
|
|
175
|
+
### Watch-Only vs Standalone
|
|
176
|
+
|
|
177
|
+
The node operates in one of two modes:
|
|
178
|
+
|
|
179
|
+
**Watch-only (default).** The node has no private keys. It imports account xpubs
|
|
180
|
+
from a remote signer and delegates all signing operations over gRPC. This is the
|
|
181
|
+
production configuration. Even if the agent's machine is compromised, an
|
|
182
|
+
attacker cannot sign transactions or extract keys because they don't exist on
|
|
183
|
+
that machine.
|
|
184
|
+
|
|
185
|
+
**Standalone.** The node generates and stores its own seed locally. The 24-word
|
|
186
|
+
mnemonic is written to `~/.lnget/lnd/seed.txt` with mode 0600. This mode is
|
|
187
|
+
appropriate for testnet, regtest, and development. It should not be used with
|
|
188
|
+
significant funds.
|
|
189
|
+
|
|
190
|
+
The mode is selected at wallet creation time via the `--mode` flag on
|
|
191
|
+
`create-wallet.sh`. Once a wallet is created in one mode, the choice is
|
|
192
|
+
permanent for that data directory.
|
|
193
|
+
|
|
194
|
+
## Remote Signer
|
|
195
|
+
|
|
196
|
+
The `lightning-security-module` skill sets up a second lnd instance that exists
|
|
197
|
+
solely to hold private keys and sign transactions. This signer node never
|
|
198
|
+
connects to the Lightning Network's peer-to-peer layer, never routes payments,
|
|
199
|
+
and never opens channels. Its only network exposure is a gRPC interface on port
|
|
200
|
+
10012 that the watch-only node connects to for signing requests.
|
|
201
|
+
|
|
202
|
+
By default, the signer runs in a Docker container named `litd-signer`, defined
|
|
203
|
+
in `skills/lightning-security-module/templates/docker-compose-signer.yml`. The
|
|
204
|
+
`setup-signer.sh` script auto-detects a running `litd-signer` container and
|
|
205
|
+
routes wallet creation and credential export through it. Pass `--native` to
|
|
206
|
+
use a locally installed lnd binary instead.
|
|
207
|
+
|
|
208
|
+
```mermaid
|
|
209
|
+
sequenceDiagram
|
|
210
|
+
participant WO as Watch-Only Node<br/>(agent machine)
|
|
211
|
+
participant S as Signer Node<br/>(secure machine)
|
|
212
|
+
participant BTC as Bitcoin Network
|
|
213
|
+
|
|
214
|
+
WO->>WO: Constructs unsigned transaction
|
|
215
|
+
WO->>S: SignOutputRaw(tx, input_index)
|
|
216
|
+
S->>S: Validates signing request
|
|
217
|
+
S->>S: Signs with private key
|
|
218
|
+
S-->>WO: Returns signature
|
|
219
|
+
WO->>WO: Assembles signed transaction
|
|
220
|
+
WO->>BTC: Broadcasts transaction
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
The signer exports a **credentials bundle** containing three files:
|
|
224
|
+
|
|
225
|
+
| File | Purpose |
|
|
226
|
+
|------|---------|
|
|
227
|
+
| `accounts.json` | Account xpubs for watch-only wallet import |
|
|
228
|
+
| `tls.cert` | TLS certificate for authenticated gRPC |
|
|
229
|
+
| `admin.macaroon` | RPC authentication token (scope down for production) |
|
|
230
|
+
|
|
231
|
+
The bundle is generated by `setup-signer.sh` and written to
|
|
232
|
+
`~/.lnget/signer/credentials-bundle/`. A base64-encoded tarball
|
|
233
|
+
(`credentials-bundle.tar.gz.b64`) is also created for easy transfer to the
|
|
234
|
+
agent machine. On the agent side, `import-credentials.sh` unpacks the bundle
|
|
235
|
+
into `~/.lnget/lnd/signer-credentials/`.
|
|
236
|
+
|
|
237
|
+
The signer's config (`skills/lightning-security-module/templates/signer-lnd.conf.template`)
|
|
238
|
+
differs from a standard lnd config in important ways: it listens for RPC on
|
|
239
|
+
`0.0.0.0:10012` to accept connections from the watch-only node, binds REST to
|
|
240
|
+
`0.0.0.0:10013` (container mode needs this for host connectivity; native mode
|
|
241
|
+
rebinds to `localhost`), includes container hostnames (`signer`, `litd-signer`)
|
|
242
|
+
in the TLS certificate's extra domains, and disables all routing and autopilot
|
|
243
|
+
features.
|
|
244
|
+
|
|
245
|
+
For a full discussion of threat models and hardening, see
|
|
246
|
+
[Security](security.md).
|
|
247
|
+
|
|
248
|
+
## Credentials
|
|
249
|
+
|
|
250
|
+
lnd uses [macaroons](https://research.google/pubs/pub41892/) for RPC
|
|
251
|
+
authentication. A macaroon is a bearer token: anyone who possesses it can
|
|
252
|
+
exercise the permissions it encodes. The default `admin.macaroon` grants
|
|
253
|
+
unrestricted access to every RPC method, which is why you should never hand it
|
|
254
|
+
to an agent in production.
|
|
255
|
+
|
|
256
|
+
The `macaroon-bakery` skill bakes scoped macaroons that grant only the
|
|
257
|
+
permissions an agent needs. It ships with five preset roles:
|
|
258
|
+
|
|
259
|
+
| Role | Can do | Cannot do |
|
|
260
|
+
|------|--------|-----------|
|
|
261
|
+
| `pay-only` | Pay and decode invoices | Create invoices, manage channels |
|
|
262
|
+
| `invoice-only` | Create and look up invoices | Pay, manage channels |
|
|
263
|
+
| `read-only` | Query balances, channels, peers, payments | Modify any state |
|
|
264
|
+
| `channel-admin` | Everything in read-only + open/close channels | Pay or create invoices |
|
|
265
|
+
| `signer-only` | Sign transactions, derive keys | Everything else |
|
|
266
|
+
|
|
267
|
+
Custom macaroons can be baked with arbitrary permission sets by passing
|
|
268
|
+
individual URI permissions to `bake.sh --custom`. The full list of available
|
|
269
|
+
permissions is available via `bake.sh --list-permissions`.
|
|
270
|
+
|
|
271
|
+
Macaroons are baked by the lnd node itself. The bakery script calls `lncli
|
|
272
|
+
bakemacaroon` with the appropriate permission URIs. The resulting macaroon file
|
|
273
|
+
should be stored with mode 0600 and treated like a password.
|
|
274
|
+
|
|
275
|
+
```mermaid
|
|
276
|
+
graph TD
|
|
277
|
+
admin["admin.macaroon<br/>(full access, never use in production)"]
|
|
278
|
+
|
|
279
|
+
admin -->|"bake --role pay-only"| payonly["pay-only.macaroon<br/>SendPayment, DecodePayReq, GetInfo"]
|
|
280
|
+
admin -->|"bake --role invoice-only"| invonly["invoice-only.macaroon<br/>AddInvoice, LookupInvoice, GetInfo"]
|
|
281
|
+
admin -->|"bake --role read-only"| readonly["read-only.macaroon<br/>GetInfo, balances, list operations"]
|
|
282
|
+
admin -->|"bake --role channel-admin"| chanadmin["channel-admin.macaroon<br/>read-only + OpenChannel, CloseChannel"]
|
|
283
|
+
admin -->|"bake --role signer-only"| signeronly["signer-only.macaroon<br/>SignOutputRaw, DeriveKey, MuSig2Sign"]
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## MCP Server
|
|
287
|
+
|
|
288
|
+
The MCP server (`mcp-server/`) connects AI assistants to a Lightning node
|
|
289
|
+
through the [Model Context Protocol](https://modelcontextprotocol.io). It uses
|
|
290
|
+
[Lightning Node Connect](https://docs.lightning.engineering/lightning-network-tools/lightning-terminal/lightning-node-connect)
|
|
291
|
+
(LNC) to reach the node, which means the assistant never needs direct network
|
|
292
|
+
access, TLS certificates, or macaroon files.
|
|
293
|
+
|
|
294
|
+
LNC works by establishing an end-to-end encrypted WebSocket tunnel through a
|
|
295
|
+
mailbox relay server. The agent and the lnd node each connect outbound to the
|
|
296
|
+
mailbox. Neither needs to accept inbound connections. The tunnel is
|
|
297
|
+
authenticated by a 10-word pairing phrase generated in Lightning Terminal.
|
|
298
|
+
|
|
299
|
+
```mermaid
|
|
300
|
+
sequenceDiagram
|
|
301
|
+
participant CC as Claude Code
|
|
302
|
+
participant MCP as mcp-lnc-server
|
|
303
|
+
participant MB as Mailbox Relay
|
|
304
|
+
participant LND as lnd + Lightning Terminal
|
|
305
|
+
|
|
306
|
+
CC->>MCP: lnc_connect(pairing_phrase, password)
|
|
307
|
+
MCP->>MCP: Generate ephemeral ECDSA keypair
|
|
308
|
+
MCP->>MB: Open WebSocket (encrypted)
|
|
309
|
+
LND->>MB: Open WebSocket (encrypted)
|
|
310
|
+
MB-->>MCP: Tunnel established
|
|
311
|
+
MB-->>LND: Tunnel established
|
|
312
|
+
|
|
313
|
+
CC->>MCP: lnc_get_info()
|
|
314
|
+
MCP->>LND: GetInfo RPC (via tunnel)
|
|
315
|
+
LND-->>MCP: NodeInfo response
|
|
316
|
+
MCP-->>CC: Formatted node info
|
|
317
|
+
|
|
318
|
+
CC->>MCP: lnc_disconnect()
|
|
319
|
+
MCP->>MB: Close tunnel
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
The server runs on stdio transport. The MCP client (Claude Code or any other
|
|
323
|
+
MCP-compatible host) launches it as a subprocess and communicates over
|
|
324
|
+
stdin/stdout. No HTTP server, no port binding. The server's Go implementation
|
|
325
|
+
lives under `mcp-server/` and is built via
|
|
326
|
+
`skills/mcp-lnc/scripts/install.sh`.
|
|
327
|
+
|
|
328
|
+
The server exposes 18 read-only tools organized into seven categories:
|
|
329
|
+
Connection, Node, Channels, Invoices, Payments, Peers/Network, and On-Chain.
|
|
330
|
+
None of these tools can modify node state. They query balances, list channels,
|
|
331
|
+
decode invoices, and inspect the network graph, but they cannot send payments,
|
|
332
|
+
open channels, or change configuration. See [MCP Server](mcp-server.md) for the
|
|
333
|
+
full tool reference.
|
|
334
|
+
|
|
335
|
+
Internally, the server uses a service manager
|
|
336
|
+
(`mcp-server/internal/services/manager.go`) that initializes one service per
|
|
337
|
+
tool category and registers their tools with the MCP SDK. When `lnc_connect`
|
|
338
|
+
is called, the manager creates a Lightning client via LNC and distributes it to
|
|
339
|
+
all services. When `lnc_disconnect` is called, the connection is closed and the
|
|
340
|
+
ephemeral keypair is discarded.
|
|
341
|
+
|
|
342
|
+
## L402 Commerce Flow
|
|
343
|
+
|
|
344
|
+
The L402 protocol ties the system together for commerce. When an agent uses
|
|
345
|
+
`lnget` to fetch a resource protected by `aperture`, the following exchange
|
|
346
|
+
happens:
|
|
347
|
+
|
|
348
|
+
```mermaid
|
|
349
|
+
sequenceDiagram
|
|
350
|
+
participant Agent as Agent (lnget)
|
|
351
|
+
participant Aperture as Aperture (seller)
|
|
352
|
+
participant SellerLND as Seller's lnd
|
|
353
|
+
participant BuyerLND as Buyer's lnd
|
|
354
|
+
participant LN as Lightning Network
|
|
355
|
+
|
|
356
|
+
Agent->>Aperture: GET /api/data
|
|
357
|
+
Aperture->>SellerLND: Generate invoice (100 sats)
|
|
358
|
+
SellerLND-->>Aperture: BOLT11 invoice
|
|
359
|
+
Aperture-->>Agent: 402 Payment Required<br/>WWW-Authenticate: L402 macaroon=..., invoice=...
|
|
360
|
+
|
|
361
|
+
Agent->>Agent: Parse challenge, check amount ≤ max-cost
|
|
362
|
+
Agent->>BuyerLND: Pay invoice
|
|
363
|
+
BuyerLND->>LN: Route payment
|
|
364
|
+
LN->>SellerLND: Deliver payment
|
|
365
|
+
SellerLND-->>LN: Reveal preimage
|
|
366
|
+
LN-->>BuyerLND: Preimage
|
|
367
|
+
BuyerLND-->>Agent: Payment settled, preimage
|
|
368
|
+
|
|
369
|
+
Agent->>Agent: Cache token (macaroon + preimage)
|
|
370
|
+
Agent->>Aperture: GET /api/data<br/>Authorization: L402 <macaroon>:<preimage>
|
|
371
|
+
Aperture->>Aperture: Validate token
|
|
372
|
+
Aperture->>Aperture: Proxy to backend :8080
|
|
373
|
+
Aperture-->>Agent: 200 OK + response data
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
`lnget` handles this entire flow automatically. The agent runs a single command
|
|
377
|
+
(`lnget https://api.example.com/data`) and receives the response data. The 402
|
|
378
|
+
challenge, invoice payment, token caching, and authenticated retry happen
|
|
379
|
+
transparently. Cached tokens are reused for subsequent requests to the same
|
|
380
|
+
domain, avoiding repeat payments.
|
|
381
|
+
|
|
382
|
+
On the server side, `aperture` sits in front of a backend HTTP service and
|
|
383
|
+
intercepts requests to protected paths. It generates invoices through its
|
|
384
|
+
connected lnd node, issues L402 challenges to unauthenticated requests, and
|
|
385
|
+
validates paid tokens on retry. The backend service doesn't need to know
|
|
386
|
+
anything about Lightning or L402.
|
|
387
|
+
|
|
388
|
+
For the full protocol specification and client/server setup, see
|
|
389
|
+
[L402 and lnget](l402-and-lnget.md) and [Commerce](commerce.md).
|
|
390
|
+
|
|
391
|
+
## File System Layout
|
|
392
|
+
|
|
393
|
+
All kit components store their data under predictable paths. The `~/.lnget/`
|
|
394
|
+
tree is managed by the kit's scripts; `~/.lnd/` and `~/.aperture/` are
|
|
395
|
+
managed by their respective daemons.
|
|
396
|
+
|
|
397
|
+
### Host Files (managed by kit scripts)
|
|
398
|
+
|
|
399
|
+
| Path | Owner | Contents |
|
|
400
|
+
|------|-------|----------|
|
|
401
|
+
| `~/.lnget/lnd/wallet-password.txt` | lnd skill | Wallet unlock passphrase (0600) |
|
|
402
|
+
| `~/.lnget/lnd/seed.txt` | lnd skill | 24-word mnemonic, standalone only (0600) |
|
|
403
|
+
| `~/.lnget/lnd/signer-credentials/` | lnd skill | Imported signer bundle (watch-only) |
|
|
404
|
+
| `~/.lnget/signer/signer-lnd.conf` | security module | Signer node configuration |
|
|
405
|
+
| `~/.lnget/signer/wallet-password.txt` | security module | Signer passphrase (0600) |
|
|
406
|
+
| `~/.lnget/signer/seed.txt` | security module | Signer mnemonic (0600) |
|
|
407
|
+
| `~/.lnget/signer/credentials-bundle/` | security module | Exported credentials for agent |
|
|
408
|
+
| `~/.lnget/config.yaml` | lnget | lnget client configuration |
|
|
409
|
+
| `~/.lnget/tokens/<domain>/` | lnget | Cached L402 tokens per domain |
|
|
410
|
+
| `mcp-server/.env` | mcp-lnc | MCP server environment config |
|
|
411
|
+
|
|
412
|
+
### Daemon Data (native mode: filesystem; container mode: Docker volumes)
|
|
413
|
+
|
|
414
|
+
In container mode, the following paths live inside named Docker volumes rather
|
|
415
|
+
than on the host filesystem. Use `docker volume ls` to list them and
|
|
416
|
+
`docker volume inspect <name>` for mount details.
|
|
417
|
+
|
|
418
|
+
| Path / Volume | Mode | Contents |
|
|
419
|
+
|---------------|------|----------|
|
|
420
|
+
| `~/.lnd/` / `litd-data` | native / container | lnd chain data, macaroons, TLS cert/key, logs |
|
|
421
|
+
| `~/.lnd-signer/` / `signer-data` | native / container | Signer chain data, macaroons, TLS |
|
|
422
|
+
| — / `litd-lit-data` | container only | litd-specific state (sessions, accounts) |
|
|
423
|
+
| `~/.aperture/` / `aperture-data` | native / container | Aperture config, database, TLS |
|
|
424
|
+
|
|
425
|
+
### Kit Infrastructure
|
|
426
|
+
|
|
427
|
+
| Path | Purpose |
|
|
428
|
+
|------|---------|
|
|
429
|
+
| `versions.env` | Pinned container image versions (litd, lnd, aperture, Bitcoin Core) |
|
|
430
|
+
| `skills/lib/config-gen.sh` | Shared config generation functions for templates |
|
|
431
|
+
| `skills/lib/rest.sh` | Shared REST API call helpers (native + container) |
|
|
432
|
+
| `skills/lnd/templates/` | Config templates and Docker Compose files |
|
|
433
|
+
| `skills/lnd/profiles/` | Profile `.env` files (default, debug, regtest, taproot, wumbo) |
|
|
434
|
+
| `skills/lightning-security-module/templates/` | Signer config template and Docker Compose |
|
|
435
|
+
| `skills/aperture/templates/` | Aperture config template and Docker Compose |
|
|
436
|
+
|
|
437
|
+
## Ports
|
|
438
|
+
|
|
439
|
+
| Port | Service | Daemon | Interface |
|
|
440
|
+
|------|---------|--------|-----------|
|
|
441
|
+
| 8443 | HTTPS (UI + gRPC + REST) | litd | 0.0.0.0 (container) |
|
|
442
|
+
| 9735 | Lightning P2P | lnd | 0.0.0.0 |
|
|
443
|
+
| 10009 | gRPC | lnd | localhost |
|
|
444
|
+
| 8080 | REST | lnd | localhost |
|
|
445
|
+
| 10012 | gRPC | signer lnd | 0.0.0.0 |
|
|
446
|
+
| 10013 | REST | signer lnd | 0.0.0.0 (container) / localhost (native) |
|
|
447
|
+
| 8081 | HTTP (L402) | aperture | configurable |
|
|
448
|
+
|
|
449
|
+
Regtest mode adds:
|
|
450
|
+
|
|
451
|
+
| Port | Service | Daemon |
|
|
452
|
+
|------|---------|--------|
|
|
453
|
+
| 18443 | Bitcoin RPC | bitcoind |
|
|
454
|
+
| 28332 | ZMQ block notifications | bitcoind |
|
|
455
|
+
| 28333 | ZMQ tx notifications | bitcoind |
|