Skip to main content
Glama

browser_handle_dialog

Accept or dismiss browser dialogs during web automation, including handling prompt dialogs by providing text input when required.

Instructions

Handle a dialog

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
acceptYesWhether to accept the dialog.
promptTextNoThe text of the prompt in case of a prompt dialog.

Implementation Reference

  • The handler function that implements the core logic of the 'browser_handle_dialog' tool. It locates the current dialog, accepts or dismisses it based on the 'accept' parameter and optional 'promptText', clears the modal state, and returns an execution result.
    handle: async (context, params) => { const dialogState = context.modalStates().find(state => state.type === 'dialog'); if (!dialogState) throw new Error('No dialog visible'); if (params.accept) await dialogState.dialog.accept(params.promptText); else await dialogState.dialog.dismiss(); context.clearModalState(dialogState); const code = [ `// <internal code to handle "${dialogState.dialog.type()}" dialog>`, ]; return { code, captureSnapshot, waitForNetwork: false, }; },
  • Zod schema definition for the 'browser_handle_dialog' tool, specifying the input parameters: 'accept' (boolean) and optional 'promptText' (string).
    schema: { name: 'browser_handle_dialog', title: 'Handle a dialog', description: 'Handle a dialog', inputSchema: z.object({ accept: z.boolean().describe('Whether to accept the dialog.'), promptText: z.string().optional().describe('The text of the prompt in case of a prompt dialog.'), }), type: 'destructive', },
  • Tool factory export that produces the 'browser_handle_dialog' tool, parameterized by captureSnapshot flag.
    export default (captureSnapshot: boolean) => [ handleDialog(captureSnapshot), ];
  • src/tools.ts:36-52 (registration)
    Main registration of snapshot tools, including the browser_handle_dialog via spread of dialogs(true).
    export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...video, ...wait(true), ];
  • src/tools.ts:54-69 (registration)
    Main registration of vision tools, including the browser_handle_dialog via spread of dialogs(false).
    export const visionTools: Tool<any>[] = [ ...common(false), ...console, ...dialogs(false), ...files(false), ...install, ...keyboard(false), ...navigate(false), ...network, ...pdf, ...tabs(false), ...testing, ...video, ...vision, ...wait(false), ];

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/lewisvoncken/playwright-mcp'

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