Skip to main content
Glama

browser_handle_dialog

Manage browser dialogs by accepting or dismissing them and optionally inputting text for prompt dialogs using Playwright MCP's automation capabilities.

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

  • Executes the tool logic: finds the dialog state, accepts or dismisses based on 'accept' param and optional promptText, clears modal state, returns code snippet.
    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, }; },
  • Defines the input schema and metadata for the 'browser_handle_dialog' tool using Zod.
    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', },
  • Exports a factory function that returns the tool for inclusion in tool registries.
    export default (captureSnapshot: boolean) => [ handleDialog(captureSnapshot), ];
  • src/tools.ts:38-38 (registration)
    Registers the tool (via dialogs(true)) in the snapshotTools array.
    ...dialogs(true),
  • src/tools.ts:55-55 (registration)
    Registers the tool (via dialogs(false)) in the visionTools array.
    ...dialogs(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/Angeluis001/playwright-mcp'

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