Skip to main content
Glama

evaluate

Execute JavaScript in the page context to access Shadow DOM, iframe content, hidden data, and trigger events that standard selectors cannot reach.

Instructions

Run JavaScript in the page context and return the result.

Use this to handle situations standard selectors can't reach:

  • Shadow DOM: document.querySelector('my-el').shadowRoot.querySelector('input')

  • Iframes: document.querySelector('iframe').contentDocument.querySelector('p')

  • Hidden data: window.INITIAL_DATA or JSON.parse(document.getElementById('NEXT_DATA').textContent)

  • Visibility checks: document.querySelector('.modal')?.getBoundingClientRect()

  • Triggering events: document.querySelector('input').dispatchEvent(new Event('focus'))

Args: js: JavaScript expression to evaluate. The return value is JSON-serialised and included in the response. Keep expressions simple — complex logic is better split across multiple calls.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses that the return value is JSON-serialised and included in the response, and that the JS runs in page context. However, it does not mention whether promises are awaited or if there are timeouts, so it's not fully exhaustive.

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 structured with a purpose sentence, a bulleted list of example uses, and an Args section. It's longer than necessary but every section adds value.

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 one-parameter tool with no annotations but an output schema, the description covers purpose, usage, and parameter semantics well. The output schema likely details the return structure, so the description's note about JSON-serialised results is sufficient.

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

Parameters5/5

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

The schema only says js is a string. The description explains it is a 'JavaScript expression to evaluate', notes the return value is JSON-serialised, and advises simplicity. This fully compensates for the 0% schema coverage.

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 clear verb+resource statement: 'Run JavaScript in the page context and return the result.' It also lists concrete use cases (Shadow DOM, iframes, hidden data) that distinguish it from sibling automation tools like click and fill_field.

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?

The description explicitly frames when to use this tool: 'Use this to handle situations standard selectors can't reach' and gives examples. It also advises to keep expressions simple, implying that complex logic should be split into multiple calls.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Dominic-Pi-Sunyer/web-speed-agent'

If you have feedback or need assistance with the MCP directory API, please join our Discord server