Skip to main content
Glama

evaluate_script

Run JavaScript functions in the target page and receive JSON-serializable output to inspect live page data.

Instructions

Evaluate a JavaScript function inside the target page. Returns the response as JSON, so returned values have to be JSON-serializable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNoAn optional list of arguments to pass to the function.
pageIdYesTargets a specific page by ID.
filePathNoThe absolute or relative path to a file to save the script output to. If omitted, the output is returned inline.
functionYesA JavaScript function declaration to be executed by the tool in the target page. Example without arguments: `() => document.title` or `async () => await fetch("example.com")`. Example with arguments: `(el) => el.innerText`
dialogActionNoHandle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept.
waitForStableDomNoWhether to wait for the DOM to settle. Pass false if the script only reads data. Defaults to true.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.3/5.0
Behavior3/5

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

The description adds a meaningful behavioral constraint: returned values must be JSON-serializable because output is returned as JSON. However, annotations provide only readOnlyHint=false, and the description does not disclose potential side effects, navigation risks, or other execution consequences of running arbitrary page JavaScript, so the description only partially carries the behavioral burden.

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 with no filler. The action and target are front-loaded, and the key return constraint is stated immediately after. The description is compact and easily scannable.

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?

The schema covers all parameters and the description explains the return format, which is important since there is no output schema. However, the description omits usage guidance and side-effect caveats for arbitrary code execution, and the non-read-only nature is only signaled by the minimal annotation. These gaps make the context only moderately complete.

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%, with all six parameters described, including examples for the function parameter. The description adds the JSON-serializability caveat for the return value, but otherwise does not explain parameter semantics beyond what the schema already provides. This meets the baseline.

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 clearly identifies the action ('Evaluate a JavaScript function'), the target resource ('inside the target page'), and the return mode (JSON). It is specific enough for an agent to understand what the tool does, and while it does not explicitly name a sibling alternative, no sibling appears to offer arbitrary JavaScript execution.

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

Usage Guidelines2/5

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

There is no guidance on when to use this tool versus dedicated actions like fill, click, navigate_page, or take_snapshot. The description does not state exclusions, prerequisites, or cases where a more specific tool should be preferred, leaving the agent to infer usage context.

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