Skip to main content
Glama
playwright-ui-mcp

playwright-ui-mcp

by ailabs-393

browser_evaluate

Execute JavaScript in a Playwright page context by page ID to inspect or manipulate the DOM and retrieve runtime values for UI verification and automation.

Instructions

Execute JavaScript code in the page context

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": {
      "pageId": "<pageId>",
      "script": "<script>"
    },
    "name": "browser_evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
pageIdYesThe page ID
scriptYesJavaScript code to execute

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.1/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the entire behavioral burden and it discloses almost nothing. It does not say whether the script can mutate page state, whether it is awaited (async/promise handling), how the script's return value is surfaced, whether errors are thrown or returned, or whether any timeout applies. For arbitrary code execution these are the exact traits an agent needs.

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 repetition. It is efficient, though its brevity reflects under-specification rather than tight information density.

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?

There is no output schema, so the description is the only place to explain how results come back, yet it says nothing about return values, async resolution, or error behavior. For a tool that executes arbitrary code in a live browser page, the definition omits information an agent needs to invoke it confidently and interpret the outcome.

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%, with both pageId and script documented, so the baseline is 3. The description adds no semantics beyond the schema, such as what 'page context' means relative to iframes or content-script isolation, or what form the script argument should take.

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 code') plus the execution scope ('in the page context'), which is far more informative than a bare name restatement. It stops short of distinguishing this from siblings like browser_get_content or browser_click, which are the safer alternatives for reading content or interacting with a specific element.

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 only implied: an agent can infer this is the escape hatch for arbitrary JS when the purpose-built sibling tools (click, type, get_content) don't cover the case. There is no explicit when-to-use, when-not-to-use, or statement that deterministic, purpose-built tools should be preferred.

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