Skip to main content
Glama

browser_evaluate

Executes JavaScript in the active page and returns the result, optionally passing a referenced element to the expression for DOM inspection or data extraction.

Instructions

Execute JavaScript on the page and return the result.

If ref is provided, the expression receives the element as its first argument (use element => element.textContent style arrow functions).

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": {
      "expression": "<expression>"
    },
    "name": "browser_evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
refNo
expressionYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.2/5.0
Behavior2/5

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

With no annotations, the description carries the full burden and leaves significant gaps. It does not say that the script runs arbitrary code with side effects on the live page, that results must be JSON-serializable, how errors surface, or whether `ref` must come from a prior snapshot/refreshed after navigation.

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?

Two short sentences, front-loaded with the core action, and the parenthetical arrow-function example earns its place by showing the calling convention. No filler or repetition.

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?

An output schema exists, so return values need not be re-explained. For an arbitrary-code execution tool with two undocumented schema parameters and no annotations, though, the description should cover mutation risk, serialization limits, and error behavior, none of which 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 0%, so the description must compensate, and it partially does: it clarifies that `ref` causes the element to be passed as the first argument to `expression`, a non-obvious contract not visible in the schema. However, `expression` itself gets no explanation beyond the name, and nothing says what `ref` refers to or how to obtain it.

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 gives a specific verb and object ('Execute JavaScript on the page and return the result'), which unambiguously identifies this as the in-page evaluation tool among the browser_* siblings. It does not explicitly name a contrasting sibling, so it lands just short of the top score.

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?

Usage is only implied: it explains the `ref` form in terms of targeting an element, which hints at when that path is appropriate, but it never states when to prefer this over reading page state via browser_snapshot, browser_get_html, or browser_get_as_markdown. There are no exclusions or prerequisites.

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