Skip to main content
Glama

browser_evaluate

Run JavaScript expressions or functions inside a live browser page or element context to read DOM state, computed values, and page data during automation.

Instructions

Evaluate a JavaScript expression or function in the browser page context (or on a specific element ref).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "function": "<function>"
    },
    "name": "browser_evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
refNoOptional element ref to pass as the first argument to the function.
elementNoHuman-readable description of the element if ref is specified.
functionYesJavaScript function or expression string, e.g. '() => document.title' or '(el) => el.textContent'.
sessionIdNoOptional target browser session ID. If omitted, uses the currently active session (or auto-launches one).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full disclosure burden. It never states that this executes arbitrary code with side effects, whether returned promises are awaited, whether results must be serializable, how errors surface, or what the return value looks like. For an arbitrary-code-execution tool with zero annotation coverage, this is a substantial gap.

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?

A single, front-loaded sentence with no filler or repetition. It is appropriately sized, though the brevity is partly the cause of the missing behavioral and usage detail.

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?

With four parameters, no annotations, and no output schema, the description should explain return-value handling and error behavior. It does none of that, leaving the agent unable to predict what comes back from an evaluation or how failures appear.

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 already documents ref, element, function, and sessionId in detail. The description only confirms that evaluation can be scoped to an element ref, adding little meaning beyond the schema. This is the expected baseline 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 names a specific verb and resource: evaluate a JavaScript expression or function within the browser page context, optionally scoped to an element ref. That is concrete enough to distinguish it from navigation, clicking, or snapshot tools. It does not explicitly contrast with the closely related browser_run_code sibling, so it falls short of a 5.

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?

There is no when-to-use guidance, no prerequisites, and no exclusion or alternative named. The parenthetical about a specific element ref hints at a use case but reads as a parameter note rather than routing advice. An agent must infer on its own when to reach for this tool versus browser_run_code or browser_snapshot.

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