Skip to main content
Glama

playwright__browser_evaluate

Destructive

Evaluate JavaScript expression on page or element

Instructions

Evaluate JavaScript expression on page or element

Input Schema

TableJSON 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
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. Changed1 schema field changedv0.4.1
    • changedInput schema / properties / filename / description
      Previous value: -"Filename to save the result to. If not provided, result is returned as text."New value: +"File name to save the result to. Relative file names are resolved against the workspace root. If not provided, result is returned as text."
  2. First observedv0.4.0

TDQS

C2.8/5.0
Behavior2/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false and openWorldHint=true, so the safety profile is covered by structured data. The description adds nothing beyond that: no mention that arbitrary JS can mutate page state, no note about the permission requirement for element targets, and no guidance on result handling. Baseline low because it contributes zero behavioral context.

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?

A single front-loaded sentence with zero waste, which is structurally clean. It is arguably too terse for a destructive, arbitrary-code-execution tool, but it is not padded or redundant.

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?

For a tool that runs arbitrary JavaScript with destructiveHint=true and no output schema, the description should at least cover the permission flow for element targets or the difference from browser_run_code_unsafe. Neither is addressed, so an agent cannot confidently choose or invoke it correctly on its own.

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 all four parameters (target, element, filename, function) are already documented in the schema with useful detail. The description adds no parameter information beyond the schema, which is acceptable at baseline 3 but earns no extra credit.

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?

Names a specific verb (evaluate) and resource (JavaScript expression on page or element), so the agent knows the operation immediately. However, it does nothing to distinguish it from the sibling playwright__browser_run_code_unsafe, which also executes code in the browser, leaving the boundary between the two unclear.

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 choose this tool over browser_run_code_unsafe, no prerequisites, and no note that element-targeted evaluation triggers a permission flow (implied by the 'element' parameter). The 'on page or element' phrasing hints at two modes but never explains which to use when.

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