Skip to content

Commit 3a545ac

Browse files
Add ldk-server-mcp crate scaffolding for MCP gateway
v1 scaffolding for an HTTPS gateway that will expose the LDK Server gRPC API as an MCP (Model Context Protocol) server, plus a small admin web UI for minting scoped auth tokens to plug into Claude Desktop / Claude Code. This PR adds the foundational pieces only: - New `ldk-server-mcp` workspace crate with a TOML config, an `axum`-based HTTPS listener (HTTP/1.1 + HTTP/2 via `hyper-util`'s auto builder), and a `/healthz` endpoint - Self-signed TLS cert auto-generation in `storage_dir`, mirroring the daemon's pattern in `ldk-server/src/util/tls.rs` (the daemon code is unchanged; the v2 plan extracts the shared bits into a util crate) - A `DaemonClient` wrapper around `ldk-server-client` that loads the daemon's `api_key` and TLS cert from disk and verifies connectivity on boot via `GetNodeInfo` - `GatewayLogger` matching the daemon's `ServerLogger` style so operators see consistent log output across the two processes - Sample config in `contrib/ldk-server-mcp-config.toml` and a crate-level `README.md` - Brainstorm doc at `docs/brainstorms/2026-05-07-ldk-server-mcp.md` capturing the full v1 spec and the suggested PR breakdown for the rest of the work (sqlite token store, web UI, MCP tool layer over the ~40 RPCs, `SubscribeEvents` -> MCP notifications fan-out, Connect-to-Claude UX) The daemon is unmodified. 14 unit tests cover config parsing, scheme stripping, log-level validation, unknown-field rejection, the cert generate/load roundtrip, and the `/healthz` route. `cargo fmt`, `cargo clippy --all-targets -- -D warnings`, `cargo test`, `cargo check --release`, and `cargo doc --release` all pass for the new crate. This change was developed with Claude Code assistance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent bf4d8bd commit 3a545ac

15 files changed

Lines changed: 1662 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 91 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "2"
3-
members = ["ldk-server-cli", "ldk-server-client", "ldk-server-grpc", "ldk-server"]
3+
members = ["ldk-server-cli", "ldk-server-client", "ldk-server-grpc", "ldk-server", "ldk-server-mcp"]
44
exclude = ["e2e-tests"]
55

66
[profile.release]

contrib/ldk-server-mcp-config.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# LDK Server MCP gateway settings
2+
[gateway]
3+
# Address the gateway listens on for HTTPS (UI + future MCP endpoint).
4+
listen_addr = "127.0.0.1:3537"
5+
6+
# Directory the gateway uses for persistent state. Holds tls.crt / tls.key
7+
# (auto-generated if not provided), the future sqlite token store, and the
8+
# bootstrap admin token hash.
9+
storage_dir = "/var/lib/ldk-server-mcp"
10+
11+
# Optional. Defaults to "info". Accepts: error, warn, info, debug, trace, off.
12+
#log_level = "info"
13+
14+
# Optional. Defaults to <storage_dir>/ldk-server-mcp.log.
15+
#log_file_path = "/var/log/ldk-server-mcp.log"
16+
17+
# Optional TLS overrides. If both are omitted, a self-signed certificate is
18+
# auto-generated under storage_dir on first start (mirrors the daemon).
19+
#[gateway.tls]
20+
#cert_path = "/etc/ldk-server-mcp/tls.crt"
21+
#key_path = "/etc/ldk-server-mcp/tls.key"
22+
# Extra hosts to include in the auto-generated certificate's SAN list. The
23+
# names "localhost" and "127.0.0.1" are always included.
24+
#hosts = ["mcp.example.com"]
25+
26+
# Connection details for the upstream LDK Server daemon.
27+
[daemon]
28+
# Bare host:port; the scheme is stripped if present.
29+
address = "127.0.0.1:3536"
30+
31+
# Path to the api_key file that the daemon writes on first start. Typically
32+
# under <daemon storage_dir>/<network>/api_key. Must be absolute.
33+
api_key_path = "/var/lib/ldk-server/bitcoin/api_key"
34+
35+
# Path to the daemon's TLS certificate. Used to pin the daemon's self-signed
36+
# cert when the gateway connects to it. Must be absolute.
37+
tls_cert_path = "/var/lib/ldk-server/tls.crt"

0 commit comments

Comments
 (0)