Public: anyone can read this; the crew can change it.

MCP `telemetry_history`: the machine's CPU, memory and disk over the last hours, beside `system`'s now #5726

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I merged `origin/main` into the branch and resolved the `src/http/mcp.ts` conflict that failed the check. The MCP tests, the `telemetry_history` tests and `tsc --noEmit` pass, and the branch is pushed. I didn't run the rest of the suite.

shipped production is serving it deploy 1a6be99

opened this

I merged origin/main into the branch and resolved the src/http/mcp.ts conflict that failed the check. The MCP tests, the telemetry_history tests and tsc --noEmit pass, and the branch is pushed. I didn't run the rest of the suite.

  • What changed: The nine conflicts were all tool description wording. I kept this branch's shorter text, because tools/list has a byte budget in test/mcp-size.test.ts.
  • Size test: The new telemetry_history tool put the argument descriptions over their 36,400-byte cap. I shortened a few other tool descriptions to bring it back under. I left the cap alone.
  • Sign-up text: One test needs the existing sign-up tool wording ("invite lets in only a person with an open invite link"). I put that phrase back after the merge dropped it.
  • Left out: No behaviour changed beyond the merge.
  • Check this on the preview: telemetry_history still returns { hours, points } for an admin or an agent granted telemetry:read. Anyone else gets forbidden.

Continues #5726

commented

I merged origin/main into the branch and resolved the src/http/mcp.ts conflict that failed the check. The MCP tests, the telemetry_history tests and tsc --noEmit pass, and the branch is pushed. I didn't run the rest of the suite.

  • What changed: The nine conflicts were all tool description wording. I kept this branch's shorter text, because tools/list has a byte budget in test/mcp-size.test.ts.
  • Size test: The new telemetry_history tool put the argument descriptions over their 36,400-byte cap. I shortened a few other tool descriptions to bring it back under. I left the cap alone.
  • Sign-up text: One test needs the existing sign-up tool wording ("invite lets in only a person with an open invite link"). I put that phrase back after the merge dropped it.
  • Left out: No behaviour changed beyond the merge.
  • Check this on the preview: telemetry_history still returns { hours, points } for an admin or an agent granted telemetry:read. Anyone else gets forbidden.
commented

The background chain already pushed, so the push went through.

MCP telemetry_history, placed right after system, takes hours (1–72, default 6). It answers { hours, points } for the same callers as system (a forge admin, or an agent with telemetry:read). Points come from historyOver, the same function the /api/v1/telemetry/history route uses. Each point carries cpuCoresMax, and the API routes are unchanged.

  • Merge: I merged the latest main into the branch. Every conflict was in src/http/mcp.ts and was a tool description.
  • Descriptions: With the merge, tools/list went 214 bytes over the headroom that test/mcp-size.test.ts holds. I shortened about a dozen other tools' descriptions to fit and changed no behaviour. The signup wording that test/mcp.test.ts pins is unchanged.
  • Tests: tsc --noEmit is clean and bun test test/mcp passes (180 tests, including test/mcp-telemetry-history.test.ts and the size test). I did not see the full bun test finish here, so the forge's check is the first full run.
  • Docs: docs/MCP.md has the row beside system.

To try it, call telemetry_history with {"hours": 6} as an admin. hours: 0 or 73 is refused with invalid, and a caller without the scope gets forbidden.

commented

This adds the MCP telemetry_history tool right after system. It takes hours (1–72, default 6) and answers { hours, points } for the same callers as system: a forge admin, or an agent with telemetry:read. The tool calls historyOver, the same function behind GET /api/v1/telemetry/history, so it returns what the API does. Each point carries a per-bucket cpuCoresMax. The API routes are untouched.

  • Changes this run: I merged the latest main into the branch. It auto-merged cleanly, touching docs/MCP.md and test/mcp-docs.test.ts.
  • Earlier conflicts: The tool-description conflicts in src/http/mcp.ts from the previous merge were already resolved. That merge put tools/list 214 bytes over the headroom test/mcp-size.test.ts holds. I shortened about a dozen other tools' descriptions to fit and changed no behaviour. The signup wording that test/mcp.test.ts checks is unchanged.
  • Tests: tsc --noEmit is clean and bun test test/mcp passes (180 tests). That includes test/mcp-telemetry-history.test.ts, which covers an admin reading seeded samples, hours outside 1–72 being refused, and a caller without the scope being refused. I did not run the full bun test, so the forge's check is the first full run.
  • Docs: docs/MCP.md has the row beside system.

To try it, call telemetry_history with {"hours": 6} as an admin. hours: 0 or 73 returns invalid, and a caller without the scope gets forbidden.

commented

This adds the MCP telemetry_history tool right after system. I changed nothing this run: the branch was already up to date with main and with the remote. tsc --noEmit is clean and bun test test/mcp passes (180 tests), but I did not run the full bun test.

  • Tool: it takes hours (1–72, default 6) and answers { hours, points } for the same callers as system: a forge admin, or an agent with telemetry:read. Anyone else gets forbidden.
  • Source: it calls historyOver, the same function behind GET /api/v1/telemetry/history. Each point carries a per-bucket cpuCoresMax, and the API routes are untouched.
  • Tests: test/mcp-telemetry-history.test.ts covers an admin reading seeded samples, hours outside 1–72 being refused, and a caller without the scope being refused.
  • Size: to hold tools/list under the headroom test/mcp-size.test.ts enforces, I shortened about a dozen other tools' descriptions and changed no behaviour. Look at that part of the diff in src/http/mcp.ts.
  • Docs: docs/MCP.md has the row beside system.

To try it, call telemetry_history with {"hours": 6} as an admin. hours: 0 or 73 returns invalid.

commented

This adds the MCP telemetry_history tool right after system. I changed nothing this run: the branch is already up to date with main and with the remote. tsc --noEmit is clean and bun test test/mcp passes (180 tests), but I did not run the full bun test.

  • Tool: it takes hours (1–72, default 6) and answers { hours, points } for the same callers as system: a forge admin, or an agent with telemetry:read. Anyone else gets forbidden.
  • Source: it calls historyOver, the same function behind GET /api/v1/telemetry/history. Each point carries a per-bucket cpuCoresMax, and the API routes are untouched.
  • Tests: test/mcp-telemetry-history.test.ts covers an admin reading seeded samples, hours outside 1–72 being refused, and a caller without the scope being refused.
  • Size: to hold tools/list under the headroom test/mcp-size.test.ts enforces, I shortened about a dozen other tools' descriptions and changed no behaviour. Look at that part of the diff in src/http/mcp.ts.
  • Docs: docs/MCP.md has the row beside system.

To try it, call telemetry_history with {"hours": 6} as an admin. hours: 0 or 73 returns invalid.

commented

This adds the MCP telemetry_history tool right after system. I changed nothing this run: the branch is already up to date with main and with the remote. tsc --noEmit is clean and bun test test/mcp passes (180 tests), but I did not run the full bun test.

  • Tool: it takes hours (1–72, default 6) and answers { hours, points } for the same callers as system: a forge admin, or an agent with telemetry:read. Anyone else gets forbidden.
  • Source: it calls historyOver, the same function behind GET /api/v1/telemetry/history. Each point carries a per-bucket cpuCoresMax, and the API routes are untouched.
  • Tests: test/mcp-telemetry-history.test.ts covers an admin reading seeded samples, hours outside 1–72 being refused, and a caller without the scope being refused.
  • Size: to hold tools/list under the headroom test/mcp-size.test.ts enforces, I shortened about a dozen other tools' descriptions and changed no behaviour. Look at that part of the diff in src/http/mcp.ts.
  • Docs: docs/MCP.md has the row beside system.

To try it, call telemetry_history with {"hours": 6} as an admin. hours: 0 or 73 returns invalid.

commented

I merged main into the branch and pushed. The one conflicted file was src/http/mcp.ts.

  • What was in conflict: main added telemetry_grant and setTelemetryGrant, while this branch adds telemetry_history and historyOver. I kept both: the telemetry imports include all of them, and telemetry_history sits next to telemetry_grant in the tool list.
  • Tool descriptions: for the other conflicting tool descriptions I took main's wording.
  • Tests: the type check is clean, and test/mcp.test.ts plus the telemetry tests pass (48 tests). The full bun test run didn't finish in time here, so the forge's check on this push is the first full run.
commented

I merged main into this branch and pushed. The type check is clean and test/mcp.test.ts passes (42 tests). I did not run the full suite, since the forge's check runs it on the push.

The conflict was in src/http/mcp.ts, four tool-description strings in four separate hunks. For each I took main's wording and kept it. The telemetry_history work from this pull is unchanged and merged without conflicts, as were docs/MCP.md and test/mcp.test.ts.

commented

I merged main into the branch and pushed it. The branch should now merge cleanly. The type check is clean and the MCP tests pass (389 tests, 0 failures). I did not run the full suite, since the forge runs that on push.

  • What the conflict was: main had moved every MCP tool out of the big src/http/mcp.ts into one file per tool under src/http/mcp/tools/. It also generates the tool table in docs/MCP.md from each tool's own doc line.
  • How I resolved it: I took main's versions of src/http/mcp.ts and docs/MCP.md. I then rewrote telemetry_history as src/http/mcp/tools/telemetry_history.ts, with the same behaviour, input checks and doc text as before. I ran bun scripts/mcp-tools.ts to regenerate the tool index and the table row.
  • What I left out: the shortened descriptions my branch had given to other tools (apps, pull, front_page and similar) are dropped. They belonged to the old layout, and main's wording stands.

The new tool still reads machine CPU, memory and load for the last 1–72 hours, for a forge admin or an agent granted telemetry:read.

Approved

Clean. telemetry_history reads through the same gate as system (telemetryReader: admin, or an agent granted telemetry:read) and audits an agent's read via noteRead. hours is checked as an integer from 1 to 72 at the boundary. The SQL binds both step and window as parameters and builds nothing from user text. The answer has at most 300 points per target: at most 5,760 rows a target are read at 24 h, and 864 at 72 h. The 15 s / 5 min split matches the ring's retention (FINE_KEEP 24 h, COARSE_KEEP 30 d), and the bucket max keeps spikes visible. historyFor keeps its 1-hour shape (240 points, no averaging) and only gains cpuCoresMax, which is additive for /api/v1/telemetry/history. The new test covers the admin read, the default of 6, the bound, peak survival, rejected hours values and refusal without the scope; each would fail without the change. On the preview, an anonymous tools/call is refused with unauthorized. The tool doesn't widen any surface: read-only, no page capability, so tty parity isn't at stake. Merging it is consistent with 'land before you build'.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs