Skip to main content
Glama

Evaluate JavaScript

evaluate

Run JavaScript in the browser page's main world to extract data or trigger page logic, returning a JSON value.

Instructions

Execute JavaScript in the page main world and return a JSON value. Use an IIFE for multiple statements, e.g. "(() => ({title: document.title}))()". Powerful: prefer snapshot/DOM when possible.

Input Schema

NameRequiredDescriptionDefault
tabIdNo
frameIdNo
trustedNo
expressionYes
userGestureNo
awaitPromiseNo
returnByValueNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.3

TDQS

B3.4/5.0
Behavior3/5

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

With no annotations, the description carries the full behavioral burden. It usefully discloses execution context (page main world) and return format, and 'Powerful' hints at risk. However, it never states that this runs arbitrary code with page privileges, can mutate/destroy page state, or what permissions/userGesture gating applies — significant omissions for a mutation-capable tool.

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?

Three tight sentences, front-loaded with purpose, followed by the practical IIFE pattern and the alternative guidance. The example earns its space by showing the required expression format; no filler.

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 7-param, no-annotation, no-output-schema tool, the description covers purpose, return type, and the expression convention but leaves six parameters and the safety/mutation profile undocumented. Adequate as a starting point, incomplete given the tool's complexity and risk.

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

Parameters2/5

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

Schema description coverage is 0% across 7 parameters. The description does explain the required 'expression' param with a concrete IIFE example, but tabId, frameId, trusted, userGesture, awaitPromise, and returnByValue are entirely undocumented in both schema and description.

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?

States a specific verb and resource — 'Execute JavaScript in the page main world' — and names the return type ('return a JSON value'). It also references sibling alternatives ('prefer snapshot/DOM'), so an agent can distinguish its role from dom and snapshot without opening a 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?

Explicitly tells the agent when *not* to reach for this tool ('prefer snapshot/DOM when possible'), which is a real routing rule against named siblings. It stops short of enumerating when this tool IS the right choice, but the context is clear.

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