Skip to main content
Glama

page_eval

Evaluate a JavaScript expression in the live page and return its value directly, skipping network and console activity. A bounded timeout prevents scripts from running indefinitely.

Instructions

Evaluate a JS expression in the page and return its value directly (no network/console delta). Use this for a quick, standalone read (e.g. "document.title"). If you also want the network/console/url side-effects the expression may cause, use page_observe with {action:{kind:"eval"}} instead. Bounded: an expression that runs or waits longer than timeoutMs (default 15000ms) is stopped — a busy loop is terminated so the page stays usable; a never-settling promise is abandoned.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdNo
timeoutMsNotime budget in ms (default 15000, max 60000)
expressionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.6.0

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations, the description carries full responsibility. It discloses timeout behavior (stopped after timeoutMs), that a busy loop is terminated, and that a never-settling promise is abandoned. It also states the return type is the value directly. It doesn't mention error handling (e.g., what happens if the expression throws), but the disclosed behavior is meaningful and not contradicted by any annotations.

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?

Two sentences, front-loaded with the core purpose, then usage guidance, then behavioral constraints. Every sentence earns its place with zero redundancy. Highly efficient.

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 simple eval tool with no output schema, the description covers the essential points: what it does, when to use it, the return type, and timeout behavior. It doesn't explicitly explain sessionId or error handling, but given the tool's simplicity and the clarity of the rest, it is quite complete. The mention of page_observe as an alternative further rounds out the context.

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 only 33% (only timeoutMs has a description), so the description must compensate. It explains the expression via example ('document.title') and clarifies the timeout behavior and default (15000ms). However, sessionId is not explained at all, and the timeoutMs description in the schema already covers the default and max, so the description adds little new for that parameter. Partial compensation for the gap but not complete.

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?

States a specific verb (evaluate) with a clear resource (JS expression in the page) and the result (return value directly). It explicitly distinguishes itself from page_observe by noting the absence of network/console side-effects, making it easy for an agent to pick the right tool among many siblings.

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

Usage Guidelines5/5

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

Provides explicit when-to-use guidance ('quick, standalone read') and names the alternative tool (page_observe with {action:{kind:'eval'}}) for when side-effects are desired. This directly addresses the key usage decision for an agent.

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