Skip to main content
Glama

browser_run_code_unsafe

Destructive

Execute arbitrary Playwright JavaScript snippets to automate page interactions and return results; use with caution because it runs code in the server process.

Instructions

Run a Playwright code snippet. Unsafe: executes arbitrary JavaScript in the Playwright server process and is RCE-equivalent. [PlayGuard] Each call waits for the page to settle. Prefer one script that loops over viewports/states over several calls.

Input 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. If both code and filename are provided, code will be ignored.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.10.1

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=false, destructiveHint=true, and openWorldHint=true, so the safety bar is partly pre-cleared; the description still adds real signal by naming the risk as "RCE-equivalent" and by disclosing the per-call settle-wait, which has latency and batching implications. It stops short of saying whether page state persists between calls or what the snippet returns.

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 plus a bracketed operational note, with the highest-stakes fact (RCE-equivalent) placed early rather than buried. Every sentence carries distinct information: capability, risk, wait behavior, batching advice.

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 2-parameter tool with no output schema and annotations covering the safety profile, the description supplies the risk model and the operational constraint an agent needs before calling. The remaining gap is return-value behavior and cross-call page state, which the absent output schema pushes onto the description.

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 `code` and `filename` fully documented in the schema, including the precedence rule that `code` is ignored when `filename` is supplied. The description adds nothing about parameters beyond the word "snippet", so the baseline 3 applies.

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 ("Run a Playwright code snippet") and immediately qualifies it with the execution context ("executes arbitrary JavaScript in the Playwright server process"). That context implicitly separates it from page-scoped siblings like browser_evaluate, but no sibling is named, so the differentiation is left to inference.

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?

The PlayGuard note gives one concrete usage rule — batch loops into a single script rather than making several calls — which is genuine guidance. However, it never says when to reach for this versus browser_evaluate, browser_snapshot, or the granular interaction tools, which is the central selection decision for an agent facing ~23 siblings.

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