Skip to main content
Glama
Playwright MCP Server

Playwright MCP Server

by sohitmahato

playwright_evaluate

Executes JavaScript in the browser context to inspect or manipulate live pages during automation, scraping, and testing tasks.

Instructions

Execute JavaScript in browser 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": {
      "script": "<script>"
    },
    "name": "playwright_evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
scriptYesJavaScript code to execute

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations, the description carries the full behavioral burden and falls well short. It does not say whether the script's return value is serialized back to the caller, whether execution is restricted to the current page or frame, or that arbitrary script can mutate or destroy page state. Only the 'browser context' phrase adds any behavioral framing.

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 six-word sentence, front-loaded with the verb and with zero filler. It is efficient, though its brevity edges into under-specification rather than disciplined conciseness.

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 high-risk, high-complexity capability — running arbitrary code in a live page — with no annotations and no output schema. The description says nothing about return values, error behavior, or mutation risk, so an agent cannot call it confidently or safely.

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 coverage is 100% with a single required string parameter, so the schema already conveys everything about 'script'. The description adds no meaning beyond it — no note on whether the script is an expression, function body, or async, which materially changes how it must be written.

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 ('Execute') and resource ('JavaScript') plus the execution environment ('in browser context'), so the agent knows this runs arbitrary code in the page. It does not distinguish itself from siblings like playwright_click or playwright_extract_text, but the capability is inherently distinct enough to be recognized.

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 guidance at all — nothing says whether this should be a fallback when no dedicated action tool (click, fill, extract_text) fits, nor what happens on the page as a result. The agent must infer all routing decisions from the tool name alone.

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