Skip to main content
Glama

evaluate

Destructive

Execute JavaScript in the browser context and return the result to extract data, check page state, or perform actions other browser tools do not cover.

Instructions

[Agent Browser] Execute JavaScript in the browser context and return the result. NOTE: This runs raw JS, NOT Playwright selectors. Use document.querySelector(), not text=. Useful for extracting data, checking state, or performing actions not covered by other tools.

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
scriptYes

Output Schema

NameRequiredDescriptionDefault
dataNo
hintsNo
messageNo
successNo
suggestionsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.0

TDQS

A3.8/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=false, destructiveHint=true, openWorldHint=true and idempotentHint=false, so the risk profile is structured. The description adds that the executed code is raw JS rather than a selector DSL, which widens the plausible side-effect surface, but it says nothing about execution timeouts, result serialization limits, or error propagation for a tool that can arbitrarily mutate page state.

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 short lines, front-loaded with the core action and the highest-value caveat (raw JS, not selectors) immediately after. The NOTE placement is effective; the tool-specific syntax example earns its space.

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?

An output schema exists, so return-value explanation is unnecessary, and annotations cover the risk profile. What remains missing for an arbitrary-code-execution tool is minor but real: how it waits for the page, what it returns for non-serializable values, and how script errors surface.

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

Parameters4/5

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

Schema coverage is 0% for the single 'script' parameter, so the description must compensate, and it does with concrete syntax guidance ('Use document.querySelector(), not text=') that tells the agent exactly what string to pass. It stops short of stating whether the script must be an expression, a function body, or return a JSON-serializable value.

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 browser context and return the result') and explicitly disclaims the selector-based approach used by neighbouring tools ('This runs raw JS, NOT Playwright selectors'). It does not name a concrete sibling, so it falls just short of a 5, but an agent can immediately tell this is the arbitrary-code escape hatch rather than a DOM-selector tool.

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 three concrete use contexts (extracting data, checking state, performing actions not covered by other tools), with the last clause functioning as an explicit fallback rule. It lacks a corresponding 'when not to use' statement, e.g. preferring the dedicated click/fill/attr tools when one exists, so it is clear but not complete.

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