Skip to main content
Glama

Evaluate JavaScript

evaluate

Run JavaScript expressions in the current page to extract data or inspect page state; results return as JSON with promises awaited.

Instructions

Evaluate a JavaScript expression in the page and return its value as JSON. Promises are awaited. Use for data extraction or page state, not for navigation (prefer navigate).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "expression": "<expression>"
    },
    "name": "evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
max_charsNoOutput cap (default 8000).
expressionYesJavaScript expression, e.g. document.title

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior4/5

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

Beyond the single readOnlyHint=false annotation, it discloses two non-obvious behaviors: promises are awaited, and the resolved value is serialized as JSON. It stops short of warning that arbitrary evaluated code can mutate page state or of describing error behavior when the expression throws, which matters given readOnlyHint=false.

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 short sentences, ~30 words, front-loaded with the core action before the behavioral note and the exclusion. No sentence is redundant or restates the tool name.

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 two-parameter tool with no output schema, the description covers the call contract (expression in, JSON out, awaited promises) sufficiently to invoke it correctly. Error semantics and execution context (main world vs isolated) are the remaining gaps but are not essential to make a correct call.

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%, so both parameters (expression, max_chars) are already documented with examples and defaults. The description adds no format or syntax guidance beyond the schema, so baseline 3 applies.

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 (evaluate), the exact resource (a JavaScript expression in the page), and the return contract (value as JSON). It also draws a boundary against the sibling 'navigate', so an agent can distinguish it without inspecting schemas.

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 an explicit positive use case (data extraction or page state) and an explicit exclusion with a preferred alternative for navigation (use navigate). It does not cover adjacent cases such as reading console output or structured extraction, but the when/when-not guidance present is clear.

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