Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8433867
refactor(admin): extract the settings write into one transport-free f…
chappie-daemon Nov 19, 2026
7a1cde0
feat(admin): serve the admin MCP server on stdio (#1183)
chappie-daemon Nov 19, 2026
44d0372
fix(admin): answer the round-1 review of the admin MCP server
chappie-daemon Nov 19, 2026
dbce701
fix(admin): answer the round-2 review of the admin MCP server
chappie-daemon Nov 20, 2026
14b6bbc
docs(admin): say how D18's mcp audit action is composed
chappie-daemon Nov 20, 2026
7a09de4
test(admin): pin get_event's refusal of an unknown key
chappie-daemon Nov 20, 2026
80a631a
docs(admin): the changeset says the MCP mode is its own process
chappie-daemon Nov 20, 2026
d6b3742
fix(admin): list_events counts page slots, not surviving rows
chappie-daemon Nov 20, 2026
30fc4e7
feat(admin): give the stdio door its own scoped credential
chappie-daemon Nov 20, 2026
9dbd43e
docs(admin): record the scoped credential in CONFIGURATION, ADR D19 a…
chappie-daemon Nov 20, 2026
ab570bb
fix(admin): check the token file's mode on the descriptor it was open…
chappie-daemon Nov 20, 2026
1d92d1f
docs(admin): cite the re-measured per-call read in D19
chappie-daemon Nov 20, 2026
8cae06f
fix(admin): keep the payments refusal on the relay path, not the stdi…
chappie-daemon Nov 20, 2026
06d4621
fix(admin): refuse a token file that is not a regular file
chappie-daemon Nov 20, 2026
1acec51
docs(admin): state D19's revocation as the calls the code makes
chappie-daemon Nov 20, 2026
6f53811
fix(admin): make the scope table total and check the descriptor's target
chappie-daemon Nov 20, 2026
a4b3919
docs(admin): say the permission rule, not an example of it
chappie-daemon Nov 20, 2026
1094c26
fix(admin): refuse a tool name the tool table does not carry
chappie-daemon Nov 20, 2026
59e6fe4
fix(admin): bound the token document's read, not only its size
chappie-daemon Nov 20, 2026
2c977e8
test(admind): assert the size rule inside each flag entry
chappie-daemon Nov 20, 2026
d54a6db
fix(admin): refuse a name the router does not dispatch
chappie-daemon Nov 20, 2026
6b71490
perf(admin): reserve the token document's read buffer
chappie-daemon Nov 20, 2026
2886cb7
fix(admin): cut and escape the caller's name in the log
chappie-daemon Nov 20, 2026
3c83570
docs(admin): say what D18's refusal asks and what D19's read names
chappie-daemon Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/admin-mcp-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
---

feat(admin): the admin MCP server, slice 1 — four tools over stdio

A new Rust crate serves `settings_get`, `settings_set`, `list_events` and
`get_event` on stdin/stdout through `rmcp`, served by `nostreamd --mcp-stdio` as a process
of its own over the same config directory. Every call is decided by a scoped token document
the mode is handed by file (`--admin-token-file`, a regular file of at most 4 KiB with no group
or other permission — 0600 is the usual mode — re-read on every call so deleting or rewriting it
is the revocation) or by an inherited descriptor (`--admin-token-fd`, held to the same rules and
read once at start); `settings_set` needs the document's `write` scope, and a denied write is
refused and recorded as `mcp.denied`. A console session token no longer authenticates the mode and
`NOSTREAM_ADMIN_TOKEN` is retired: setting it refuses the start. Executed calls are audited to
`admin-audit.jsonl` under one `mcp.<tool>` action; those names are recorded as ADR 0014 D18 and
the credential as D19.

Rust only: no published package changes, so this entry carries no version bump. The
operator-facing carriers are the mode's `--help`, `CONFIGURATION.md` and ADR 0014 D19.
47 changes: 47 additions & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The following environment variables can be set:
| RELAY_PRIVATE_KEY | Relay's private key in hex | (auto-generated) |
| WORKER_COUNT | Number of workers override | No. of available CPUs |
| LOG_FORMAT | Set to `json` to replace the startup banner with one `relay starting` record, so every line the relay writes parses as JSON. | (banner) |
| NOSTREAM_ADMIN_TOKEN | **Retired.** It used to carry a console session token to `nostreamd --mcp-stdio`; it grants nothing now, and setting it makes the mode refuse to start. See [The admin MCP mode](#the-admin-mcp-mode---mcp-stdio). | (unset: the mode refuses to start if it is set) |
| DB_URI | PostgreSQL URI (overrides DB_HOST, DB_PORT, etc.) | |
| DB_HOST | PostgresSQL Hostname | |
| DB_PORT | PostgreSQL Port | 5432 |
Expand Down Expand Up @@ -71,6 +72,52 @@ The following environment variables can be set:
| ZEBEDEE_API_KEY | Zebedee Project API Key | |
| NWC_URL | NWC connection URL (`nostr+walletconnect://...`) | |

## The admin MCP mode (`--mcp-stdio`)

`nostreamd --mcp-stdio` serves the admin MCP server (`settings_get`, `settings_set`,
`list_events`, `get_event`) on stdin/stdout and exits when stdin closes. It binds no socket,
opens no store of its own, and writes its log lines to **stderr** so nothing but JSON-RPC crosses
stdout.

Its credential is a **scoped token document** of its own — never a console session token and never
an environment variable. Deliver it one of two ways; exactly one is required:

| Flag | What it reads |
|---|---|
| `--admin-token-file <path>` | The document in a **regular** file that carries **no group or other permission** — `mode & 0o077 == 0`, which `0600` satisfies and a read-only `0400` does too — of at most 4 KiB. Anything else refuses the start, naming what it found: a group- or world-accessible mode, a FIFO, a device or a directory there (the mode re-opens the file on every call, and opening a FIFO waits for a writer), or a file too large to be a document. It is re-read on **every call**, so deleting or rewriting it is the revocation: narrowing it to reads takes effect on the next call, with nothing restarted. |
| `--admin-token-fd <n>` | The same document on an inherited descriptor, conventionally `3` (`exec 3<token.json`). It is read **once at start**, so its lifetime is the process's — a rewrite of the file it came from changes nothing until the process is restarted. The descriptor's target is held to the same rules as the file form's: a regular file, no group or other permission, at most 4 KiB. |

The document is JSON, and `scopes` is optional:

```json
{ "scopes": ["write"] }
```

| Document | What it may call |
|---|---|
| `{}` or `{ "scopes": [] }` | The read tools: `settings_get`, `list_events`, `get_event`. |
| `{ "scopes": ["write"] }` | The read tools and `settings_set`. |

`write` is the only accepted scope, and an unknown name — a typo, or a document from another tool
— refuses to start rather than being narrowed silently. A call the document's scopes deny is
refused with `Forbidden: <tool> needs the "write" scope` and recorded as one `mcp.denied` line in
`<config>/admin-audit.jsonl`, because it is a call the door authenticated and then denied; a call
with no readable document answers `Unauthorized` and is not recorded, because there is nothing to
attribute it to.

The mode also needs `admin.enabled: true` in the settings (else every call answers `Not Found`).
`SECRET` is **not** a prerequisite: the door derives no session key. The console's own HTTP
surface is unchanged and still authenticates with `SECRET` and `POST /admin/login` sessions.

Run it from the directory that holds `resources/` — the daemon reads its default settings from
`resources/default-settings.yaml`, resolved against the working directory — and from nowhere else:

```sh
install -m 0600 /dev/null /etc/nostream/admin-token.json
printf '{"scopes": ["write"]}\n' > /etc/nostream/admin-token.json
nostreamd --config-dir /etc/nostream --mcp-stdio --admin-token-file /etc/nostream/admin-token.json
```

## I2P

I2P support is provided as a sidecar container (i2pd) via `docker-compose.i2p.yml`, mirroring the Tor setup. No application-level environment variables are needed — the i2pd container creates an I2P server tunnel that forwards traffic to nostream's WebSocket port.
Expand Down
198 changes: 198 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ nostream-admin = { path = "crates/nostream-admin" }
nostream-cli = { path = "crates/nostream-cli" }
nostream-config = { path = "crates/nostream-config" }
nostream-core = { path = "crates/nostream-core" }
nostream-mcp = { path = "crates/nostream-mcp" }
nostream-relay = { path = "crates/nostream-relay" }
nostream-services = { path = "crates/nostream-services" }
nostream-storage = { path = "crates/nostream-storage" }
Expand All @@ -40,6 +41,7 @@ opentelemetry = "0.33.1"
opentelemetry-otlp = { version = "0.33.1", default-features = false, features = ["trace", "grpc-tonic"] }
opentelemetry_sdk = { version = "0.33.1", default-features = false, features = ["trace", "rt-tokio"] }
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
rmcp = { version = "3.11", features = ["server", "transport-io", "transport-async-rw"] }
scrypt = "0.11"
secp256k1 = "0.33.1"
serde = { version = "1", features = ["derive"] }
Expand Down
Loading
Loading