Skip to main content
Glama

browser_evaluate

Evaluates a JavaScript expression once in an attached browser tab, awaits a returned function's Promise, and returns JSON or a DOM element reference via cached cursors.

Instructions

Evaluate expression once; call a returned function once and await its Promise, without user activation. Use an async IIFE for statements. capture_truncated marks capture loss; required_chars/next_item signal page-budget needs. cursor reads cache without re-execution.

Input Schema

NameRequiredDescriptionDefault
frameNoChild frame: at least one of url/title/path. url/title exact; path=unique nested CSS iframe steps (e.g. ["#frame"]); exclusive with frame_id.
cursorNoExactly one of expression/cursor. Cursor reads cached JSON; omit frame/frame_id and result_type=element.
frame_idNo
max_charsNoPer-page JSON value budget, excluding metadata; capture cap 1M chars / 50000 nodes / depth 8.
expressionNo
tab_handleYes
timeout_msNo
result_typeNoelement: return one connected DOM element as a ref.json
dialog_policyNoaccept/dismiss auto-handle dialogs and return their messages.ask

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.24.2
    • changedInput schema / properties / cursor / description
      Previous value: -"Cached JSON instead of expression; omit frame, frame_id and result_type=element."New value: +"Exactly one of expression/cursor. Cursor reads cached JSON; omit frame/frame_id and result_type=element."
    • changedInput schema / properties / dialog_policy / description
      Previous value: -"accept/dismiss returns handled dialog messages."New value: +"accept/dismiss auto-handle dialogs and return their messages."
    • changedInput schema / properties / frame / description
      Previous value: -"Exact child-frame URL/title or CSS iframe path (e.g. [\"#content_iframe\"]); alternative to frame_id. Each path entry uniquely selects an iframe in the preceding document."New value: +"Child frame: at least one of url/title/path. url/title exact; path=unique nested CSS iframe steps (e.g. [\"#frame\"]); exclusive with frame_id."
    • addedInput schema / properties / result_type / description
      Added value: +"element: return one connected DOM element as a ref."
  2. First observedv0.24.0

TDQS

B3.4/5.0
Behavior3/5

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

With no annotations, the description carries the full burden and it does disclose real behavior: it runs without user activation, awaits a returned Promise, and reports capture loss via capture_truncated. It does not say whether the expression can mutate page state or whether the tool is read-only, which is the most important unknown for an arbitrary-code tool.

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 core execution contract is front-loaded in the first sentence, and the following sentences each add a distinct fact (IIFE pattern, truncation signals, cursor reuse). It is dense but no sentence is pure filler; the jargon terms are only lightly defined.

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?

For a 9-parameter tool with no annotations and no output schema, the description helpfully names three return-side fields (capture_truncated, required_chars, next_item) that would otherwise be invisible. But it omits dialog_policy behavior, result_type=element semantics, and frame targeting that the schema only partly documents.

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 coverage is 56% across 9 parameters. The description adds meaning for expression, cursor (cache read, no re-execution) and the page-budget mechanic that governs max_chars, but leaves tab_handle, frame/frame_id, timeout_ms, result_type, and dialog_policy unaddressed. Partial compensation, not full.

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 opening clause 'Evaluate expression once' names a specific verb (evaluate) and resource (a page expression), which no sibling tool duplicates. It also states the execution contract (call a returned function once, await its Promise). It stops short of naming when to prefer it over browser_snapshot or browser_read_text, so it is clear but not fully differentiated.

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?

'Use an async IIFE for statements' and 'cursor reads cache without re-execution' give concrete usage hints for two scenarios. However, there is no guidance on when to reach for this tool instead of the sibling read tools (browser_read_text, browser_snapshot), and no statement of when not to use it.

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