Skip to main content
Glama

browser_evaluate

Destructive

Run JavaScript in a page and return the JSON-serialisable result. Pass a function like () => document.title, or include a ref to pass an element as the first argument.

Instructions

Run JavaScript in the page and return the JSON-serialisable result. Pass a function: () => document.title, or (element) => element.value together with a ref. Promises are awaited.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoElement passed as the function's first argument
elementNoHuman-readable element description used to obtain permission to interact with the element
functionYesJavaScript function source, e.g. `() => location.href`

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.0

TDQS

A3.7/5.0
Behavior3/5

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

Annotations already flag readOnlyHint=false, destructiveHint=true and openWorldHint=true, and the description adds genuine behavioral detail beyond them: the result must be JSON-serialisable and Promises are awaited. However, it omits the most important behavioral caveat for a destructive tool with page-level privileges – that arbitrary JS can mutate or break the page – and says nothing about error behavior or the permission prompt implied by the 'element' parameter.

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 tight sentences: purpose first, then the two calling forms with inline examples, then the async caveat. No filler, and the most decision-relevant information is front-loaded.

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?

There is no output schema, so the description carries the return-value burden and does so adequately ('JSON-serialisable result', awaited Promises). Given a destructive, open-world tool operating on live pages, it is still missing failure modes and a warning about side effects on page state.

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 100%, so the baseline is 3, but the description adds contract detail the schema lacks: the function must be a function expression, it may take the ref element as its first argument (illustrated with `(element) => element.value`), and async results are awaited. It does not explain the 'element' permission-description parameter, so it is short of a 5.

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?

The description states a precise verb+resource ('Run JavaScript in the page and return the JSON-serialisable result'), which unambiguously places it as the arbitrary-JS escape hatch among a sibling set of navigation/click/snapshot tools. It never names a sibling alternative, so the differentiation is implicit rather than explicit.

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 implied by the unique capability ('run JS in the page'), but there is no explicit when-to-use guidance, no statement of when the structured siblings (browser_snapshot, browser_click) should be preferred, and no preconditions such as needing a loaded page or permission. The invocation examples help a caller but do not advise on tool selection.

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