Skip to main content
Glama

browser_eval

Evaluates a JavaScript expression in the active page and returns its JSON-serializable result, awaiting promises up to a timeout. Use it to extract page data or run in-page logic with the current session.

Instructions

Run a JavaScript expression in the active page and return its JSON-serializable result. Promises are awaited (timeout ms, default 10000). Runs with the page's privileges, including any logged-in session: only run code you wrote or understand.

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_eval"
  }
}

Input Schema

NameRequiredDescriptionDefault
timeoutNoMax ms to await a promise (default 10000)
expressionYesJavaScript expression

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv4.5.0
    • addedInput schema / properties / timeout
      Added value: +{
      +  "description": "Max ms to await a promise (default 10000)",
      +  "type": "number"
      +}
  2. First observedv2.0.4

TDQS

A3.5/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 does disclose important traits: promise awaiting with a default timeout and that code runs with the page's privileges, including logged-in sessions. It omits other material behavior such as error/serialization failure handling, whether navigation or mutation side effects persist, and frame/context constraints.

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?

Three short sentences, front-loaded with the action and return value, then timeout behavior, then the privilege warning. Every sentence earns its place; the only small cost is the parenthetical timeout detail that duplicates the schema.

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?

For a two-parameter evaluation tool with no output schema, the description covers what is returned, how promises/timeouts are handled, and the privilege implications, which is the critical safety context. It is only marginally incomplete on error behavior and execution context (frames, origins).

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 100%, so both parameters are already documented, establishing a baseline of 3. The description reinforces the timeout's promise-awaiting meaning and adds that the result must be JSON-serializable, which shapes how the expression should be written, but adds no syntax or format detail beyond the schema.

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-plus-resource: it runs a JavaScript expression in the active page and returns the JSON-serializable result. That is clearly distinct from click/fill/extract siblings in substance, but it never names or explicitly contrasts a sibling tool, which keeps it 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 Guidelines3/5

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

Usage is only implied: an agent can infer it is for arbitrary in-page JavaScript rather than structured actions, but there is no explicit 'use this when' rule and no named alternative (e.g. a text-extraction tool) for cases where scripted evaluation is unnecessary.

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