Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mcp): allow text-only preview snapshots #10232

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/10232/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 4 changed files with 15 additions and 3 deletions (loading 2).

x
0 of 4 viewed, 4 left
5 additions and 1 deletionapps/server/src/mcp/toolkits/preview/handlers.tsModified
View file
@@ -77,7 +77,11 @@
invokeTargeted<PreviewAutomationResizeResult>("resize", input, input.timeoutMs),
preview_set_appearance: (input) =>
invokeTargeted<PreviewAutomationSetColorSchemeResult>("setColorScheme", input),
- preview_snapshot: (input) => invokeTargeted<PreviewAutomationSnapshot>("snapshot", input ?? {}),
+ preview_snapshot: (input) => {
+ // Output selection is MCP-only; the browser still produces a complete snapshot.
+ const { includeImage: _includeImage, ...operationInput } = input ?? {};
+ return invokeTargeted<PreviewAutomationSnapshot>("snapshot", operationInput);
+ },
preview_click: (input) =>
invokeTargeted<void>("click", input, input.timeoutMs).pipe(Effect.as({})),
preview_type: (input) => invokeTargeted<void>("type", input, input.timeoutMs).pipe(Effect.as({})),
10 additions and 2 deletionsapps/server/src/mcp/toolkits/preview/tools.tsModified
View file
@@ -111,8 +111,16 @@
export const PreviewSnapshotTool = readonlyBrowserTool(
Tool.make("preview_snapshot", {
description:
- "Inspect a page before interacting. Pass tabId to inspect a specific tab; omit it to use this agent session's current tab. Returns page state, semantic elements, diagnostics, action history, and a PNG screenshot.",
- parameters: PreviewAutomationTabTargetInput,
+ "Inspect a page before interacting. Pass tabId to inspect a specific tab; omit it to use this agent session's current tab. Returns page state, semantic elements, diagnostics, action history, and a PNG screenshot. Set includeImage=false for text-only output with the same page metadata.",
+ parameters: Schema.Struct({
+ ...PreviewAutomationTabTargetInput.fields,
+ includeImage: Schema.optional(
+ Schema.Boolean.annotate({
+ description:
+ "Include the PNG image in the tool response. Defaults to true. Set false for text-only output.",