Skip to main content
Glama

handle_dialog

Accept or dismiss browser dialogs during Chrome automation to manage pop-ups and alerts that interrupt testing workflows.

Instructions

If a browser dialog was opened, use this command to handle it

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesWhether to dismiss or accept the dialog
promptTextNoOptional prompt text to enter into the dialog.

Implementation Reference

  • The handler function for the 'handle_dialog' tool. It retrieves the current dialog from context, then accepts or dismisses it based on the action parameter, optionally entering prompt text for accept. Clears the dialog and includes pages in response.
    handler: async (request, response, context) => {
      const dialog = context.getDialog();
      if (!dialog) {
        throw new Error('No open dialog found');
      }
    
      switch (request.params.action) {
        case 'accept': {
          try {
            await dialog.accept(request.params.promptText);
          } catch (err) {
            // Likely already handled by the user outside of MCP.
            logger(err);
          }
          response.appendResponseLine('Successfully accepted the dialog');
          break;
        }
        case 'dismiss': {
          try {
            await dialog.dismiss();
          } catch (err) {
            // Likely already handled.
            logger(err);
          }
          response.appendResponseLine('Successfully dismissed the dialog');
          break;
        }
      }
    
      context.clearDialog();
      response.setIncludePages(true);
    },
  • Input schema for the 'handle_dialog' tool using Zod. Defines 'action' as enum ['accept', 'dismiss'] and optional 'promptText' string.
    schema: {
      action: z
        .enum(['accept', 'dismiss'])
        .describe('Whether to dismiss or accept the dialog'),
      promptText: z
        .string()
        .optional()
        .describe('Optional prompt text to enter into the dialog.'),
    },
  • Registration of the 'handle_dialog' tool using defineTool, including name, description, annotations, schema, and handler.
    export const handleDialog = defineTool({
      name: 'handle_dialog',
      description: `If a browser dialog was opened, use this command to handle it`,
      annotations: {
        category: ToolCategories.INPUT_AUTOMATION,
        readOnlyHint: false,
      },
      schema: {
        action: z
          .enum(['accept', 'dismiss'])
          .describe('Whether to dismiss or accept the dialog'),
        promptText: z
          .string()
          .optional()
          .describe('Optional prompt text to enter into the dialog.'),
      },
      handler: async (request, response, context) => {
        const dialog = context.getDialog();
        if (!dialog) {
          throw new Error('No open dialog found');
        }
    
        switch (request.params.action) {
          case 'accept': {
            try {
              await dialog.accept(request.params.promptText);
            } catch (err) {
              // Likely already handled by the user outside of MCP.
              logger(err);
            }
            response.appendResponseLine('Successfully accepted the dialog');
            break;
          }
          case 'dismiss': {
            try {
              await dialog.dismiss();
            } catch (err) {
              // Likely already handled.
              logger(err);
            }
            response.appendResponseLine('Successfully dismissed the dialog');
            break;
          }
        }
    
        context.clearDialog();
        response.setIncludePages(true);
      },
    });
Behavior3/5

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

The annotations only provide readOnlyHint=false, indicating this is a mutation tool. The description adds value by specifying the tool handles browser dialogs, which implies it interacts with UI elements and may require specific conditions (dialog must be open). However, it doesn't disclose additional behavioral traits like whether it blocks execution, error conditions, or side effects beyond the basic action. With annotations covering the mutation aspect, this earns a baseline score for adding some context.

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 a single, efficient sentence that front-loads the essential information: the condition for use and the core action. There is no wasted verbiage or redundancy, making it highly concise and well-structured for quick comprehension.

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

Completeness3/5

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

Given the tool's moderate complexity (handling UI dialogs with mutation), lack of output schema, and minimal annotations, the description is somewhat incomplete. It covers the basic purpose and condition but omits details like return values, error handling, or prerequisites (e.g., must have an open dialog). For a mutation tool without output schema, more context would be beneficial, but it meets a minimum viable level.

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?

The input schema has 100% description coverage, with clear documentation for both parameters (action with enum values, promptText as optional). The description doesn't add any semantic details beyond what the schema provides—it doesn't explain parameter interactions or usage examples. Given the high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'handle' (verb) 'a browser dialog' (resource). It specifies the condition for usage ('If a browser dialog was opened'), making the purpose specific and actionable. However, it doesn't explicitly distinguish this tool from potential sibling alternatives like 'click' or 'close_page' that might also interact with dialogs, preventing a perfect score.

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

Usage Guidelines3/5

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

The description provides some usage context by stating 'If a browser dialog was opened', which implies when to use it. However, it doesn't specify when NOT to use it (e.g., for non-dialog elements) or name explicit alternatives among the sibling tools (e.g., 'click' for buttons). This leaves room for ambiguity, making it implied rather than explicit guidance.

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/SHAY5555-gif/chrome-devtools-mcp'

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