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

MCP `runs` answers with the `ui://forge/run` card, as `now` does #5348

Parked opened this
Closed without merging

scout/forge:scout/5320-mcp-runs-answers-with-the-ui-forge-run-c → main 1 commit fork 2 threads · 2 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
2 files changed +27 −0
src/web/studio/cards.ts +11
@@ -42,6 +42,7 @@ export const CARD_KINDS: readonly CardKind[] = ["app", "run", "decision", "wave"
4242 export const CARD_OF_TOOL: Readonly<Record<string, CardKind>> = {
4343 apps: "app",
4444 now: "run",
45 runs: "run",
4546 asks: "decision",
4647 milestones: "wave",
4748 map: "map",
@@ -101,6 +102,16 @@ export function cardFor(tool: string, value: unknown, origin = ""): Card | undef
101102 for (const a of apps.slice(0, 3))
102103 if (text(a["app"]) !== "")
103104 actions.push({ label: `Tell ${text(a["app"])}`, tool: "tell", args: { repo: text(a["app"]), context: {} }, words: true });
105 } else if (tool === "runs") {
106 // `runs` answers `{ runs: [{ id, kind, state, number, startedAt, endedAt }] }`,
107 // newest first; it names no app, so the card offers no stop.

Not blocking: the card's title comes from CARD_TITLE.run, which is "Working now". For runs it will head a list of mostly finished (done or failed) runs, and the direction asks for honest words. If someone touches this again, pass a title per tool (for example "Runs" for runs) rather than per kind. The ui://forge/run resource can stay shared.

108 const runs = list(obj(value)["runs"]).map(obj);
109 status = runs.length === 0 ? "no runs" : `${runs.length} run${runs.length === 1 ? "" : "s"}`;
110 for (const r of runs.slice(0, LIMIT))
111 rows.push({
112 label: `${text(r["kind"])} ${text(r["id"])}`,
113 value: `${r["number"] == null ? "" : `#${text(r["number"])} — `}${text(r["state"])}`,
114 });
104115 } else if (kind === "run") {
105116 const runs = list(value).map(obj);
106117 status = runs.length === 0 ? "nothing running" : `${runs.length} going`;
test/mcp.test.ts +16
@@ -1149,6 +1149,22 @@ describe("the forge over MCP", () => {
11491149 expect(body.result.structuredContent.card.kind).toBe("feed");
11501150 });
11511151
1152 test("runs answers with the run card, newest first, twelve rows at most", async () => {
1153 const { cardFor } = await import("../src/web/studio/cards.ts");
1154 const runs = Array.from({ length: 15 }, (_, i) => ({
1155 id: `r${i}`, kind: "agent", state: "done", number: i === 0 ? null : i, startedAt: 1, endedAt: 2,
1156 }));
1157 const card = cardFor("runs", { runs })!;
1158 expect(card.kind).toBe("run");
1159 expect(card.rows).toHaveLength(12);
1160 expect(card.rows[0]).toEqual({ label: "agent r0", value: "done" });
1161 expect(card.rows[1]).toEqual({ label: "agent r1", value: "#1 — done" });
1162 const { body } = await call(rw, "tools/call", { name: "runs", arguments: { repo: "alice/game" } });
1163 expect(body.result.structuredContent.card.kind).toBe("run");
1164 const tools = (await call(rw, "tools/list")).body.result.tools;
1165 expect(tools.find((t: any) => t.name === "runs")._meta?.ui?.resourceUri).toBe("ui://forge/run");
1166 });
1167
11521168 test("a tool result carries the card it renders", async () => {
11531169 const { body } = await call(rw, "tools/call", { name: "apps", arguments: {} });
11541170 const card = body.result.structuredContent.card;

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs