Repository navigation
feat(admin): serve the admin MCP server on stdio (#1183, slice 1) - #1197
Conversation
🦋 Changeset detectedLatest commit: 3c83570 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
[High impact] The PR appears safe to merge; no new blocking issue was found.
|
|
Hosted-review triage: the P2 on |
A page's size is the slots the store spent. collect_records drops StreamedEvent::Vanished, which is the store's signal that a selected key was removed before its value was read (a replacement hard-deletes the row it supersedes, a retention pass removes a soft-deleted one), so a full page that lost a row answered 499 rows with truncated: false while another matching row remained unread. collect_page returns the rows and the slots beside them, the tool derives the marker from the slots, and a case drives a real page whose second selected slot vanished.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Slice 1 of #1183: an MCP admin server over stdio, with a credential of its own.
The credential
{"scopes": ["write"]}—scopesoptional, the keyset closed, an unknown scope refuses the load.
--admin-token-file PATH(a regular file with no group or other permission, at most4 KiB, re-read on every call, so deleting or rewriting it is the revocation) or
--admin-token-fd N(the same checks on the descriptor, read once — the process's lifetime).settings_get,list_events,get_event) are what a token gets by default;settings_setneedswrite.NOSTREAM_ADMIN_TOKENis retired: set it and the mode refuses to start, naming the variable.A console session token has no path in — the session-key check is not consulted here.
What ships
crates/nostream-mcpandnostreamd --mcp-stdioserve four tools over stdio, in a process oftheir own over the same config directory (ADR 0012 D9 puts a second process on one store
directory outside its contract, and the store is not wired for either mode yet). Every dispatched
call appends one line to
<config>/admin-audit.jsonlundermcp.<tool>; a scope denial appendsmcp.deniedwith{tool, scope}and no argument values; a credential refusal appends nothing.ADR 0014 D18 (the surface, the audit table) and D19 (this credential) record the decisions.
Slices 2–5 (relay status, delete/user admin, invoices and reports, maintenance) are cut in the
job's
spec.mdand discussed on #1183.Why the credential changed
The first approved tree used a console session token in an environment variable. It was escalated
rather than merged — an env var is readable at
/proc/<pid>/environ, inherited by every child, andthat token carried settings write into a second process with no rate limiter in front of it. The
operator's answer was "narrow the credential"; this is that build, and the escalation is the reason
the diff is larger than the four tools.
Verification
cargo test --workspace --all-features— 105 targets, 1582 passed, 0 failed, 6 ignored (the sixneed a Postgres URL), re-taken independently by the approver.
cargo fmt --all --checkclean, bothclippy passes clean (
-D warnings, and the strict deny-set on lib+bins), release build clean.mcp_stdio15,auth11,tool_payloads23,tools_list5,audit4,nostream-admin155.Eight review rounds; every blocking finding was fixed with a case that fails at the previous head, and
the load-bearing ones were:
_ => falsea fifth tool could bypass — now aconsttable the dispatchcannot avoid, with a case over
rmcp's own tool list;list_eventsanswered unfiltered to a mistyped argument name — an unknown key is now refused,naming the accepted set;
{"id":""}cost 8,153 µs over 20,000 keys — criteria are validated to the wire's 4-hex floorbefore any store read (10,994 → 843 µs);
one conjunction (
row && router.has_route) now decides both, and a route-less row is refused;/proc/self/environread whole, a rewrite accepted withmetadata ≤ 4 KiB) —
take(cap + 1)plus a reserved buffer (a 4 KiB read: −3.36 µs, 2 reads not 9).Known, filed separately
settings.changedpayload. Pre-existing on the HTTP console; this door needs an explicitwritescope to reach it.
rmcp3.11.0 logs request arguments verbatim at DEBUG, so--log-level debugwrites atoken to stderr. Default level is INFO.
Closes #1183is absent on purpose: the repository's default branch ismain, so aClosesline ona PR into
rewrite/maincloses nothing; #1183 is closed by hand when the slice merges.