Skip to main content
Glama

evaluate_script

Run a JavaScript function in the page to return targeted values like text, computed styles, or element existence, without a full snapshot. Ideal for quick reads during browser automation.

Instructions

Run a JS function in the page and return its result. Prefer this for targeted reads (a value, text, computed style, whether an element exists) instead of a full take_snapshot. Use the UID interaction tools for clicking, typing, and filling.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNoUIDs to pass as function arguments
saveToNoSave the result to a file as JSON instead of returning it inline. Pass a file path, an existing directory (generated file inside), or true (generated file under ~/.firefox-devtools-mcp/output/). Relative paths resolve against the current working directory.
previewNoNumber of characters of the saved result to return inline as a preview when saveTo is used. Omit for no preview.
sandboxNoEvaluate in an isolated sandbox realm with this name instead of the page realm. The sandbox shares the page DOM and keeps the native built-ins even where the page overrode them. Page-defined globals and expandos are invisible from the sandbox, and vice-versa. The same name reuses the same sandbox across calls; omit to evaluate in the page realm.
timeoutNoTimeout in ms (default: 5000)
functionYesJS function string, e.g. () => document.title

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed1 schema field changedv0.10.0
    • addedInput schema / properties / sandbox
      Added value: +{
      +  "description": "Evaluate in an isolated sandbox realm with this name instead of the page realm. The sandbox shares the page DOM and keeps the native built-ins even where the page overrode them. Page-defined globals and expandos are invisible from the sandbox, and vice-versa. The same name reuses the same sandbox across calls; omit to evaluate in the page realm.",
      +  "type": "string"
      +}
  2. Addedv0.9.15

TDQS

A4.2/5.0
Behavior3/5

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

The annotations declare readOnlyHint: false, and the description doesn't contradict this — no annotation contradiction. However, the description adds minimal behavioral disclosure beyond the schema; the rich details (sandbox realm semantics, saveTo path resolution) live in the parameter docs, not the description. For a tool that executes arbitrary JS, a note about side-effect potential or that results may not be serializable would have elevated this further.

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?

Three sentences, each earning its place: what it does, when to prefer it, what to use instead. Front-loaded with the core purpose and zero filler. This is a model of concise, high-information density.

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 complex JS execution tool with 6 parameters and no output schema, the description plus annotations plus rich schema documentation provide a complete picture. The only gap is that it doesn't address error behavior or serialization limits of return values, but these are minor given the strength of the supporting schema docs.

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 100%, and the schema's parameter docs are genuinely rich (saveTo explains string/directory/true behavior, sandbox explains realm isolation and persistence, timeout documents its 5000ms default). Per the calibration baseline, when the schema handles the documentation burden, a 3 is appropriate. The description wisely avoids restating what the schema covers.

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 'Run a JS function in the page and return its result' — a specific verb+resource+outcome statement. It also distinguishes itself from siblings by naming take_snapshot and the UID interaction tools. The tool's purpose is instantly clear.

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?

Explicit when-to-use guidance: 'Prefer this for targeted reads (a value, text, computed style, whether an element exists) instead of a full take_snapshot.' It also tells the agent what NOT to use it for: 'Use the UID interaction tools for clicking, typing, and filling.' This is textbook usage guidance with named alternatives.

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

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/mozilla/firefox-devtools-mcp'

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