screenshot
Capture the active tab and obtain base64 PNG, URL, title, and detection of 2FA, captcha, or payment prompts. Use after each interaction to verify page state and identify handoff triggers.
Instructions
Capture the active tab. Returns base64 PNG, URL, title, and any detected handoff triggers (2FA, captcha, payment prompts). Call this after every action to verify state.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fullPage | No | Full scrollable page (default false) |
Implementation Reference
- src/index.ts:226-238 (handler)The core screenshot tool handler — captures a Playwright page screenshot as PNG, returns base64, URL, title, and detects handoff triggers (2FA, captcha, etc.).
async function screenshot(args: { fullPage?: boolean }) { const p = requirePage(); const buf = await p.screenshot({ fullPage: args.fullPage ?? false, type: 'png' }); // Sniff for handoff triggers in visible text. Cheap and very useful. const text = await p.evaluate(() => document.body?.innerText?.slice(0, 20000) ?? ''); const triggers = detectHandoffTriggers(text); return { base64: buf.toString('base64'), url: p.url(), title: await p.title().catch(() => ''), handoffTriggers: triggers, }; } - src/index.ts:369-378 (schema)Tool registration with input schema defining the 'screenshot' tool's input (optional boolean `fullPage`) and description.
{ name: 'screenshot', description: 'Capture the active tab. Returns base64 PNG, URL, title, and any detected handoff ' + 'triggers (2FA, captcha, payment prompts). Call this after every action to verify state.', inputSchema: { type: 'object', properties: { fullPage: { type: 'boolean', description: 'Full scrollable page (default false)' } }, }, }, - src/index.ts:464-464 (registration)Dispatch in CallToolRequestSchema handler routing the 'screenshot' tool name to the screenshot function.
case 'screenshot': result = await screenshot(args as { fullPage?: boolean }); break; - src/index.ts:475-485 (registration)Special response formatting for screenshot — extracts the base64 image data and returns it as an image content block so Claude can view it, plus metadata as text.
// Screenshot returns image content as a separate block so Claude can actually look at it. if (name === 'screenshot' && result && typeof result === 'object' && 'base64' in result) { const r = result as { base64: string; url: string; title: string; handoffTriggers: string[] }; const meta = { url: r.url, title: r.title, handoffTriggers: r.handoffTriggers }; return { content: [ { type: 'image', data: r.base64, mimeType: 'image/png' }, { type: 'text', text: JSON.stringify(meta, null, 2) }, ], }; } - src/index.ts:141-147 (helper)Helper used by screenshot handler — scans text for handoff triggers like 2FA, captcha, payment prompts.
function detectHandoffTriggers(text: string): string[] { const found = new Set<string>(); for (const [rx, label] of HANDOFF_PATTERNS) { if (rx.test(text)) found.add(label); } return [...found]; }