Skip to main content
Glama

browser_handle_dialog

Destructive

Accept or dismiss browser dialogs during automated web testing. Manage pop-ups, alerts, and prompts to maintain test flow.

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 implements the core logic for handling browser dialogs. It finds the current dialog state, clears it, and either accepts 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();
      });
    },
  • The schema definition for the browser_handle_dialog tool, including name, title, description, input schema using Zod, and 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',
    },
  • Exports the defined tool for registration in the MCP tools system.
    export default [
      handleDialog,
    ];
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate destructiveHint=true (implying state changes) and readOnlyHint=false (confirming it's not read-only), which the description doesn't contradict. However, the description adds minimal behavioral context beyond annotations—it doesn't specify what 'handle' entails (e.g., accepting/dismissing dialogs, potential side effects like page navigation). With annotations covering safety aspects, the description provides some value but lacks detail on operational behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at two words, with no wasted language. It's front-loaded but under-specified—while brevity is achieved, it sacrifices clarity. In this case, conciseness is maximized, though it doesn't serve the tool's informational needs effectively.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with destructive annotations, two parameters, and no output schema, the description is incomplete. It doesn't explain what dialogs are, return values, error conditions, or how it interacts with browser state. Given the complexity implied by parameters and annotations, more context is needed to guide an agent adequately.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear parameter documentation: 'accept' (boolean for dialog acceptance) and 'promptText' (string for prompt dialogs). The description adds no parameter semantics beyond the schema, failing to explain relationships (e.g., promptText is only for prompt-type dialogs) or usage examples. Given high schema coverage, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Handle a dialog' is a tautology that restates the tool name without adding specificity. It doesn't clarify what type of dialog is being handled (e.g., browser alert, confirm, prompt) or what 'handle' means in this context. While sibling tools like browser_click or browser_type have clear actions, this description lacks the verb+resource clarity needed for distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., that a dialog must be present), exclusions, or related tools like browser_console_messages for monitoring. Without any usage context, an agent cannot determine appropriate invocation scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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