Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

handleDialog

Manages browser dialog interactions like alerts, confirms, and prompts by accepting or dismissing them and entering text when needed.

Instructions

Handle browser dialogs (alerts, confirms, prompts)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
acceptYesWhether to accept (true) or dismiss (false) the dialog
promptTextNoText to enter in prompt dialogs (optional)

Implementation Reference

  • Core handler implementation in PlaywrightController that sets up a one-time listener for dialog events and handles accept/dismiss with optional prompt text.
    async handleDialog(accept: boolean, promptText?: string): Promise<void> {
      try {
        if (!this.isInitialized() || !this.state.page) {
          throw new Error('Browser not initialized');
        }
        this.log('Setting up dialog handler', { accept, promptText });
        
        this.state.page.once('dialog', async dialog => {
          this.log('Dialog detected', { type: dialog.type(), message: dialog.message() });
          if (accept) {
            await dialog.accept(promptText);
          } else {
            await dialog.dismiss();
          }
          this.log('Dialog handled');
        });
      } catch (error: any) {
        console.error('Handle dialog error:', error);
        throw new BrowserError('Failed to handle dialog', 'Check if there is a dialog to handle');
      }
    }
  • Tool schema defining the input parameters: accept (required boolean) and optional promptText (string).
    const HANDLE_DIALOG_TOOL: Tool = {
      name: "handleDialog",
      description: "Handle browser dialogs (alerts, confirms, prompts)",
      inputSchema: {
        type: "object",
        properties: {
          accept: { 
            type: "boolean",
            description: "Whether to accept (true) or dismiss (false) the dialog"
          },
          promptText: { 
            type: "string",
            description: "Text to enter in prompt dialogs (optional)"
          }
        },
        required: ["accept"]
      }
    };
  • src/server.ts:543-543 (registration)
    Registration of the handleDialog tool in the tools object passed to MCP server capabilities.
    handleDialog: HANDLE_DIALOG_TOOL,
  • src/server.ts:886-897 (registration)
    MCP callTool request handler case that validates input and delegates to the Playwright controller's handleDialog method.
    case 'handleDialog': {
      if (typeof args.accept !== 'boolean') {
        return {
          content: [{ type: "text", text: "Accept parameter is required" }],
          isError: true
        };
      }
      await playwrightController.handleDialog(args.accept, args.promptText as string);
      return {
        content: [{ type: "text", text: "Dialog handler set successfully" }]
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions handling dialogs but doesn't disclose behavioral traits like whether this blocks execution until dialog appears, what happens if no dialog is present, error conditions, or side effects. The description is too vague for a mutation tool (handling implies interaction) with zero annotation coverage.

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 (one phrase) and front-loaded with the core purpose. Every word earns its place, with no redundant or unnecessary information, making it easy to parse quickly.

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 no annotations, no output schema, and handling browser dialogs (which can involve mutation and complex interactions), the description is incomplete. It lacks details on behavior, error handling, return values, or integration with sibling tools, leaving significant gaps for an AI agent to use it correctly.

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%, so the schema fully documents both parameters. The description adds no parameter-specific information beyond what's in the schema (e.g., it doesn't clarify when 'promptText' is required or how it interacts with dialog types). Baseline 3 is appropriate when the schema does the heavy lifting.

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 action ('handle') and resource ('browser dialogs'), with specific examples of dialog types (alerts, confirms, prompts). However, it doesn't distinguish this tool from sibling tools like 'click' or 'selectOption' that might also interact with browser UI elements, so it doesn't reach the highest score.

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

Usage Guidelines2/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. With many sibling tools for browser interaction (e.g., 'click', 'type', 'selectOption'), there's no indication of when a dialog requires this specific handler versus other methods, nor any prerequisites or exclusions mentioned.

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/jomon003/PlayMCP'

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