Skip to main content
Glama

playwright__browser_run_code_unsafe

Destructive

Run a Playwright code snippet. Unsafe: executes arbitrary JavaScript in the Playwright server process and is RCE-equivalent.

Instructions

Run a Playwright code snippet. Unsafe: executes arbitrary JavaScript in the Playwright server process and is RCE-equivalent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeNoA JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction. For example: `async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }`
filenameNoLoad code from the specified file. Relative file names are resolved against the workspace root. If both code and filename are provided, code will be ignored.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.4.1
    • changedInput schema / properties / filename / description
      Previous value: -"Load code from the specified file. If both code and filename are provided, code will be ignored."New value: +"Load code from the specified file. Relative file names are resolved against the workspace root. If both code and filename are provided, code will be ignored."
  2. First observedv0.4.0

TDQS

A3.6/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true, openWorldHint=true, and readOnlyHint=false, so the safety profile is covered structurally. The description adds real value beyond them by naming the severity: it runs in the Playwright server process and is 'RCE-equivalent', which tells the agent the blast radius is the host, not just the page.

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?

Two sentences, zero waste, purpose front-loaded and the danger statement immediately following. Every clause earns its place.

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 dangerous execution tool with a fully documented schema and complete annotation profile, the description covers what the agent needs to call it and respect it. It omits the relationship to browser_evaluate and the return-value semantics of the executed function, but these are minor given no output schema exits to contradict.

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% and both parameters (code, filename) are richly documented, including the invocation signature and the precedence rule when both are supplied. The description adds nothing about parameters, which is acceptable given the schema does the heavy lifting; baseline 3.

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+resource ('Run a Playwright code snippet') and immediately scopes the mechanism ('executes arbitrary JavaScript in the Playwright server process'). This distinguishes it in spirit from the page-scoped sibling browser_evaluate, though it never names that sibling, so the differentiation is implied rather than explicit.

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, when-not-to-use, or alternative guidance. The 'Unsafe' label signals caution but gives the agent no condition for choosing this over browser_evaluate or any other sibling.

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