Skip to content

feat(mcp): add the relay_status tool over a published status document - #1209

Merged
chappie-daemon merged 28 commits into
rewrite/mainfrom
factory/035-mcp-relay-status
Nov 21, 2026
Merged

chappie-daemon merged 28 commits into
rewrite/mainfrom
factory/035-mcp-relay-status

Conversation

@chappie-daemon

@chappie-daemon chappie-daemon commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Slice 2 of #1183: one tool, relay_status — uptime, worker health, version, connection count, and the NIP-11 document — plus the two pieces no other slice needs.

What ships

  • A published status document. The tool answers in the --mcp-stdio process; the relay lives in the daemon's, and heartbeats are process memory. So the daemon writes <config>/relay-status.json (generatedAt, uptimeSeconds, activeConnections, relayPubkey, workers) every 5 s with an atomic temp-and-rename, and the stdio process reads it per call. A fact with no document fresher than 30 s is null with a reason naming the file — never a 0 that reads as "nothing is connected". A 0 only ever comes from a document that says 0.
  • ConnectionCap::live_total() — the total the cap could not answer before; it held per-address counts and a tracked-address count, so a total was not derivable.
  • nostream_relay::nip11 — the document builder, absent until now (nip-parity.md D1 kept the surface shut). Eleven top-level keys and seventeen limitation keys, each from a source the ADR names; seven keys are dropped with reasons, including the two with no Rust source at all. This closes nip-parity.md item 11, the deferred field-set decision.
  • The tool — TOOL_RELAY_STATUS, its TOOLS row, a handler that takes no arguments, and its audit line (mcp.relay_status).

The relay's identity is published, not re-derived. nip11.self comes from the daemon's document — the key the relay actually signs with — and the MCP process reads no key material at all, so a door started with a different secret cannot name a key the relay never signs with.

nostream-cli info keeps its own assembly: its output is pinned byte-for-byte by the CLI's acceptance cases and carries no document, so sharing the builder would buy nothing and risk the pin. The reason is in the module doc and ADR 0016 D4.

Decisions

ADR 0016 records seven, each with its cost: the document and its two sources; the seam being two concrete places rather than a trait (the tree's trait precedents invert a dependency, and nothing here needs inverting); the document's shape; the field set; supported_nips's filters; restricted_writes' arms; and the payload's shapes. ADR 0014 is amended where its single-writer decision and its audit vocabulary meet this job.

Verification

At db8ff8c0, the approver's own runs:

check result
cargo test --workspace --all-features 111 targets, 1 756 passed / 0 failed / 7 ignored
cargo test -p nostream-mcp 58 across seven targets (relay_status 10, tools_list 5, auth 11, audit 4, tool_payloads 23, lib 5)
new and touched targets nip11 7, status 9, transport 21, handlers 66, admin_http 3, mcp_stdio 17
git merge-tree against the base clean

Five payload states driven on the built binary in one --mcp-stdio process: no document, corrupt, 40 s-stale → five nulls with the reason and no self; fresh saying 0 → 0 with its key as self; fresh with values → the document's numbers. A 13 s daemon run on a config directory holding only settings.yaml produced the five-key document with the modification time advancing 5 004 ms apart and no warnings.

Two limits, stated rather than implied: the database-backed sets need a Postgres service and are #[ignore]d here (ignored: 7, run by CI's parity step), and AC7 — the case that starts the real daemon and watches the file appear — is the only test that proves a writer runs, so it is the one to read first.

Part of #1183. Slices 3–5 are not registered here and the issue stays open.

@changeset-bot

changeset-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: db8ff8c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When 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

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b5a9057-1365-4159-bfbd-a25c0c575681

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the latest change addresses the remaining numbered finding.

Summary

Adds relay_status and a NIP-11 document builder.

  • The daemon publishes fresh relay facts for the MCP process to read.
  • The NIP-11 document reflects the relay’s configured features and limits.
  • The MCP server answers relay status through a new read-only tool.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Daemon["Relay daemon"] -->|"Atomic write every 5 seconds"| File["relay-status.json"]
  File -->|"Read on each call"| MCP["relay_status"]
  Settings["Settings and version"] --> Builder["NIP-11 builder"]
  File -->|"Fresh signing identity"| Builder
  Builder --> MCP
Loading

Reviews (12) · Last reviewed commit: "docs(settings): the self rule differs by..." · Reviewed by Greptile

Comment thread crates/nostream-relay/src/nip11.rs Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 15:42

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 15:53

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 16:32

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 16:42

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 16:52

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 16:59

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 17:12

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

Comment thread CLI.md Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 17:14

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 17:39

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

Comment thread resources/default-settings.yaml Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 21, 2026 17:41

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@coveralls

coveralls commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 44931415495

Coverage remained the same at 77.582%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 12081
Covered Lines: 9792
Line Coverage: 81.05%
Relevant Branches: 6342
Covered Branches: 4501
Branch Coverage: 70.97%
Branches in Coverage %: Yes
Coverage Strength: 759.44 hits per line

💛 - Coveralls

@chappie-daemon
chappie-daemon merged commit 443cb98 into rewrite/main Nov 21, 2026
22 checks passed
@chappie-daemon
chappie-daemon deleted the factory/035-mcp-relay-status branch November 21, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants