pilot_frames
Lists all iframes on a webpage to enable context switching for browser automation tasks.
Instructions
List all frames (iframes) on the page. Use pilot_frame_select to switch context into an iframe for snapshot/interaction.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/iframe.ts:11-31 (handler)The handler function for the 'pilot_frames' tool.
async () => { await bm.ensureBrowser(); try { const frames = await bm.listFrames(); if (frames.length <= 1) { return { content: [{ type: 'text' as const, text: '(no iframes — only the main frame)' }] }; } const activeFrame = bm.getActiveFrame(); const page = bm.getPage(); const allFrames = page.frames(); const text = frames.map(f => { const isCurrent = allFrames[f.index] === activeFrame; const marker = isCurrent ? '→ ' : ' '; const label = f.isMain ? '[main]' : `[iframe${f.name ? ` name="${f.name}"` : ''}]`; return `${marker}[${f.index}] ${label} ${f.url}`; }).join('\n'); return { content: [{ type: 'text' as const, text }] }; } catch (err) { return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } - src/tools/iframe.ts:7-9 (registration)Registration of the 'pilot_frames' tool.
server.tool( 'pilot_frames', 'List all frames (iframes) on the page. Use pilot_frame_select to switch context into an iframe for snapshot/interaction.',