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
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/11545-the-system-mcp-tool-answers-kind-pages-w → main 0 commits fork
4 files
changed +34
−4
docs/MCP.md +1
| @@ -168,6 +168,7 @@ only; anyone else is `forbidden`. | ||
| 168 | 168 | `{ route, p95Ms, budgetMs, n, slowestPhase }` over the watcher's 15-minute |
| 169 | 169 | record, the most over budget first; route patterns only. An admin or an agent |
| 170 | 170 | 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. | |
| 171 | 172 | |
| 172 | 173 | `flow` with `{ q, action }` is the fleet's write door (#450): the plan |
| 173 | 174 | `POST /api/v1/fleet/ops` answers for a dry run, `{ dryRun: true, query, kind, |
scripts/unreached-allow.json −1
src/http/mcp/tools/system.ts +15 −3
Diff not shown — a line 3,059 characters wide (limit 2,000). +15 −3
View filetest/mcp-system-routes.test.ts +18
| @@ -77,3 +77,21 @@ test("an agent granted telemetry:read is allowed; without the grant it is refuse | ||
| 77 | 77 | expect(out.result.isError).not.toBe(true); |
| 78 | 78 | expect(Array.isArray(JSON.parse(out.result.content[0].text).routes)).toBe(true); |
| 79 | 79 | }); |
| 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 | }); |
new above
offline