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

The system MCP tool answers `kind: "pages"` with the same page-budget rows /system shows #16755

Merged opened this

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

Merged

torque/forge:torque/11545-the-system-mcp-tool-answers-kind-pages-w → main 0 commits fork

  • Merged. torque/11545-the-system-mcp-tool-answers-kind-pages-w was merged into main as df6de28.

Review

Sign in to review this change.
4 files changed +34 −4
docs/MCP.md +1
@@ -168,6 +168,7 @@ only; anyone else is `forbidden`.
168168 `{ route, p95Ms, budgetMs, n, slowestPhase }` over the watcher's 15-minute
169169 record, the most over budget first; route patterns only. An admin or an agent
170170 granted `telemetry:read`.
171 `{ kind: "pages" }` answers `pageBudgetRows`: one `{ page, pattern, budgetMs, statements, medianMs, n, over }` per budgeted page, as /system's page budgets; same gate.
171172
172173 `flow` with `{ q, action }` is the fleet's write door (#450): the plan
173174 `POST /api/v1/fleet/ops` answers for a dry run, `{ dryRun: true, query, kind,
scripts/unreached-allow.json −1
@@ -1,5 +1,4 @@
11 [
22 "src/apps/changes.ts",
3 "src/perf/page_budget_read.ts",
43 "src/spawn/pod.ts"
54 ]
src/http/mcp/tools/system.ts +15 −3

Diff not shown — a line 3,059 characters wide (limit 2,000). +15 −3

View file
test/mcp-system-routes.test.ts +18
@@ -77,3 +77,21 @@ test("an agent granted telemetry:read is allowed; without the grant it is refuse
7777 expect(out.result.isError).not.toBe(true);
7878 expect(Array.isArray(JSON.parse(out.result.content[0].text).routes)).toBe(true);
7979 });
80
81 test("pages answers one row per PAGE_BUDGETS entry; an unknown kind names pages", async () => {
82 const { PAGE_BUDGETS } = await import("../src/perf/page_budget.ts");
83 const post = async (token: string, kind: string) => {
84 const res = await fetch(`${servers.url}/mcp`, {
85 method: "POST",
86 headers: { "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${token}` },
87 body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "system", arguments: { kind } } }),
88 });
89 return (await res.json()) as any;
90 };
91 const out = JSON.parse((await post(admin, "pages")).result.content[0].text);
92 expect(out.pages.map((r: any) => r.page)).toEqual(PAGE_BUDGETS.map((b) => b.page));
93 expect((await post(plain, "pages")).result.isError).toBe(true);
94 const bad = await post(admin, "nope");
95 expect(bad.result.isError).toBe(true);
96 expect(bad.result.content[0].text).toContain("pages");
97 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs