Skip to main content
Glama

evaluate

Run JavaScript in the shared browser page to extract data or inspect state, returning a JSON-serializable result; accepts a bare expression or statements with return.

Instructions

Run JavaScript in the page and return the JSON-serializable result. Both a bare expression ("document.title") and statements using "return x" are accepted. Powerful; prefer snapshot/query when possible.

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": {
      "script": "<script>"
    },
    "name": "evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
tabIdNo
scriptYesJS expression or statements; use "return x" for a value

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.1

TDQS

A3.9/5.0
Behavior3/5

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

With no annotations, the description must carry the behavioral burden. It discloses the execution context (in-page), the return contract (JSON-serializable), and the accepted script forms, plus a risk signal in 'Powerful.' However, it never states that arbitrary script can mutate page state, how errors or rejected promises surface, whether results are truncated, or what permissions/CSP may block it.

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, front-loaded with what the tool does, then how to call it, then when to prefer alternatives. No filler or restated title.

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 two-parameter, high-power tool with no annotations and no output schema, the definition covers invocation syntax but omits default-tab behavior, error/return-shape details, and async handling. Adequate to call it, thin on the edge cases that matter for arbitrary code execution.

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?

The description explains the two accepted shapes of 'script' (bare expression vs. 'return x'), which is the main way agents misuse this tool, though this largely repeats the schema's own parameter description. The 'tabId' parameter, at 50% schema coverage, is never mentioned — the description does not say which tab is targeted when it is omitted.

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 specific verb and resource: 'Run JavaScript in the page and return the JSON-serializable result.' It also names the capabilities it is not (snapshot/query), so an agent can place it among the read/inspect siblings without opening another 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?

It gives explicit routing guidance: 'prefer snapshot/query when possible,' which tells the agent this is a fallback for cases the structured tools cannot cover. The condition 'when possible' is left unqualified, so the agent gets direction but no concrete trigger or exclusion cases.

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