@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.
Files changed (68) hide show
  1. package/.claude-plugin/marketplace.json +36 -0
  2. package/.claude-plugin/plugin.json +12 -0
  3. package/README.md +307 -0
  4. package/bin/lightning-mcp-server +15 -0
  5. package/docs/architecture.md +455 -0
  6. package/docs/commerce.md +357 -0
  7. package/docs/l402-and-lnget.md +267 -0
  8. package/docs/mcp-server.md +285 -0
  9. package/docs/quickref.md +263 -0
  10. package/docs/security.md +298 -0
  11. package/docs/two-agent-setup.md +394 -0
  12. package/package.json +52 -0
  13. package/postinstall.js +160 -0
  14. package/skills/aperture/SKILL.md +330 -0
  15. package/skills/aperture/scripts/install.sh +68 -0
  16. package/skills/aperture/scripts/setup.sh +155 -0
  17. package/skills/aperture/scripts/start.sh +81 -0
  18. package/skills/aperture/scripts/stop.sh +57 -0
  19. package/skills/aperture/templates/aperture-regtest.yaml +36 -0
  20. package/skills/aperture/templates/aperture.yaml.template +64 -0
  21. package/skills/aperture/templates/docker-compose-aperture.yml +59 -0
  22. package/skills/commerce/SKILL.md +211 -0
  23. package/skills/lib/config-gen.sh +127 -0
  24. package/skills/lib/rest.sh +69 -0
  25. package/skills/lightning-security-module/SKILL.md +253 -0
  26. package/skills/lightning-security-module/references/architecture.md +133 -0
  27. package/skills/lightning-security-module/scripts/docker-start.sh +117 -0
  28. package/skills/lightning-security-module/scripts/docker-stop.sh +53 -0
  29. package/skills/lightning-security-module/scripts/export-credentials.sh +268 -0
  30. package/skills/lightning-security-module/scripts/install.sh +178 -0
  31. package/skills/lightning-security-module/scripts/setup-signer.sh +307 -0
  32. package/skills/lightning-security-module/scripts/start-signer.sh +152 -0
  33. package/skills/lightning-security-module/scripts/stop-signer.sh +240 -0
  34. package/skills/lightning-security-module/templates/docker-compose-signer.yml +35 -0
  35. package/skills/lightning-security-module/templates/signer-lnd.conf.template +69 -0
  36. package/skills/lnd/SKILL.md +441 -0
  37. package/skills/lnd/profiles/debug.env +4 -0
  38. package/skills/lnd/profiles/default.env +3 -0
  39. package/skills/lnd/profiles/regtest.env +4 -0
  40. package/skills/lnd/profiles/taproot.env +3 -0
  41. package/skills/lnd/profiles/wumbo.env +3 -0
  42. package/skills/lnd/references/security.md +156 -0
  43. package/skills/lnd/scripts/create-wallet.sh +464 -0
  44. package/skills/lnd/scripts/docker-start.sh +256 -0
  45. package/skills/lnd/scripts/docker-stop.sh +109 -0
  46. package/skills/lnd/scripts/import-credentials.sh +145 -0
  47. package/skills/lnd/scripts/install.sh +195 -0
  48. package/skills/lnd/scripts/lncli.sh +150 -0
  49. package/skills/lnd/scripts/start-lnd.sh +241 -0
  50. package/skills/lnd/scripts/stop-lnd.sh +218 -0
  51. package/skills/lnd/scripts/unlock-wallet.sh +134 -0
  52. package/skills/lnd/templates/docker-compose-regtest.yml +122 -0
  53. package/skills/lnd/templates/docker-compose-watchonly.yml +71 -0
  54. package/skills/lnd/templates/docker-compose.yml +49 -0
  55. package/skills/lnd/templates/litd-regtest.conf.template +61 -0
  56. package/skills/lnd/templates/litd-watchonly.conf.template +57 -0
  57. package/skills/lnd/templates/litd.conf.template +88 -0
  58. package/skills/lnd/templates/lnd.conf.template +91 -0
  59. package/skills/lnget/SKILL.md +288 -0
  60. package/skills/lnget/scripts/install.sh +69 -0
  61. package/skills/macaroon-bakery/SKILL.md +179 -0
  62. package/skills/macaroon-bakery/scripts/bake.sh +337 -0
  63. package/skills/mcp-lnc/SKILL.md +280 -0
  64. package/skills/mcp-lnc/scripts/configure.sh +130 -0
  65. package/skills/mcp-lnc/scripts/install.sh +103 -0
  66. package/skills/mcp-lnc/scripts/setup-claude-config.sh +162 -0
  67. package/skills/mcp-lnc/templates/env.template +16 -0
  68. package/versions.env +23 -0
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "lightninglabs",
3
+ "owner": {
4
+ "name": "Lightning Labs",
5
+ "email": "support@lightning.engineering"
6
+ },
7
+ "metadata": {
8
+ "description": "Lightning Network agent toolkit — MCP server, L402 payments, node operations, and composable skills for AI agents",
9
+ "version": "0.2.0"
10
+ },
11
+ "plugins": [
12
+ {
13
+ "name": "lightning-agent-tools",
14
+ "source": ".",
15
+ "description": "Full Lightning Network agent toolkit with 7 composable skills: lnd node operations, remote signer security, L402 commerce with lnget and Aperture, scoped macaroon credentials, and MCP server integration via Lightning Node Connect.",
16
+ "version": "0.2.0",
17
+ "author": {
18
+ "name": "Lightning Labs"
19
+ },
20
+ "homepage": "https://github.com/lightninglabs/lightning-agent-tools",
21
+ "repository": "https://github.com/lightninglabs/lightning-agent-tools",
22
+ "license": "MIT",
23
+ "keywords": [
24
+ "lightning",
25
+ "bitcoin",
26
+ "lnd",
27
+ "l402",
28
+ "payments",
29
+ "mcp",
30
+ "lnc",
31
+ "agent"
32
+ ],
33
+ "category": "infrastructure"
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "lightning-agent-tools",
3
+ "description": "Lightning Network agent toolkit. Container-first skills for running Lightning Terminal (litd) nodes with lnd, loop, pool, and tapd. Includes remote signer security, L402 commerce with lnget and Aperture, scoped macaroon credentials, and MCP server integration.",
4
+ "version": "0.2.0",
5
+ "author": {
6
+ "name": "Lightning Labs"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/lightninglabs/lightning-agent-kit"
11
+ }
12
+ }
package/README.md ADDED
@@ -0,0 +1,307 @@
1
+ # Lightning Agent Tools
2
+
3
+ AI agents can read documentation, write code, and orchestrate complex workflows,
4
+ but they can't easily pay for things. Traditional payment rails require
5
+ government IDs, bank accounts, and manual enrollment, none of which work for
6
+ autonomous software. Lightning Agent Tools bridges this gap by giving agents
7
+ native access to the [Lightning Network](https://lightning.network), a
8
+ decentralized payment protocol capable of instant, high-volume transactions with
9
+ no identity requirements.
10
+
11
+ The toolkit consists of seven composable skills and an MCP server. Together they
12
+ let an agent run a Lightning node, pay for resources on the web using the
13
+ [L402](https://docs.lightning.engineering/the-lightning-network/l402) protocol,
14
+ host its own paid API endpoints, manage scoped credentials, and query node state
15
+ through the Model Context Protocol. The skills work with any agent framework
16
+ that can execute shell commands: [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview),
17
+ [Codex](https://openai.com/index/codex/), or your own tooling. The MCP server
18
+ follows the [Model Context Protocol](https://modelcontextprotocol.io) standard
19
+ and works with any compatible client. The security model defaults to a remote
20
+ signer architecture that keeps private keys on a separate machine, away from the
21
+ agent's runtime environment.
22
+
23
+ ## How It Works
24
+
25
+ ```mermaid
26
+ graph TD
27
+ CC["Your Agent"] --> Skills
28
+
29
+ subgraph Skills["Skills"]
30
+ lnd["lnd<br/><i>run a Lightning node</i>"]
31
+ lsm["lightning-security-module<br/><i>remote signer</i>"]
32
+ mb["macaroon-bakery<br/><i>scoped credentials</i>"]
33
+ lg["lnget<br/><i>L402 HTTP client</i>"]
34
+ ap["aperture<br/><i>L402 reverse proxy</i>"]
35
+ mcp["mcp-lnc<br/><i>MCP server</i>"]
36
+ com["commerce<br/><i>buyer/seller workflows</i>"]
37
+ end
38
+
39
+ subgraph Runtime["Daemons & Tools"]
40
+ lnd_d["lnd daemon"]
41
+ signer_d["lnd signer"]
42
+ aperture_d["aperture proxy"]
43
+ lnget_d["lnget CLI"]
44
+ mcp_d["mcp-lnc-server"]
45
+ end
46
+
47
+ lnd --> lnd_d
48
+ lsm --> signer_d
49
+ lg --> lnget_d
50
+ ap --> aperture_d
51
+ mcp --> mcp_d
52
+
53
+ lnd_d <-->|"remote signing"| signer_d
54
+ lnget_d -->|"pays invoices"| lnd_d
55
+ aperture_d -->|"generates invoices"| lnd_d
56
+ mcp_d <-->|"LNC tunnel"| lnd_d
57
+
58
+ com -.-> lnd
59
+ com -.-> lg
60
+ com -.-> ap
61
+ ```
62
+
63
+ The skills break down into three functional groups:
64
+
65
+ **Payment infrastructure.** The `lnd` skill runs a Lightning node using the
66
+ Neutrino light client (no full Bitcoin node required) with SQLite storage. The
67
+ `lightning-security-module` sets up a remote signer to hold private keys on a
68
+ separate machine. The `macaroon-bakery` bakes least-privilege credentials so
69
+ agents only get the permissions they need.
70
+
71
+ **Commerce.** The `lnget` skill installs a command-line HTTP client that handles
72
+ L402 payments automatically. When it hits a 402 response, it pays the embedded
73
+ Lightning invoice, caches the token, and retries. The `aperture` skill runs an
74
+ L402 reverse proxy that gates access to a backend service behind Lightning
75
+ invoices. The `commerce` skill ties these together into buyer and seller
76
+ workflows.
77
+
78
+ **Node access.** The `mcp-lnc` skill builds and configures an MCP server that
79
+ connects to a Lightning node via Lightning Node Connect (encrypted WebSocket
80
+ tunnels, pairing-phrase auth, no stored credentials). It exposes 18 read-only
81
+ tools for querying node state and works with any MCP-compatible client.
82
+
83
+ ## Quick Start
84
+
85
+ ### Option A: Zero-Install MCP via `claude mcp add`
86
+
87
+ Register the MCP server with Claude Code in one command — no Go toolchain or
88
+ git clone required:
89
+
90
+ ```bash
91
+ claude mcp add --transport stdio lnc -- npx -y @lightninglabs/lightning-mcp-server
92
+ ```
93
+
94
+ With a specific mailbox server:
95
+
96
+ ```bash
97
+ claude mcp add --transport stdio \
98
+ --env LNC_MAILBOX_SERVER=mailbox.terminal.lightning.today:443 \
99
+ lnc -- npx -y @lightninglabs/lightning-mcp-server
100
+ ```
101
+
102
+ For development/regtest:
103
+
104
+ ```bash
105
+ claude mcp add --transport stdio \
106
+ --env LNC_MAILBOX_SERVER=localhost:11110 \
107
+ --env LNC_DEV_MODE=true \
108
+ --env LNC_INSECURE=true \
109
+ lnc -- npx -y @lightninglabs/lightning-mcp-server
110
+ ```
111
+
112
+ Scope options: `--scope local` (default, just you), `--scope project` (shared
113
+ via `.mcp.json`), `--scope user` (all your projects).
114
+
115
+ Restart Claude Code, then:
116
+
117
+ ```
118
+ Connect to my Lightning node with pairing phrase: "word1 word2 ... word10"
119
+ ```
120
+
121
+ The agent can now query balances, list channels, decode invoices, and inspect
122
+ the network graph. See [MCP Server](docs/mcp-server.md) for details.
123
+
124
+ ### Option B: Full Plugin with All Skills
125
+
126
+ Install the complete plugin (all 7 skills + MCP server) via the Claude Code
127
+ plugin marketplace:
128
+
129
+ ```bash
130
+ # Add the marketplace (one-time)
131
+ /plugin marketplace add lightninglabs/lightning-agent-tools
132
+
133
+ # Install the plugin (gets all skills)
134
+ /plugin install lightning-agent-tools@lightninglabs
135
+ ```
136
+
137
+ Or load locally for development:
138
+
139
+ ```bash
140
+ git clone https://github.com/lightninglabs/lightning-agent-tools.git
141
+ claude --plugin-dir ./lightning-agent-tools
142
+ ```
143
+
144
+ This gives Claude Code access to all skills: lnd node management, remote
145
+ signer security, lnget L402 payments, Aperture proxy, macaroon bakery,
146
+ MCP server integration, and commerce workflows.
147
+
148
+ ### Option C: Read-Only Node Access (from source)
149
+
150
+ Build the MCP server from source. Requires Go 1.24+.
151
+
152
+ ```bash
153
+ git clone https://github.com/lightninglabs/lightning-agent-tools.git
154
+ cd lightning-agent-tools
155
+
156
+ skills/mcp-lnc/scripts/install.sh
157
+ skills/mcp-lnc/scripts/configure.sh --production
158
+ skills/mcp-lnc/scripts/setup-claude-config.sh --scope project
159
+ ```
160
+
161
+ Restart Claude Code, then:
162
+
163
+ ```
164
+ Connect to my Lightning node with pairing phrase: "word1 word2 ... word10"
165
+ ```
166
+
167
+ The agent can now query balances, list channels, decode invoices, and inspect
168
+ the network graph. See [MCP Server](docs/mcp-server.md) for details.
169
+
170
+ ### Option B: Full Commerce Stack
171
+
172
+ Run your own node and start buying or selling resources over Lightning. Docker
173
+ is the default deployment method — `install.sh` pulls a container image and
174
+ `start-lnd.sh` launches it via Docker Compose.
175
+
176
+ ```bash
177
+ git clone https://github.com/lightninglabs/lightning-agent-tools.git
178
+ cd lightning-agent-tools
179
+
180
+ # Install components (pulls Docker images by default; --source to build natively)
181
+ skills/lnd/scripts/install.sh
182
+ skills/lnget/scripts/install.sh
183
+
184
+ # Create and start a node (runs in a Docker container)
185
+ skills/lnd/scripts/create-wallet.sh --mode standalone
186
+ skills/lnd/scripts/start-lnd.sh
187
+
188
+ # Configure lnget
189
+ lnget config init
190
+
191
+ # Fetch a paid resource
192
+ lnget --max-cost 500 https://api.example.com/data.json
193
+ ```
194
+
195
+ All wrapper scripts (`start-lnd.sh`, `stop-lnd.sh`, `lncli.sh`) auto-detect
196
+ Docker containers. Pass `--native` to any script to use a locally built binary
197
+ instead.
198
+
199
+ For the full walkthrough including wallet funding, channel management, and
200
+ hosting your own paid endpoints, see [Commerce](docs/commerce.md).
201
+
202
+ ### Natural Language
203
+
204
+ Agents with skill discovery (like Claude Code) pick up the skills automatically.
205
+ You can interact through natural language:
206
+
207
+ ```
208
+ Install Lightning Agent Tools and set up a Lightning node with
209
+ remote signer so I can start paying for L402 APIs with lnget.
210
+ ```
211
+
212
+ ```
213
+ Bake a pay-only macaroon on my regtest node
214
+ ```
215
+
216
+ ```
217
+ Export credentials from my signer and set up a watch-only node
218
+ ```
219
+
220
+ ## Skills
221
+
222
+ | Skill | What it does |
223
+ |-------|-------------|
224
+ | **lnd** | Installs and operates an lnd Lightning node. Neutrino light client, SQLite storage. Defaults to watch-only mode with remote signer. |
225
+ | **lightning-security-module** | Sets up a remote signer node on a separate machine. Holds all private keys; the agent machine has none. |
226
+ | **macaroon-bakery** | Bakes scoped macaroons (pay-only, invoice-only, read-only, channel-admin, signer-only) for least-privilege access. |
227
+ | **lnget** | Command-line HTTP client with automatic L402 payment. Pays Lightning invoices on 402 responses, caches tokens, retries. |
228
+ | **aperture** | L402 reverse proxy. Sits in front of a backend service, issues invoices, validates paid tokens, proxies authorized requests. |
229
+ | **mcp-lnc** | Builds and configures the MCP server for LNC-based read-only access to a Lightning node. 18 tools, no stored credentials. |
230
+ | **commerce** | Meta-skill orchestrating lnd + lnget + aperture for end-to-end buyer/seller workflows. |
231
+
232
+ All scripts support `--container` for Docker-based lnd nodes and `--rpcserver`
233
+ / `--tlscertpath` / `--macaroonpath` for remote nodes.
234
+
235
+ ## Security
236
+
237
+ The kit provides three tiers of access with increasing trust requirements:
238
+
239
+ ```mermaid
240
+ graph LR
241
+ subgraph T1["Tier 1: Watch-Only + Remote Signer"]
242
+ A1["Agent: no keys"]
243
+ S1["Signer: holds keys"]
244
+ A1 ---|"gRPC"| S1
245
+ end
246
+
247
+ subgraph T2["Tier 2: Standalone"]
248
+ A2["Agent: keys on disk (0600)"]
249
+ end
250
+
251
+ subgraph T3["Tier 3: Read-Only via LNC"]
252
+ A3["Agent: no credentials on disk"]
253
+ end
254
+
255
+ T1 --- P1["Production"]
256
+ T2 --- P2["Testing"]
257
+ T3 --- P3["Observation"]
258
+ ```
259
+
260
+ **Tier 1 (default)** splits the node into a watch-only instance on the agent
261
+ machine and a signer on a separate machine. The agent can route payments and
262
+ manage channels but cannot sign transactions. Keys never leave the signer.
263
+
264
+ **Tier 2** stores keys locally. Appropriate for testnet, regtest, and small-value
265
+ mainnet experiments.
266
+
267
+ **Tier 3** uses the MCP server with LNC. No credentials are written to disk;
268
+ the pairing phrase is handled in memory and ephemeral ECDSA keypairs are
269
+ generated per session.
270
+
271
+ For all tiers, use the `macaroon-bakery` to scope credentials. A buyer agent
272
+ gets a `pay-only` macaroon; a monitoring agent gets `read-only`. Never hand out
273
+ `admin.macaroon` in production.
274
+
275
+ See [Security](docs/security.md) for threat models, hardening, and the
276
+ production checklist.
277
+
278
+ ## Documentation
279
+
280
+ | Document | Description |
281
+ |----------|-------------|
282
+ | [Architecture](docs/architecture.md) | System design, component map, plugin discovery, data flows |
283
+ | [Security](docs/security.md) | Three-tier security model, remote signer, macaroon scoping, production checklist |
284
+ | [L402 and lnget](docs/l402-and-lnget.md) | The L402 protocol, lnget usage, spending controls, token caching |
285
+ | [MCP Server](docs/mcp-server.md) | LNC mechanics, setup walkthrough, 18-tool reference, configuration |
286
+ | [Commerce](docs/commerce.md) | Buyer and seller agent setup, the commerce loop, cost management |
287
+ | [Two-Agent Setup](docs/two-agent-setup.md) | Signer agent + node agent walkthrough for production key isolation |
288
+ | [Quick Reference](docs/quickref.md) | Every command in one place |
289
+
290
+ Each skill also has a detailed `SKILL.md` in its directory under `skills/` with
291
+ operational reference material: script options, configuration templates, file
292
+ paths, and troubleshooting.
293
+
294
+ ## Prerequisites
295
+
296
+ - **Docker** for running lnd/litd containers (the default deployment method)
297
+ - **Go 1.21+** only needed when building from source (`install.sh --source`) or
298
+ for lnget and the MCP server
299
+ - **jq** for JSON processing in shell scripts
300
+ - **Lightning Terminal** (optional) for generating LNC pairing phrases
301
+
302
+ Container image versions are pinned in `versions.env` at the repository root and
303
+ can be overridden via environment variables.
304
+
305
+ ## License
306
+
307
+ See [LICENSE](mcp-server/LICENSE).
@@ -0,0 +1,15 @@
1
+ #!/bin/sh
2
+
3
+ # This wrapper script is a placeholder that gets replaced by the actual
4
+ # binary during npm postinstall. If you see this message, the postinstall
5
+ # script did not run successfully.
6
+ #
7
+ # To fix this, try:
8
+ # npm rebuild @lightninglabs/lightning-mcp-server
9
+ #
10
+ # Or build from source:
11
+ # cd mcp-server && make build
12
+
13
+ echo "Error: lightning-mcp-server binary not installed." >&2
14
+ echo "Run 'npm rebuild @lightninglabs/lightning-mcp-server' or build from source." >&2
15
+ exit 1