Skip to main content
Glama

accept_dialog

Accept browser dialogs like alerts, confirms, and prompts during automated testing. Enter text for prompt dialogs and handle dialog interactions in Firefox browser automation.

Instructions

Accept the active browser dialog (alert/confirm/prompt). For prompts, you may provide promptText. Returns an error if no dialog is open.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptTextNoText to enter in a prompt dialog (optional, only for prompt dialogs)

Implementation Reference

  • The handler function that executes the 'accept_dialog' tool logic. It extracts optional promptText from args, gets the Firefox instance, calls firefox.acceptDialog(promptText), and returns success or error response.
    export async function handleAcceptDialog(args: unknown): Promise<McpToolResponse> { try { const { promptText } = (args as { promptText?: string }) || {}; const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); try { await firefox.acceptDialog(promptText); return successResponse(promptText ? `✅ Accepted: "${promptText}"` : '✅ Accepted'); } 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); } }
  • The input schema and metadata definition for the 'accept_dialog' tool.
    export const acceptDialogTool = { name: 'accept_dialog', description: 'Accept browser dialog. Provide promptText for prompts.', inputSchema: { type: 'object', properties: { promptText: { type: 'string', description: 'Text for prompt dialogs', }, }, }, };
  • src/index.ts:103-147 (registration)
    Registration of the handler for 'accept_dialog' in the toolHandlers Map used by the MCP server.
    const toolHandlers = new Map< string, (input: unknown) => Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> >([ // Pages ['list_pages', tools.handleListPages], ['new_page', tools.handleNewPage], ['navigate_page', tools.handleNavigatePage], ['select_page', tools.handleSelectPage], ['close_page', tools.handleClosePage], // Script evaluation - DISABLED (see docs/future-features.md) // ['evaluate_script', tools.handleEvaluateScript], // Console ['list_console_messages', tools.handleListConsoleMessages], ['clear_console_messages', tools.handleClearConsoleMessages], // Network ['list_network_requests', tools.handleListNetworkRequests], ['get_network_request', tools.handleGetNetworkRequest], // Snapshot ['take_snapshot', tools.handleTakeSnapshot], ['resolve_uid_to_selector', tools.handleResolveUidToSelector], ['clear_snapshot', tools.handleClearSnapshot], // Input ['click_by_uid', tools.handleClickByUid], ['hover_by_uid', tools.handleHoverByUid], ['fill_by_uid', tools.handleFillByUid], ['drag_by_uid_to_uid', tools.handleDragByUidToUid], ['fill_form_by_uid', tools.handleFillFormByUid], ['upload_file_by_uid', tools.handleUploadFileByUid], // Screenshot ['screenshot_page', tools.handleScreenshotPage], ['screenshot_by_uid', tools.handleScreenshotByUid], // Utilities ['accept_dialog', tools.handleAcceptDialog], ['dismiss_dialog', tools.handleDismissDialog], ['navigate_history', tools.handleNavigateHistory], ['set_viewport_size', tools.handleSetViewportSize], ]);
  • src/index.ts:150-191 (registration)
    Registration of the 'accept_dialog' tool definition in the allTools array returned by listTools.
    const allTools = [ // Pages tools.listPagesTool, tools.newPageTool, tools.navigatePageTool, tools.selectPageTool, tools.closePageTool, // Script evaluation - DISABLED (see docs/future-features.md) // tools.evaluateScriptTool, // Console tools.listConsoleMessagesTool, tools.clearConsoleMessagesTool, // Network tools.listNetworkRequestsTool, tools.getNetworkRequestTool, // Snapshot tools.takeSnapshotTool, tools.resolveUidToSelectorTool, tools.clearSnapshotTool, // Input tools.clickByUidTool, tools.hoverByUidTool, tools.fillByUidTool, tools.dragByUidToUidTool, tools.fillFormByUidTool, tools.uploadFileByUidTool, // Screenshot tools.screenshotPageTool, tools.screenshotByUidTool, // Utilities tools.acceptDialogTool, tools.dismissDialogTool, tools.navigateHistoryTool, tools.setViewportSizeTool, ];
  • Low-level helper method in PageManagement class that handles accepting browser dialogs using Selenium WebDriver BiDi.
    async acceptDialog(promptText?: string): Promise<void> { try { const alert = await this.driver.switchTo().alert(); if (promptText !== undefined) { await alert.sendKeys(promptText); } await alert.accept(); } catch (error) { throw new Error( `Failed to accept dialog: ${error instanceof Error ? error.message : String(error)}` ); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/freema/firefox-devtools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server