Skip to main content
Glama
JustasMonkev

MCP Accessibility Scanner

browser_handle_dialog

Destructive

Automate dialog handling during web accessibility scans by accepting or dismissing prompts, ensuring uninterrupted WCAG compliance testing with Playwright and Axe-core.

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

  • Handler function that locates the current dialog modal state, clears it, and either accepts (with optional prompt text) 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();
      });
    },
  • Schema definition for the tool, including name, title, description, Zod input schema for 'accept' boolean and optional 'promptText' string, 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',
    },
  • Local registration of the tool using defineTabTool, which encapsulates schema, handler, capability, and modal state clearing behavior.
    const handleDialog = defineTabTool({
      capability: 'core',
    
      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',
      },
    
      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();
        });
      },
    
      clearsModalState: 'dialog',
    });
  • src/tools.ts:38-56 (registration)
    Global registration where the dialogs tools (including browser_handle_dialog) are spread into the allTools array for export and use in the MCP protocol.
    export const allTools: Tool<any>[] = [
      ...common,
      ...console,
      ...dialogs,
      ...evaluate,
      ...files,
      ...form,
      ...install,
      ...keyboard,
      ...navigate,
      ...network,
      ...mouse,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs,
      ...wait,
      ...verify,
    ];
Behavior3/5

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

Annotations indicate destructiveHint=true and readOnlyHint=false, suggesting a write operation with potential side effects. The description doesn't contradict this but adds minimal context beyond annotations—it implies interaction with dialogs but doesn't specify behaviors like what happens when accepting/canceling or if it affects browser state. With annotations covering safety, the description adds some value but lacks detail on consequences.

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 'Handle a dialog' is extremely concise with no wasted words. It's front-loaded and to the point, though this brevity contributes to gaps in other dimensions. Every word serves a purpose, making it structurally efficient.

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 dialogs with potential destructive effects), lack of output schema, and minimal description, it's incomplete. The description doesn't explain return values, error conditions, or interaction patterns, leaving significant gaps for an agent to understand how to use it effectively in context with other browser tools.

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 descriptions in the schema (e.g., 'accept' for dialog acceptance, 'promptText' for prompt input). The description adds no additional meaning beyond the schema, such as explaining when promptText is needed or how parameters interact. Baseline 3 is appropriate since the schema fully documents parameters.

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 tautological with the tool name 'browser_handle_dialog' and doesn't specify what type of dialog or what handling entails. It mentions a dialog but doesn't distinguish it from other browser tools like browser_click or browser_select_option that might interact with UI elements. The purpose is vague and doesn't provide specific action details.

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?

There are no guidelines on when to use this tool versus alternatives. It doesn't mention prerequisites like needing an open dialog, nor does it differentiate from siblings like browser_click for button interactions or browser_select_option for dropdowns. The description offers no context for usage decisions.

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

Related 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/JustasMonkev/mcp-accessibility-scanner'

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