Skip to main content
Glama
Angeluis001

Playwright MCP

by Angeluis001

browser_handle_dialog

Destructive

Accept or dismiss browser dialogs during web automation to manage pop-ups, alerts, and prompts in Playwright-based testing.

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 executes the tool logic: finds the dialog modal state, accepts or dismisses it based on parameters, clears the state, and returns internal 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,
      };
    },
  • Input schema and metadata definition 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',
    },
  • src/tools.ts:35-50 (registration)
    Registration of browser_handle_dialog by spreading dialogs(true) into the snapshotTools array.
    export const snapshotTools: Tool<any>[] = [
      ...common(true),
      ...console,
      ...dialogs(true),
      ...files(true),
      ...install,
      ...keyboard(true),
      ...navigate(true),
      ...network,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs(true),
      ...testing,
      ...wait(true),
    ];
  • src/tools.ts:52-66 (registration)
    Registration of browser_handle_dialog by spreading dialogs(false) into the visionTools array.
    export const visionTools: Tool<any>[] = [
      ...common(false),
      ...console,
      ...dialogs(false),
      ...files(false),
      ...install,
      ...keyboard(false),
      ...navigate(false),
      ...network,
      ...pdf,
      ...tabs(false),
      ...testing,
      ...vision,
      ...wait(false),
    ];
Behavior3/5

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

Annotations indicate readOnlyHint=false, openWorldHint=true, and destructiveHint=true, which already inform the agent that this is a mutable, potentially destructive operation with open-ended outcomes. The description adds minimal value by implying interaction with dialogs but doesn't elaborate on behavioral traits like side effects, error conditions, or specific dialog types. No contradiction with annotations exists, but the description fails to compensate for the lack of output schema or detailed context.

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

Conciseness4/5

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

The description is extremely concise with just two words, which is efficient and front-loaded. However, it's overly terse to the point of under-specification, missing critical details that would help an agent. While not verbose, it fails to earn a perfect score due to lacking necessary explanatory content.

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?

Given the tool's complexity (handling browser dialogs with destructive potential), lack of output schema, and minimal annotations beyond basic hints, the description is incomplete. It doesn't cover return values, error handling, or the scope of 'dialogs' (e.g., alerts, confirms, prompts), leaving significant gaps for agent understanding in a context-rich browser automation environment.

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 documentation for 'accept' (boolean for accepting the dialog) and 'promptText' (string for prompt dialog text). The description adds no parameter semantics beyond what the schema provides, such as explaining when 'promptText' is required or how 'accept' interacts with different dialog types. Baseline 3 is appropriate given the schema's comprehensive coverage.

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 (e.g., JavaScript alert, confirmation, prompt) or what 'handling' entails beyond the basic verb. While it distinguishes from siblings like 'browser_click' or 'browser_navigate' by focusing on dialogs, it lacks the detailed verb+resource+scope needed for higher scoring.

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 for different dialog types. Given the sibling tools include various browser interactions, this lack of context leaves the agent guessing about appropriate usage 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/Angeluis001/playwright-mcp'

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