Skip to main content
Glama
ChristofMilius

mcp-agent-playwright

browser_evaluate

Run custom JavaScript in a webpage to extract data that accessibility snapshots miss, returning JSON-serializable results.

Instructions

Run arbitrary JavaScript in the page and return the result.

Example: document.title or ({hrefs: [...document.querySelectorAll('a')].map(a => a.href)}). Use for scraping data the accessibility snapshot cannot express.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jsYesJavaScript expression or statement body to run in the page. Return JSON-serializable values.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description carries the burden, and it does disclose the core trait: arbitrary JavaScript executes in the page context and its result is returned. However, it does not explicitly warn that arbitrary JS can mutate page state or cause side effects, nor does it cover promise/async handling, which is a real gap for this powerful tool.

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?

It is two sentences with one compact example; the core behavior is front-loaded and no words are wasted. The example is concrete and directly illustrates both a simple expression and an object-returning expression.

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?

For a one-parameter tool with full schema coverage and an output schema, the description is nearly complete: it states what the tool does, where it runs, and when to prefer it. The missing caution about side effects and async behavior keeps it from being fully complete, but these are not blocking for the primary scraping use case.

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% for the single js parameter, so the schema already documents what to pass and the JSON-serializable return constraint. The description adds a useful expression example and the scraping use case, but it does not substantially extend parameter semantics beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Run arbitrary JavaScript in the page and return the result.' It also differentiates itself from sibling browser tools by saying it is for scraping data the accessibility snapshot cannot express, so an agent can distinguish it from browser_snapshot and the DOM-interaction tools.

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

Usage Guidelines4/5

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

It gives an explicit use case: scraping data the accessibility snapshot cannot express, which points to browser_snapshot as the main alternative. It does not state exclusions such as 'do not use for navigation or clicking' or compare itself with browser_click/type, so it stops short of a 5.

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