Skip to main content
Glama

browser_handle_dialog

Automate dialog handling during web accessibility scans by accepting or dismissing prompts, ensuring uninterrupted WCAG compliance testing with Playwright and Axe-core.

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

  • Handler function that locates the current dialog modal state, clears it, and either accepts (with optional prompt text) or dismisses the dialog based on the input parameters.
    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(); }); },
  • Schema definition for the tool, including name, title, description, Zod input schema for 'accept' boolean and optional 'promptText' string, and destructive type.
    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', },
  • Local registration of the tool using defineTabTool, which encapsulates schema, handler, capability, and modal state clearing behavior.
    const handleDialog = defineTabTool({ capability: 'core', 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', }, 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(); }); }, clearsModalState: 'dialog', });
  • src/tools.ts:38-56 (registration)
    Global registration where the dialogs tools (including browser_handle_dialog) are spread into the allTools array for export and use in the MCP protocol.
    export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...form, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ...verify, ];

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/JustasMonkev/mcp-accessibility-scanner'

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