Skip to main content
Glama

Run JavaScript

evaluate

Run JavaScript in a browser tab to extract data or execute custom scripts, returning JSON results; choose main or isolated world and target iframes as needed.

Instructions

Runs JavaScript in the page and returns the result as JSON. Pass either an expression ("document.title") or a function ("(a, b) => a + b") with args. Promises are awaited. DOM nodes, functions and cyclic objects are described instead of failing. world="isolated" runs in a private world that cannot see page globals; frame selects an iframe by the ref of its element.

Input Schema

NameRequiredDescriptionDefault
argsNoArguments for function.
frameNoElement ref from page_snapshot or find, e.g. "e12".
tabIdNoTab to act on. Defaults to the session target tab (see tab_select).
worldNoExecution world (default main, i.e. the page's own JavaScript context).
functionNoJavaScript function source, called with args.
timeoutMsNoTimeout in milliseconds (default 30000).
expressionNoJavaScript expression to evaluate.
userGestureNoTreat the call as a user gesture (allows play(), fullscreen, clipboard).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior4/5

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

With annotations declaring readOnlyHint=false and openWorldHint=true, the description adds valuable behavioral context: promises are awaited, DOM nodes/functions/cyclic objects are described rather than causing failures, and isolated worlds cannot see page globals. It does not contradict annotations and meaningfully supplements them.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is four tight sentences, front-loaded with the primary purpose and followed by the most decision-relevant details. There is no filler or repetition.

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 an 8-parameter tool with no output schema and no required params, the description covers return format, unserializable value handling, execution worlds, and frame selection. Remaining details like timeout and userGesture are adequately covered by the schema, so the description is nearly complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is already 100%, setting the baseline at 3, but the description adds semantic meaning beyond the schema: the expression-vs-function distinction, the behavioral implication of world='isolated', and the frame ref rule. This helps an agent choose parameter values correctly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ('Runs JavaScript in the page and returns the result as JSON') and clearly distinguishes the tool from siblings like cdp_send or console_logs. An agent can immediately tell this is the direct page-context evaluation tool.

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?

The description implies when to use the tool by explaining expression vs function modes and frame/world selection, but it never states when not to use it or which siblings are alternatives. Usage is inferable but not explicitly routed.

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