Skip to main content
Glama

browser_handle_dialog

Answers JavaScript alert, confirm, prompt, or 'Leave site?' dialogs on the active tab, or arms automatic handling for the next dialog before a click opens it.

Instructions

Answer a JavaScript alert/confirm/prompt or "Leave site?" on the active tab. If a dialog this extension saw open is on screen and nobody is answering it, it is answered now, and the reply says what Chrome reports happened (action accept or dismiss). Otherwise this arms automatic handling of the next dialog on the tab and returns immediately - call it BEFORE the click that opens the dialog, because a dialog freezes the tab. Pass wait=true only when the dialog is already opening. An armed accept never answers "Leave site?" unless leave_page is true; the arming lasts at most 30 s. A "Leave site?" that is already open is accepted only with leave_page: true too (error leave-page-required). An extension older than 1.33.0 (its store update can lag a release) does not enforce leave_page when accepting dialogs, so the server does not send it an accept without leave_page: true (error extension-too-old-for-leave-page); an arming it is sent is capped at 30 s but survives a page or tab change. Errors: dialog-being-answered (browser_navigate or an earlier call is answering it - wait), dialog-unconfirmed (answered, but Chrome did not confirm it closed), tab-not-responding (a dialog that opened before anything listened, or a busy page; the note says what to do), page-changed (the page changed while arming; nothing was armed), session-changed (the session switched tabs while arming). With extension 1.33.0 or newer, an arming is dropped when a new document loads or becomes active in the tab (a reload or a prerendered page too; not an address change within the page) or the session moves to another tab.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "browser_handle_dialog"
  }
}

Input Schema

NameRequiredDescriptionDefault
textNoText to enter for prompt() dialogs
waitNoBlock until a dialog appears instead of arming and returning (default: false). Only use when the dialog is already on its way.
actionNoAccept or dismiss the dialog (default: accept)
timeoutNoHow long the arming stays active in ms (default and at most 30000)
partitionNoRun this call in a partition from browser_partition (an id like "p1"). Leave it out for the default partition. An unknown or closed id is an error; the call is never sent to the default partition instead.
leave_pageNoWith action accept: also accept a "Leave site?" (beforeunload), which leaves the page and loses anything unsaved on it. Default false: an armed accept answers alerts, confirms and prompts only. Ask the user first.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.33.0
    • addedInput schema / properties / leave_page
      Added value: +{
      +  "description": "With action accept: also accept a \"Leave site?\" (beforeunload), which leaves the page and loses anything unsaved on it. Default false: an armed accept answers alerts, confirms and prompts only. Ask the user first.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / partition
      Added value: +{
      +  "description": "Run this call in a partition from browser_partition (an id like \"p1\"). Leave it out for the default partition. An unknown or closed id is an error; the call is never sent to the default partition instead.",
      +  "type": "string"
      +}
    • changedInput schema / properties / timeout / description
      Previous value: -"How long the arming stays active in ms (default: 60000)"New value: +"How long the arming stays active in ms (default and at most 30000)"
  2. Changed2 schema fields changedv1.28.0
    • changedInput schema / properties / timeout / description
      Previous value: -"Max wait for dialog in ms (default: 10000)"New value: +"How long the arming stays active in ms (default: 60000)"
    • addedInput schema / properties / wait
      Added value: +{
      +  "description": "Block until a dialog appears instead of arming and returning (default: false). Only use when the dialog is already on its way.",
      +  "type": "boolean"
      +}
  3. First observedv1.0.0

TDQS

A4.2/5.0
Behavior3/5

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

No annotations are supplied, so the description bears the full transparency burden, and it does a lot: arming semantics, the 30 s cap, leave_page enforcement, extension-version behavior, and a full error taxonomy are disclosed. However, the second half collapses into an extremely dense run-on about arming being dropped on document load or tab switch, making the behavioral picture hard to parse on first read.

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

Conciseness3/5

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

Purpose is correctly front-loaded in the first sentence, but the remainder is a single sprawling paragraph with nested parentheticals and semicolon chains. Most sentences carry unique information, yet the final sentence about arming being dropped is nearly unreadable and could be split or summarized rather than enumerated inline.

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

Completeness4/5

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

Given no annotations, no output schema, and a six-parameter tool with subtle async semantics, the description covers nearly everything an agent needs: timing, arming lifetime, error names, and version caveats. The main gap is that the dense final sentence makes the arming-drop conditions harder to act on than the rest of the content.

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

Parameters4/5

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

Schema coverage is 100%, so the schema already documents all six parameters, setting the baseline at 3. The description adds value beyond the schema by explaining when to set wait=true, that leave_page applies only to accept and needs user confirmation, and the extension-version constraint that triggers leave-page-required or extension-too-old-for-leave-page.

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

Purpose5/5

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

Opens with a specific verb and resource: 'Answer a JavaScript alert/confirm/prompt or "Leave site?" on the active tab.' It names the exact dialog types handled and the scope (active tab), which distinguishes it from sibling interaction tools like browser_click that would open such dialogs.

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

Usage Guidelines5/5

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

Gives explicit timing guidance: call it BEFORE the click that opens the dialog because a dialog freezes the tab, and 'Pass wait=true only when the dialog is already opening.' It also tells the agent what to do on dialog-being-answered (wait) and requires asking the user before leave_page.

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