Skip to main content
Glama

evaluate_js

Destructive

Evaluate JavaScript in a browser frame or targeted element by ref, selector, or text, and return JSON; optionally save full results to a file.

Instructions

Evaluate JavaScript in a frame or element (ref/selector/text passes el and arg); returns JSON.

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": "evaluate_js"
  }
}

Input Schema

NameRequiredDescriptionDefault
argNo
refNoOptional target element ref (passes (el, arg) to expression).
textNoOptional visible text target (passes (el, arg) to expression).
tabIdNo
frameIdxNo
savePathNoFile under cwd or TURBO_BROWSER_SAVE_ROOT. Full result goes to the file; the reply has only savePath, bytes and a 300-char preview.
selectorNoOptional target selector (passes (el, arg) to expression).
expressionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.6.1
    • changedInput schema / properties / savePath / description
      Previous value: -"Optional file path relative to cwd to save result."New value: +"File under cwd or TURBO_BROWSER_SAVE_ROOT. Full result goes to the file; the reply has only savePath, bytes and a 300-char preview."
  2. First observedv0.4.0

TDQS

B3.3/5.0
Behavior3/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false, idempotentHint=false and openWorldHint=true, so the bar is lower. The description adds that results come back as JSON and that certain target params bind (el, arg), but says nothing about arbitrary-code side effects, whether the page state is mutated, or why non-idempotent behavior matters. No contradiction with the annotations.

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 dense sentence with the core action front-loaded and the binding semantics as a tight parenthetical. Nothing is wasted, though 'returns JSON' is too terse to be useful on its own.

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?

For an 8-parameter destructive arbitrary-code tool with no output schema, the description is thin: it never describes the reply shape beyond 'returns JSON' (the savePath preview behavior only lives in the schema), nor error or timeout behavior. An agent must open the schema to know how to use it safely.

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 50%, so compensation is partly required. The parenthetical '(ref/selector/text passes el and arg)' is genuinely useful — it explains how arg is bound to the target, which the schema leaves unexplained for arg itself. However, expression, tabId, and frameIdx carry no meaning in either place.

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?

States a specific verb+resource: evaluating JavaScript inside a frame or element, with the targeting modes named. It is distinguishable from the sibling tools (capture_page, extract_clean_text, act_fast), which do not run arbitrary JS. It stops short of a 5 because it never says what class of problem this tool solves versus those siblings.

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 this is the escape hatch for custom JS when no dedicated tool exists. There is no explicit when-to-use, when-not-to-use, or named alternative, despite several sibling tools that might overlap for extraction tasks.

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