Skip to main content
Glama

browser_handle_dialog

Automate dialog handling in web browsers by accepting or dismissing alerts, prompts, or confirmations using structured input for precise control during web interactions.

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 finds the current dialog modal state, clears it, and either accepts or dismisses the dialog based on the 'accept' parameter, with optional prompt text.
    handle: async (tab, params, response) => { response.setIncludeSnapshot(); const dialogState = tab.modalStates().find(state => state.type === 'dialog'); if (!dialogState) throw new Error('No dialog visible'); tab.clearModalState(dialogState); await tab.waitForCompletion(async () => { if (params.accept) await dialogState.dialog.accept(params.promptText); else await dialogState.dialog.dismiss(); }); },
  • Defines the tool schema including name 'browser_handle_dialog', input parameters 'accept' (boolean) and optional 'promptText' (string), marked as destructive.
    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', },
  • src/tools.ts:36-52 (registration)
    Registers the tool by including the exported dialogs array (containing browser_handle_dialog) in the main allTools export.
    export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];
  • src/tools.ts:39-39 (registration)
    Spreads the imported dialogs tools into the allTools array, registering browser_handle_dialog.
    ...dialogs,
  • src/tools.ts:19-19 (registration)
    Imports the dialogs.ts module which exports the browser_handle_dialog tool.
    import dialogs from './tools/dialogs.js';

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/nzjami/mcpPlaywright'

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