screenshot
Capture a base64 PNG screenshot of a browser tab. Use for visual verification of CSS, layout, or proof. Prefer snapshot for most tasks due to higher token efficiency.
Instructions
Take visual screenshot in base64 PNG. Use ONLY for visual verification (CSS, layout, proof). Prefer snapshot for most tasks — much more token-efficient.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tabId | Yes | Tab ID from create_tab |
Implementation Reference
- src/tools/observation.ts:245-261 (handler)Tool handler for 'screenshot' — calls client.screenshot() and returns base64 PNG image result.
server.tool( "screenshot", "Take visual screenshot in base64 PNG. Use ONLY for visual verification (CSS, layout, proof). Prefer snapshot for most tasks — much more token-efficient.", { tabId: z.string().min(1).describe("Tab ID from create_tab") }, async (input: unknown) => { try { const parsed = z.object({ tabId: z.string().min(1).describe("Tab ID from create_tab") }).parse(input); const tracked = getTrackedTab(parsed.tabId); const screenshotBuffer = await deps.client.screenshot(parsed.tabId, tracked.userId); incrementToolCall(parsed.tabId); return imageResult(screenshotBuffer.toString("base64")); } catch (error) { return toErrorResult(error); } } - src/tools/observation.ts:248-249 (schema)Input schema for screenshot tool — requires tabId string.
{ tabId: z.string().min(1).describe("Tab ID from create_tab") - src/tools/observation.ts:245-262 (registration)Registration of the 'screenshot' tool via server.tool()
server.tool( "screenshot", "Take visual screenshot in base64 PNG. Use ONLY for visual verification (CSS, layout, proof). Prefer snapshot for most tasks — much more token-efficient.", { tabId: z.string().min(1).describe("Tab ID from create_tab") }, async (input: unknown) => { try { const parsed = z.object({ tabId: z.string().min(1).describe("Tab ID from create_tab") }).parse(input); const tracked = getTrackedTab(parsed.tabId); const screenshotBuffer = await deps.client.screenshot(parsed.tabId, tracked.userId); incrementToolCall(parsed.tabId); return imageResult(screenshotBuffer.toString("base64")); } catch (error) { return toErrorResult(error); } } ); - src/client.ts:652-660 (helper)Client method that fetches screenshot binary from the API.
async screenshot(tabId: string, userId: string): Promise<Buffer> { const binary = await this.requestBinary( `/tabs/${encodeURIComponent(tabId)}/screenshot?userId=${encodeURIComponent(userId)}`, { method: "GET" } ); return Buffer.from(binary); } - src/errors.ts:51-55 (helper)Helper function to wrap base64 PNG into a ToolResult with image content type.
export function imageResult(base64Png: string): ToolResult { return { content: [{ type: "image", data: base64Png, mimeType: "image/png" }] }; }