Skip to main content
Glama

browser_run_code_unsafe

Destructive

Run arbitrary Playwright JavaScript in the server process for direct page control. Unsafe: equivalent to remote code execution, so use only for advanced automation tasks.

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. First observedv0.1.0

TDQS

A4.4/5.0
Behavior5/5

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

Even though destructiveHint=true and readOnlyHint=false already signal danger, the description adds crucial context: the code runs in the Playwright server process, can execute arbitrary JavaScript, and is RCE-equivalent. This is more transparent than the annotation alone and gives an agent a concrete safety boundary.

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 short sentences deliver the action, the resource, the execution context, and a stark safety warning. Every word earns its place, and the danger is front-loaded immediately after the verb.

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 arbitrary-code tool with no output schema, the description gives the critical context an agent needs: where the code runs and why it is unsafe. It does not describe the return value or error behavior, but given the open-ended nature of the tool and the complete parameter schema, this is a minor gap.

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 'code' and 'filename' are already well documented in the schema, including the precedence rule when both are provided. The description adds no parameter-specific meaning, but it does not need to because the schema carries the full burden.

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 names a specific verb ('Run'), a specific resource ('a Playwright code snippet'), and immediately identifies the defining scope: arbitrary JavaScript in the Playwright server process. This clearly sets it apart from sibling tools like browser_evaluate, which executes in the page, even though both are code-execution 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?

The description does not name alternatives explicitly, but the 'Unsafe' and 'RCE-equivalent' framing strongly implies this is a last-resort escape hatch rather than a routine tool. It gives enough context for an agent to know it should prefer the safer specialized browser sibling tools unless it truly needs arbitrary Playwright code.

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