pilot_dialog
Retrieve captured browser dialog messages (alert, confirm, prompt) from a buffer. Use to inspect dialog text or verify dialog appearance after an action.
Instructions
Retrieve captured browser dialog messages (alert, confirm, prompt) from a circular buffer. Use when the user wants to see what native dialogs appeared on the page, check prompt text, or verify that a dialog was triggered after an action. Note: configure auto-handling with pilot_handle_dialog to prevent dialogs from blocking page interaction.
Parameters:
clear: Set to true to clear the buffer after reading
Returns: Timestamped list of dialogs showing type (alert/confirm/prompt), message text, and the action taken (accepted/dismissed) with any response text. Or "(no dialogs captured)" if empty.
Errors: None — returns empty message if no dialogs were captured.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clear | No | Clear the buffer after reading |
Implementation Reference
- src/tools/inspection.ts:89-110 (handler)The 'pilot_dialog' tool handler: registers the tool with a description and typed 'clear' parameter, reads the dialogBuffer (a CircularBuffer of DialogEntry objects), formats timestamped dialog entries (type, message, action, response), and returns them as text. Supports clearing the buffer.
server.tool( 'pilot_dialog', `Retrieve captured browser dialog messages (alert, confirm, prompt) from a circular buffer. Use when the user wants to see what native dialogs appeared on the page, check prompt text, or verify that a dialog was triggered after an action. Note: configure auto-handling with pilot_handle_dialog to prevent dialogs from blocking page interaction. Parameters: - clear: Set to true to clear the buffer after reading Returns: Timestamped list of dialogs showing type (alert/confirm/prompt), message text, and the action taken (accepted/dismissed) with any response text. Or "(no dialogs captured)" if empty. Errors: None — returns empty message if no dialogs were captured.`, { clear: z.boolean().optional().describe('Clear the buffer after reading') }, async ({ clear }) => { await bm.ensureBrowser(); if (clear) { dialogBuffer.clear(); return { content: [{ type: 'text' as const, text: 'Dialog buffer cleared.' }] }; } if (dialogBuffer.length === 0) return { content: [{ type: 'text' as const, text: '(no dialogs captured)' }] }; const text = dialogBuffer.toArray().map(e => `[${new Date(e.timestamp).toISOString()}] [${e.type}] "${e.message}" → ${e.action}${e.response ? ` "${e.response}"` : ''}` ).join('\n'); return { content: [{ type: 'text' as const, text }] }; } ); - src/buffers.ts:88-95 (schema)The DialogEntry interface defining the schema for dialog buffer entries: timestamp, type (alert/confirm/prompt), message, optional defaultValue, action (accepted/dismissed), and optional response text.
export interface DialogEntry { timestamp: number; type: string; message: string; defaultValue?: string; action: string; response?: string; } - src/buffers.ts:103-115 (helper)The dialogBuffer singleton and addDialogEntry helper: a CircularBuffer<DialogEntry> with 50,000 entry capacity, used by the tool to store and retrieve captured browser dialogs.
export const dialogBuffer = new CircularBuffer<DialogEntry>(HIGH_WATER_MARK); export function addConsoleEntry(entry: LogEntry) { consoleBuffer.push(entry); } export function addNetworkEntry(entry: NetworkEntry) { networkBuffer.push(entry); } export function addDialogEntry(entry: DialogEntry) { dialogBuffer.push(entry); } - src/tools/register.ts:73-87 (registration)Registration of all tools via registerAllTools, which calls registerInspectionTools (the function that registers 'pilot_dialog'). The tool is not in CORE or STANDARD sets, so it's only available in 'full' profile.
export function registerAllTools(server: McpServer, bm: BrowserManager, profile: ToolProfile = 'full'): void { const allowed = PROFILE_TOOLS[profile]; const effectiveServer = allowed ? createFilteredServer(server, allowed) : server; registerNavigationTools(effectiveServer, bm); registerSnapshotTools(effectiveServer, bm); registerInteractionTools(effectiveServer, bm); registerPageTools(effectiveServer, bm); registerInspectionTools(effectiveServer, bm); registerVisualTools(effectiveServer, bm); registerTabTools(effectiveServer, bm); registerSettingsTools(effectiveServer, bm); registerIframeTools(effectiveServer, bm); registerAutomationTools(effectiveServer, bm); }