Skip to main content
Glama

Evaluate JavaScript

evaluate
Destructive

Runs JavaScript in the selected page's main runtime to execute promise-based DOM interactions and return serializable results.

Instructions

Evaluate JavaScript in the selected page's main runtime. Supports promises and mutations, so an expression can install a one-shot DOM event listener and resolve after the user acts. Results must be serializable.

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
page_idNoTarget page id from get_pages; omit to use the selected page
expressionYesJavaScript expression or IIFE
await_promiseNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.0

TDQS

A3.6/5.0
Behavior4/5

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

Annotations only say readOnly=false and destructive=true; the description adds real context beyond that: promise support, mutation capability, the one-shot listener pattern, and the hard constraint that results must be serializable. It does not cover timeouts, navigation persistence, or error surfacing, which would matter for arbitrary code execution.

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?

Two compact sentences, front-loaded with the verb and target runtime, followed by the behavioral caveats. Nothing is redundant, though the listener example is dense in a single clause.

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?

No output schema exists, and the description does not describe what evaluation returns or how failures surface, which is significant for an arbitrary-code tool. The serialization constraint is helpful, but return shape and limits remain undocumented.

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 coverage is 67%, so most parameters are already documented. The description hints at page_id scoping ('selected page') and at await_promise through 'supports promises', but never states the default awaiting behavior or the expression syntax expectations directly.

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?

A specific verb and resource are stated: evaluate JavaScript in the page's main runtime, with the runtime scope clarifying what is affected. It is naturally distinct from siblings like get_console or screenshot, but the description never explicitly contrasts with them, leaving the distinction implicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied. The note that an expression can install a one-shot DOM listener and resolve after user action hints at a real use case, but there is no explicit 'use this when…' guidance, no prerequisites, and no mention of when to prefer get_console or inspect_page instead.

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