dismiss_dialog
Close active browser dialogs like alerts, confirms, or prompts during automated testing and browser control operations.
Instructions
Dismiss the active browser dialog (alert/confirm/prompt). Returns an error if no dialog is open.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/utilities.ts:95-116 (handler)The primary handler function for the 'dismiss_dialog' MCP tool. It lazily initializes the Firefox instance, calls firefox.dismissDialog(), handles specific 'no dialog' errors, and returns success/error responses.export async function handleDismissDialog(_args: unknown): Promise<McpToolResponse> { try { const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); try { await firefox.dismissDialog(); return successResponse('✅ Dismissed'); } catch (error) { const errorMsg = (error as Error).message; // Concise error for no active dialog if (errorMsg.includes('no such alert') || errorMsg.includes('No dialog')) { throw new Error('No active dialog'); } throw error; } } catch (error) { return errorResponse(error as Error); } }
- src/tools/utilities.ts:23-30 (schema)The tool schema definition for 'dismiss_dialog', including name, description, and empty input schema (no parameters required).export const dismissDialogTool = { name: 'dismiss_dialog', description: 'Dismiss browser dialog.', inputSchema: { type: 'object', properties: {}, }, };
- src/index.ts:142-147 (registration)Registration of the dismiss_dialog handler in the central toolHandlers Map used by the MCP server to dispatch tool calls.// Utilities ['accept_dialog', tools.handleAcceptDialog], ['dismiss_dialog', tools.handleDismissDialog], ['navigate_history', tools.handleNavigateHistory], ['set_viewport_size', tools.handleSetViewportSize], ]);
- src/index.ts:187-191 (registration)Inclusion of the dismissDialogTool schema in the allTools array returned by listTools.tools.acceptDialogTool, tools.dismissDialogTool, tools.navigateHistoryTool, tools.setViewportSizeTool, ];
- src/firefox/pages.ts:65-74 (helper)Core helper method in PageManagement class that performs the actual WebDriver alert dismissal.async dismissDialog(): Promise<void> { try { const alert = await this.driver.switchTo().alert(); await alert.dismiss(); } catch (error) { throw new Error( `Failed to dismiss dialog: ${error instanceof Error ? error.message : String(error)}` ); } }