Skip to main content
Glama

Evaluate JavaScript in a page

evaluate_js
Destructive

Execute JavaScript in an attached H5 page to inspect or change page state, read cookies/storage, and return results, including awaited Promises.

Instructions

Run a JavaScript expression in an attached page and return its result. Plain objects/arrays come back as JSON (so nested Map/Set/DOM values show as {}); other values (DOM nodes, Map, Set, Error, window) as a short description. Promises are awaited. For multiple statements or await, wrap them: (async () => { ... })(). Runs with the page's full privileges, so it can read cookies/storage and change page state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_idNoDefaults to the most recently attached page
expressionYesJavaScript expression to evaluate

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.1

TDQS

A4.7/5.0
Behavior5/5

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

Adds substantial context beyond annotations: it discloses that execution runs with the page's full privileges, can read cookies/storage and mutate page state (consistent with destructiveHint=true), awaits promises, and explains how different return types are serialized. This is exactly the behavioral detail annotations cannot convey.

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?

Four tightly packed sentences with zero filler, front-loaded with the core action and return contract, then privileges. Every sentence carries information an agent needs.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description carries the full return-value burden and does so thoroughly (JSON for plain objects/arrays, short description for DOM/Map/Set/Error/window). Privilege and mutation scope are also covered, so nothing needed to call or interpret the tool is missing.

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 100%, so the baseline is 3; the description goes further by implying the expression parameter must be a single expression and must be wrapped in an async IIFE for statements/await. It adds no extra detail for target_id beyond the schema's own default note.

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 and resource ('Run a JavaScript expression in an attached page and return its result') and is clearly distinct from the siblings (list_targets, attach, get_console, detach). An agent can identify the tool without opening the schema.

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?

Gives concrete usage guidance ('For multiple statements or await, wrap them: (async () => { ... })()') and notes target_id defaults to the most recently attached page. It stops short of naming when-not-to-use or pointing to a sibling such as get_console for log inspection, so no explicit alternatives are offered.

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

Deploy Server

Other Tools