Skip to main content
Glama

browser_handle_dialog

Manage browser dialogs by accepting or declining them and providing prompt text when needed, using Playwright MCP server for automated 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 asynchronous handler function that implements the core logic of the 'browser_handle_dialog' tool. It locates the current dialog modal state, accepts or dismisses the dialog based on the 'accept' parameter, clears the modal state, and returns a response with internal code comment and no network wait.
    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, }; },
  • The schema definition for the 'browser_handle_dialog' tool, specifying the name, title, description, Zod input schema (accept boolean and optional promptText), 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', },
  • src/tools.ts:39-39 (registration)
    Registration of the 'browser_handle_dialog' tool factory (with captureSnapshot=true) into the snapshotTools array.
    ...dialogs(true),
  • src/tools.ts:57-57 (registration)
    Registration of the 'browser_handle_dialog' tool factory (with captureSnapshot=false) into the visionTools array.
    ...dialogs(false),
  • Export of the tool factory function for 'browser_handle_dialog', which returns the defined tool based on captureSnapshot parameter, used in registrations above.
    export default (captureSnapshot: boolean) => [ handleDialog(captureSnapshot), ];

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