Skip to main content
Glama

eval

Run JavaScript expressions in the page's isolated context, preventing window mutations from affecting page scripts; use eval_handle to retain references across calls.

Instructions

Evaluate a JS expression in the page (isolated context per Patchright default — window.X = ... mutations are NOT visible to page JS; use eval_handle to retain references).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exprYesJS expression.
leaseNoOptional lease token to present if the target session is leased (0.7.0). Threaded per-call; never read from the server's env.
sessionNoOptional session name to target (omit for the shared 'default'). On a daemon shared with other agents, pass a UNIQUE name for stateful multi-step work (go→click→fill) so you don't collide on 'default'.
timeout_msNoGive up after this long — a busy page starves isolated-world eval too.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

The description adds a key behavioral nuance beyond the `openWorldHint` annotation: the JS runs in an isolated world so `window.X = ...` mutations are NOT visible to page JS. This is exactly the practical behavior an agent must know before calling eval. It also mentions that `eval_handle` is the alternative to retain references, which is actionable and not deductible from the annotation alone.

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?

The description is a single sentence and front-loaded with the action, while still adding the critical isolated-world caveat and forwarding to `eval_handle`. It is a little dense with the semicolon-clause, but every piece earns its place. Nothing is fluffy or redundant.

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?

For a tool with four parameters and a strong schema, the description covers the most important evaluation-context trap. However, it does not state what the caller should expect as a return value or how async expressions are handled, which agents often need to know when using an eval tool; leaves some usage ambiguity.

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?

The input schema has 100% description coverage for all four parameters, so the description does not need to repeat parameter meanings. The description adds no extra intel about `expr`, `lease`, `session`, or `timeout_ms`, so it does not improve on what the schema now gives; the baseline of 3 applies.

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 states a specific verb and resource: it 'evaluate[s] a JS expression in the page.' It further clarifies the scope by noting the isolated context and the boundary on `window.X` mutations, and it differentiates itself from `eval_handle` by telling the caller when to use that sibling instead. An agent can then distinguish `eval` from the many other page-tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

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

It explicitly provides an alternative: 'use eval_handle to retain references', which tells the agent when `eval` is insufficient. It also implies this tool is for cases where references are NOT retained. However, it does not define broader conditions (e.g., when it is better than `wait_fn` or extracting text) or list exclusions beyond the reference case.

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