The best way to control Claude Code, Codex and more from any computer or phone
fix(web,mobile): MCP app calls keep their tool row and result beside the app card (#33347)
Julius Marminge committed
Nov 12, 2026 at 23:57 UTC
dd7918e1e2c39d06d73c76096fc0c1129762cdb2
11 files changed
+265
-62
apps/mobile/src/lib/threadActivity.test.ts
+30
-1
@@ -54,7 +54,36 @@ it("shows a captured MCP app for a failed deferred write", () => {
54
input: {},
55
output: { t3McpApp: mcpApp, result: { content: [], isError: true } },
56
};
57
- expect(buildThreadFeed([projected(item, 0)])).toMatchObject([{ type: "mcp-app", app: mcpApp }]);
57
+ expect(buildThreadFeed([projected(item, 0)])).toMatchObject([
58
+ { type: "activity-group" },
59
+ { type: "mcp-app", app: mcpApp },
60
+ ]);
61
+});
62
+
63
+it("keeps an MCP app call's tool activity beside its app card", () => {
64
+ const mcpApp = {
65
+ attachmentId: "repro-app-html",
66
+ server: "repro",
67
+ tool: "aggregate_rum_events",
68
+ resourceUri: "ui://repro/dataviz",
69
+ };
70
+ const item: OrchestrationV2TurnItem = {
71
+ ...base("repro-app", "2026-08-29T00:00:00.000Z", 1),
72
+ type: "dynamic_tool",
73
+ toolName: "repro.aggregate_rum_events",
74
+ input: { query: "@type:view" },
75
+ output: {
76
+ t3McpApp: mcpApp,
77
+ result: { content: [{ type: "text", text: "Notice\nview\tcount\n/home\t42" }] },
78
+ },
79
+ };
80
+ const feed = buildThreadFeed([projected(item, 0)]);
81
+ expect(feed).toContainEqual(expect.objectContaining({ type: "mcp-app", app: mcpApp }));
82
+ const activities = feed.flatMap((entry) =>
83
+ entry.type === "activity-group" ? entry.activities : [],
84
+ );
85
+ expect(activities).toHaveLength(1);
86
+ expect(activities[0]?.getFullDetail()).toContain("@type:view");
87
});
88
89
it("keeps historical plan detail accessible from its paged turn item", () => {
apps/mobile/src/lib/threadActivity.ts
+29
-32
@@ -317,7 +317,7 @@ const projectedEntriesCache = new WeakMap<
317
OrchestrationV2ProjectedTurnItem,
318
{
319
readonly attemptId: RunAttemptId | null;
320
- readonly entry: RawThreadFeedEntry;
320
+ readonly entries: ReadonlyArray<RawThreadFeedEntry>;
321
}
322
>();
323
const localMessageEntriesCache = new WeakMap<
@@ -2409,8 +2409,10 @@ export function buildThreadFeed(
2409
const attemptId = resolveAttemptId(item);
2410
const cached = projectedEntriesCache.get(row);
2411
if (cached?.attemptId === attemptId) {
2412
- entries.push(cached.entry);
2413
- entryRows.push(index);
2412
+ for (const entry of cached.entries) {
2413
+ entries.push(entry);
2414
+ entryRows.push(index);
2415
+ }
2416
continue;
2417
}
2418
const createdAt = DateTime.formatIso(item.startedAt ?? item.updatedAt);
@@ -2426,24 +2428,7 @@ export function buildThreadFeed(
2428
runId: item.runId,
2429
render,
2430
};
2429
- projectedEntriesCache.set(row, { attemptId, entry });
2430
- entries.push(entry);
2431
- entryRows.push(index);
2432
- continue;
2433
- }
2434
- const app = item.type === "dynamic_tool" ? mcpAppFromToolItem(item) : undefined;
2435
- if (app) {
2436
- const entry: RawThreadFeedEntry = {
2437
- type: "mcp-app",
2438
- id: `mcp-app:${row.visibility}:${row.sourceThreadId}:${row.sourceItemId}`,
2439
- createdAt,
2440
- runId: item.runId,
2441
- sourceThreadId: row.sourceThreadId,
2442
- itemId: row.sourceItemId,
2443
- revision: turnItemDetailRevision(item),
2444
- app,
2445
- };
2446
- projectedEntriesCache.set(row, { attemptId, entry });
2431
+ projectedEntriesCache.set(row, { attemptId, entries: [entry] });
2432
entries.push(entry);
2433
entryRows.push(index);
2434
continue;
@@ -2480,22 +2465,34 @@ export function buildThreadFeed(
2465
projectedItem: row,
2466
},
2467
};
2483
- projectedEntriesCache.set(row, { attemptId, entry });
2468
+ projectedEntriesCache.set(row, { attemptId, entries: [entry] });
2469
entries.push(entry);
2470
entryRows.push(index);
2471
continue;
2472
}
2473
const activity = toFeedActivity(row, attemptId);
2489
- const entry: RawThreadFeedEntry = {
2490
- type: "activity",
2491
- id: activity.id,
2492
- createdAt,
2493
- runId: item.runId,
2494
- activity,
2495
- };
2496
- projectedEntriesCache.set(row, { attemptId, entry });
2497
- entries.push(entry);
2498
- entryRows.push(index);
2474
+ const rowEntries: RawThreadFeedEntry[] = [
2475
+ { type: "activity", id: activity.id, createdAt, runId: item.runId, activity },
2476
+ ];
2477
+ // The card follows its tool activity: a feed restart resumes after a row's last entry.
2478
+ const app = item.type === "dynamic_tool" ? mcpAppFromToolItem(item) : undefined;
2479
+ if (app) {
2480
+ rowEntries.push({
2481
+ type: "mcp-app",
2482
+ id: `mcp-app:${row.visibility}:${row.sourceThreadId}:${row.sourceItemId}`,
2483
+ createdAt,
2484
+ runId: item.runId,
2485
+ sourceThreadId: row.sourceThreadId,
2486
+ itemId: row.sourceItemId,
2487
+ revision: turnItemDetailRevision(item),
2488
+ app,
2489
+ });
2490
+ }
2491
+ projectedEntriesCache.set(row, { attemptId, entries: rowEntries });
2492
+ for (const entry of rowEntries) {
2493
+ entries.push(entry);
2494
+ entryRows.push(index);
2495
+ }
2496
}
2497
const retainedMessageIds = new Set([
2498
...foldedAnswerRunIdByMessageId.keys(),
apps/server/src/orchestration-v2/WireProjection.test.ts
+39
@@ -228,6 +228,45 @@ describe("orchestration V2 wire projection", () => {
228
output: { content: [{ type: "image", mimeType: "image/png" }] },
229
});
230
expect(item.output.content[0]?.source.data).toBe(data);
231
+
232
+ const t3McpApp = {
233
+ attachmentId: "app-html",
234
+ server: "repro",
235
+ tool: "chart",
236
+ resourceUri: "ui://repro/chart",
237
+ };
238
+ const text = { type: "text", text: "Rendered chart" };
239
+ const appItem = {
240
+ ...item,
241
+ toolName: "repro.chart",
242
+ output: {
243
+ t3McpApp,
244
+ result: { content: [text, { type: "image", mimeType: "image/png", data }] },
245
+ },
246
+ };
247
+ expect(projectTurnItemForDetail(appItem)).toMatchObject({
248
+ output: { t3McpApp, result: { content: [text, { type: "image", mimeType: "image/png" }] } },
249
+ });
250
+ const largeOutput = projectTurnItemForDetail(appItem);
251
+ expect(
252
+ JSON.stringify(largeOutput.type === "dynamic_tool" ? largeOutput.output : null),
253
+ ).not.toContain(data);
254
+
255
+ const smallApp = {
256
+ t3McpApp,
257
+ result: { content: [text, { type: "image", mimeType: "image/png", data: "iVBORw0KGgo=" }] },
258
+ };
259
+ expect(projectTurnItemForDetail({ ...appItem, output: smallApp })).toMatchObject({
260
+ output: smallApp,
261
+ });
262
+
263
+ const forged = projectTurnItemForDetail({
264
+ ...appItem,
265
+ output: { t3McpApp: { ...t3McpApp, resourceUri: data }, result: { content: [text] } },
266
+ });
267
+ expect(
268
+ JSON.stringify(forged.type === "dynamic_tool" ? forged.output : null).length,
269
+ ).toBeLessThan(270_000);
270
});
271
272
it("keeps image markers when the rest of a tool output is too large to send", () => {
apps/server/src/orchestration-v2/WireProjection.ts
+17
-1
@@ -15,6 +15,7 @@ import {
15
dedupeSubagentBodies,
16
dedupeTurnItemBodies,
17
} from "@t3tools/shared/orchestrationV2DedupedBodies";
18
+import { MCP_APP_OUTPUT_KEY, readMcpAppReference } from "@t3tools/shared/mcpApp";
19
import {
20
compactDynamicToolOutput,
21
omitToolOutputImageData,
@@ -228,7 +229,7 @@ function boundDynamicValue(value: unknown): unknown {
229
}
230
231
/** Preserve ordered image markers in truncated output so clients can load images by index. */
231
-function boundToolOutput(output: unknown): unknown {
232
+function boundToolResult(output: unknown): unknown {
233
const omitted = omitToolOutputImageData(output);
234
const bounded = boundDynamicValue(omitted);
235
if (typeof bounded !== "string" || typeof omitted === "string") return bounded;
@@ -241,6 +242,21 @@ function boundToolOutput(output: unknown): unknown {
242
];
243
}
244
245
+function boundToolOutput(output: unknown): unknown {
246
+ if (typeof output !== "object" || output === null || !("result" in output)) {
247
+ return boundToolResult(output);
248
+ }
249
+ const app =
250
+ MCP_APP_OUTPUT_KEY in output ? readMcpAppReference(output[MCP_APP_OUTPUT_KEY]) : undefined;
251
+ if (app === undefined) return boundToolResult(output);
252
+ // The app receives this result, so its image data stays unless it is too large to send.
253
+ const fits = boundDynamicValue(output.result) === output.result;
254
+ return {
255
+ [MCP_APP_OUTPUT_KEY]: app,
256
+ result: fits ? output.result : boundToolResult(output.result),
257
+ };
258
+}
259
+
260
export function projectTurnItemForDetail(item: OrchestrationV2TurnItem): OrchestrationV2TurnItem {
261
switch (item.type) {
262
case "command_execution":
apps/web/src/session-logic.test.ts
+47
-2
@@ -1391,7 +1391,7 @@ describe("HTML renders in the timeline", () => {
1391
]);
1392
});
1393
1394
- it("hosts a captured MCP app in place, from any provider's tool", () => {
1394
+ it("hosts a captured MCP app after its tool row, from any provider's tool", () => {
1395
const mcpApp = {
1396
attachmentId: "render-thread-app-html",
1397
server: "weather",
@@ -1403,13 +1403,58 @@ describe("HTML renders in the timeline", () => {
1403
call.type === "dynamic_tool" ? { ...call, toolName: "weather.get_weather" } : call,
1404
);
1405
expect(entries.find((entry) => entry.kind === "mcp-app")).toMatchObject({
1406
- id: "render",
1406
+ id: "mcp-app:render",
1407
itemId: "render",
1408
mcpApp,
1409
});
1410
expect(rowsFor(entries, false)).toEqual(["message", "turn-fold", "mcp-app", "message"]);
1411
});
1412
1413
+ it("keeps an MCP app call's tool row and output beside its app card", () => {
1414
+ const mcpApp = {
1415
+ attachmentId: "render-thread-app-html",
1416
+ server: "repro",
1417
+ tool: "aggregate_rum_events",
1418
+ resourceUri: "ui://repro/dataviz",
1419
+ };
1420
+ const result = { content: [{ type: "text", text: "Notice\nview\tcount\n/home\t42" }] };
1421
+ const call = renderCall("completed", { t3McpApp: mcpApp, result });
1422
+ const entries = turn(
1423
+ call.type === "dynamic_tool" ? { ...call, toolName: "repro.aggregate_rum_events" } : call,
1424
+ );
1425
+ expect(entries.find((entry) => entry.kind === "mcp-app")).toMatchObject({ mcpApp });
1426
+ const toolRows = entries.flatMap((entry) =>
1427
+ entry.kind === "work" && entry.entry.toolTitle === "repro.aggregate_rum_events"
1428
+ ? [entry.entry]
1429
+ : [],
1430
+ );
1431
+ expect(toolRows).toMatchObject([{ toolData: { output: { result } } }]);
1432
+ });
1433
+
1434
+ it("drops an MCP app card when an update removes the call's app", () => {
1435
+ const mcpApp = {
1436
+ attachmentId: "render-thread-app-html",
1437
+ server: "repro",
1438
+ tool: "aggregate_rum_events",
1439
+ resourceUri: "ui://repro/dataviz",
1440
+ };
1441
+ const call = (output: unknown) => ({
1442
+ ...renderCall("completed", output),
1443
+ toolName: "repro.aggregate_rum_events",
1444
+ });
1445
+ const result = { content: [{ type: "text", text: "rows" }] };
1446
+ const input = (output: unknown) => ({
1447
+ visibleTurnItems: [visible(command("before", 1)), visible(call(output))],
1448
+ optimisticMessages: [],
1449
+ });
1450
+ const previous = deriveTimelineEntriesFromVisibleTurnItemsWithState(
1451
+ input({ t3McpApp: mcpApp, result }),
1452
+ );
1453
+ const nextInput = input({ result });
1454
+ const next = deriveTimelineEntriesFromVisibleTurnItemsWithState(nextInput, previous);
1455
+ expect(next.entries).toEqual(deriveTimelineEntriesFromVisibleTurnItems(nextInput));
1456
+ });
1457
+
1458
it("hosts an MCP app whose call failed, as a form-deferring write does", () => {
1459
const mcpApp = {
1460
attachmentId: "render-thread-app-html",
apps/web/src/session-logic.ts
+18
-16
@@ -652,22 +652,6 @@ export function deriveTimelineEntriesFromVisibleTurnItems(
652
continue;
653
}
654
655
- const mcpApp = item.type === "dynamic_tool" ? mcpAppFromToolItem(item) : undefined;
656
- if (mcpApp !== undefined) {
657
- entries.push({
658
- id: item.id,
659
- kind: "mcp-app",
660
- createdAt,
661
- runId: item.runId,
662
- sourceThreadId: row.sourceThreadId,
663
- itemId: row.sourceItemId,
664
- revision: turnItemDetailRevision(item),
665
- mcpApp,
666
- ...attemptMetadata,
667
- });
668
- continue;
669
- }
670
-
655
if (STANDALONE_V2_ITEM_TYPES.has(item.type)) {
656
entries.push({
657
id: item.id,
@@ -686,6 +670,21 @@ export function deriveTimelineEntriesFromVisibleTurnItems(
670
entry: projectedWorkEntry(row),
671
...attemptMetadata,
672
});
673
+
674
+ const mcpApp = item.type === "dynamic_tool" ? mcpAppFromToolItem(item) : undefined;
675
+ if (mcpApp !== undefined) {
676
+ entries.push({
677
+ id: `mcp-app:${item.id}`,
678
+ kind: "mcp-app",
679
+ createdAt,
680
+ runId: item.runId,
681
+ sourceThreadId: row.sourceThreadId,
682
+ itemId: row.sourceItemId,
683
+ revision: turnItemDetailRevision(item),
684
+ mcpApp,
685
+ ...attemptMetadata,
686
+ });
687
+ }
688
}
689
690
const retainedMessageIds = new Set([
@@ -870,6 +869,9 @@ function canRederiveInPlace(
869
item.item.type !== "user_message" &&
870
item.item.type !== "assistant_message" &&
871
item.item.type !== "user_input_request" &&
872
+ // An app call projects two entries; in-place reuse replaces one.
873
+ (previousItem.item.type !== "dynamic_tool" ||
874
+ mcpAppFromToolItem(previousItem.item) === undefined) &&
875
((input.anchoredMessages?.length ?? 0) === 0 ||
876
projectedItemCreatedAt(item) === projectedItemCreatedAt(previousItem))
877
);
docs/user/html-renders.md
+1
-1
@@ -12,7 +12,7 @@ Previews can load public resources such as CDN scripts, but nothing on your loca
12
13
## MCP apps
14
15
-Some MCP servers return an interactive app with their tool results, following the [MCP Apps](https://github.com/modelcontextprotocol/ext-apps) standard. When an agent calls one of those tools, the app appears in the thread in place of the tool call, on web, desktop, and mobile. Codex and Claude support this today, for any MCP server you have configured for them. Claude needs Claude Code 2.1.301 or newer; older versions and other providers show these calls as ordinary tool calls.
15
+Some MCP servers return an interactive app with their tool results, following the [MCP Apps](https://github.com/modelcontextprotocol/ext-apps) standard. When an agent calls one of those tools, the app appears in the thread below the tool call, on web, desktop, and mobile. The tool call keeps its input and result, so you can still read them when an app shows nothing. Codex and Claude support this today, for any MCP server you have configured for them. Claude needs Claude Code 2.1.301 or newer; older versions and other providers show these calls as ordinary tool calls.
16
17
Apps follow your theme. An app can call tools on its own server and post a message to the thread; T3 Code asks first unless the server marks the tool as read-only, and it asks before every message. On mobile, an app also asks before opening a link, and T3 Code asks before saving a file an app offers. An app stays viewable after its agent stops, but using it needs the agent of the thread that created it running, so send a message in that thread first if the app says it is unavailable. An app that navigates away from its own page is stopped.
18
packages/client-runtime/src/work-log/itemDetail.test.ts
+49
@@ -113,3 +113,52 @@ describe("tool image output parsing", () => {
113
},
114
);
115
});
116
+
117
+describe("MCP app tool output", () => {
118
+ it("shows the tool result, not the app wrapper", () => {
119
+ const text = "Notice\nview\tcount\n/home\t42";
120
+ const item = toolItem({
121
+ t3McpApp: {
122
+ attachmentId: "app-html",
123
+ server: "repro",
124
+ tool: "aggregate_rum_events",
125
+ resourceUri: "ui://repro/dataviz",
126
+ },
127
+ result: { content: [{ type: "text", text }] },
128
+ });
129
+ expect(turnItemOutputText(item)).toBe(text);
130
+ });
131
+
132
+ it("reads a result with metadata and marks images it cannot preview", () => {
133
+ const item = toolItem({
134
+ t3McpApp: {
135
+ attachmentId: "app-html",
136
+ server: "repro",
137
+ tool: "chart",
138
+ resourceUri: "ui://repro/chart",
139
+ },
140
+ result: {
141
+ content: [
142
+ { type: "text", text: "chart" },
143
+ { type: "image", mimeType: "image/png", data: "iVBORw0KGgo=" },
144
+ ],
145
+ _meta: { "ui/resourceUri": "ui://repro/chart" },
146
+ },
147
+ });
148
+ expect(turnItemOutputText(item)).toBe("chart\n[image]");
149
+
150
+ const bounded = toolItem({
151
+ t3McpApp: {
152
+ attachmentId: "app-html",
153
+ server: "repro",
154
+ tool: "chart",
155
+ resourceUri: "ui://repro/chart",
156
+ },
157
+ result: [
158
+ { type: "text", text: "chart" },
159
+ { type: "image", mimeType: "image/png" },
160
+ ],
161
+ });
162
+ expect(turnItemOutputText(bounded)).toBe("chart\n[image]");
163
+ });
164
+});
packages/client-runtime/src/work-log/itemDetail.ts
+25
-6
@@ -1,5 +1,10 @@
1
import type { AssetResource, OrchestrationV2TurnItem } from "@t3tools/contracts";
2
-import { toolOutputImageBlocks, toolOutputImages } from "@t3tools/shared/toolOutput";
2
+import { MCP_APP_OUTPUT_KEY } from "@t3tools/shared/mcpApp";
3
+import {
4
+ mcpToolResultOutput,
5
+ toolOutputImageBlocks,
6
+ toolOutputImages,
7
+} from "@t3tools/shared/toolOutput";
8
import * as DateTime from "effect/DateTime";
9
10
const MAX_TEXT_BLOCK_DEPTH = 4;
@@ -90,10 +95,14 @@ function formatJsonValue(value: unknown): string | null {
95
return json;
96
}
97
93
-function formatToolValue(value: unknown, hasImagePreview = false): string | null {
98
+function formatToolValue(
99
+ value: unknown,
100
+ hasImagePreview = false,
101
+ previewedImageBlocks = toolOutputImageBlocks(value),
102
+): string | null {
103
if (value === undefined || value === null) return null;
104
if (hasImagePreview && isRecord(value) && value.type === "image") return null;
96
- const text = textFromBlocks(value, 0, toolOutputImageBlocks(value));
105
+ const text = textFromBlocks(value, 0, previewedImageBlocks);
106
if (text !== null) return text.trim() ? prettyJsonText(text) : null;
107
return formatJsonValue(value);
108
}
@@ -177,14 +186,24 @@ function commandOutputText(output: string): string {
186
.join("\n");
187
}
188
189
+// App calls store the provider result beside the app reference; its images get no preview.
190
+function dynamicToolOutputText(
191
+ item: Extract<OrchestrationV2TurnItem, { readonly type: "dynamic_tool" }>,
192
+): string | null {
193
+ const output = item.output;
194
+ if (!isRecord(output) || !(MCP_APP_OUTPUT_KEY in output) || !("result" in output)) {
195
+ return formatToolValue(output, item.viewedImagePath !== undefined);
196
+ }
197
+ const result = output.result;
198
+ return formatToolValue(isRecord(result) ? mcpToolResultOutput(result) : result, false, []);
199
+}
200
+
201
export function turnItemOutputText(item: OrchestrationV2TurnItem): string | null {
202
switch (item.type) {
203
case "command_execution":
204
return item.output?.trim() ? commandOutputText(item.output) || null : null;
205
case "dynamic_tool":
185
- return item.outputOmitted === true
186
- ? null
187
- : formatToolValue(item.output, item.viewedImagePath !== undefined);
206
+ return item.outputOmitted === true ? null : dynamicToolOutputText(item);
207
case "file_search":
208
return item.results?.length
209
? item.results
packages/shared/src/toolOutput.test.ts
+2
@@ -199,6 +199,8 @@ describe("toolOutputImages", () => {
199
expect(output).toEqual({ content, structuredContent });
200
expect(mcpToolResultOutput({ content: [text], structuredContent })).toBe(structuredContent);
201
expect(mcpToolResultOutput({ content })).toBe(content);
202
+ expect(mcpToolResultOutput({ content: [text], structuredContent: {} })).toEqual([text]);
203
+ expect(mcpToolResultOutput({ content: [text], structuredContent: [] })).toEqual([text]);
204
});
205
206
it("skips types the server must not serve inline", () => {
packages/shared/src/toolOutput.ts
+8
-3
@@ -299,10 +299,15 @@ export function mcpToolResultOutput(result: {
299
readonly content?: unknown;
300
readonly structuredContent?: unknown;
301
}): unknown {
302
- if (result.structuredContent != null && toolOutputImages(result.content).length > 0) {
303
- return { content: result.content, structuredContent: result.structuredContent };
302
+ const structuredContent =
303
+ (Array.isArray(result.structuredContent) || Predicate.isObject(result.structuredContent)) &&
304
+ Object.keys(result.structuredContent).length === 0
305
+ ? undefined
306
+ : result.structuredContent;
307
+ if (structuredContent != null && toolOutputImages(result.content).length > 0) {
308
+ return { content: result.content, structuredContent };
309
}
305
- return result.structuredContent ?? result.content;
310
+ return structuredContent ?? result.content;
311
}
312
313
export function omitToolOutputImageData(value: unknown): unknown {