Skip to main content
Glama

browser_evaluate

Destructive

Runs a JavaScript function on a browser page or element to extract values, inspect DOM state, or perform custom checks. Saves results to a file when requested.

Instructions

Evaluate JavaScript expression on page or element

Input Schema

NameRequiredDescriptionDefault
targetNoExact target element reference from the page snapshot, or a unique element selector
elementNoHuman-readable element description used to obtain permission to interact with the element
sessionNoSession id (default "default"). Each session is an isolated browser (own cookies, tabs) that runs in parallel with the others. Created on first use.
filenameNoFile name to save the result to. Relative file names are resolved against the workspace root. If not provided, result is returned as text.
functionYes() => { /* code */ } or (element) => { /* code */ } when element is provided

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.8/5.0
Behavior2/5

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

Annotations already declare readOnlyHint=false, destructiveHint=true, openWorldHint=true, so the safety profile is known, but the description adds nothing about what arbitrary JS execution actually implies: page-context mutation, whether the page can navigate or fire network calls, how async/promises are handled, or what the result looks like. For a deliberately destructive, open-world capability, one sentence of behavioral context is a real gap beyond what the annotations carry.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The single sentence is front-loaded and free of filler, but 'appropriately sized' cuts both ways: for a destructive code-execution tool, one clause is under-specified rather than efficient. It is concise without being informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With five parameters, no output schema, and destructive annotations, the description should at minimum say what evaluation returns (text via filename, or the value) and what context it runs in. None of that is covered, so an agent must infer the entire return and side-effect model from the schema alone.

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 target, element, session, filename, and function are all documented, and the function field even shows the two accepted signatures with and without an element argument. The description's contribution is limited to the phrase 'or element', which only loosely ties the element-scoped form together, so the baseline of 3 applies.

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 ('Evaluate JavaScript expression') and adds the scope 'on page or element', so the core action is unambiguous. It does not distinguish itself from a close sibling like browser_run_code_unsafe, leaving the agent to infer the difference between page-context evaluation and running code in the automation context.

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

Usage Guidelines2/5

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

There is no guidance on when to reach for this tool instead of browser_run_code_unsafe, browser_find, or browser_console_messages, and no stated preconditions (page must be loaded, element must come from a snapshot). The agent is given no exclusions or alternatives whatsoever.

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