Skip to main content
Glama
playwright-mcp-router

playwright-mcp-router

by huangzt

browser_evaluate

Destructive

Evaluates JavaScript expressions on a Playwright page or target element, returning results as text or saving them to a file for debugging and data extraction.

Instructions

Evaluate JavaScript expression on page or element

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": {
      "session": "<session>",
      "function": "<function>"
    },
    "name": "browser_evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
colorNoOptional Chrome tab group color override for a newly created session.
targetNoExact target element reference from the page snapshot, or a unique element selector
accountNoChrome account profile to use (defaults to 'default'). Configured accounts: 'default' (Isolated Browser).default
elementNoHuman-readable element description used to obtain permission to interact with the element
sessionYesRequired isolated session name (also displayed as the Chrome tab group title), e.g. "T1867-api-debug" or "home-css". Use a unique, descriptive task name per conversation so concurrent agents never hijack each other's active tab.
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 observedv0.1.0

TDQS

C2.9/5.0
Behavior2/5

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

Annotations already declare readOnlyHint=false, destructiveHint=true, and openWorldHint=true, so the safety profile is covered. The description adds nothing beyond that — it doesn't mention that arbitrary code runs with page privileges, that results go to a file when filename is set, or that side effects persist. Consistent with annotations, so no contradiction.

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?

A single front-loaded sentence with no filler or redundancy. It is efficient, though the brevity edges into under-specification rather than crispness.

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?

This is a seven-parameter, destructive, arbitrary-code-execution tool with no output schema, yet the description never explains the return path (text vs. saved file), the required function signature, or the session isolation model. Given the complexity and risk, the one-line description is not sufficient.

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 every parameter including session, function signature, target, element, and filename is documented in the schema itself. The description contributes no additional meaning about parameter behavior; baseline 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?

The description gives a clear verb ('Evaluate') and object ('JavaScript expression on page or element'), so an agent can tell this executes code in the page context. It does not, however, distinguish this from the sibling browser_run_code_unsafe, leaving ambiguity about which execution tool to pick.

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 when-to-use or when-not-to-use guidance, no mention of prerequisites, and no reference to any alternative tool. The agent is left to infer that this is the tool for arbitrary in-page evaluation versus snapshot/click/fill siblings.

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