Skip to main content
Glama
playwright-mcp-router

playwright-mcp-router

by huangzt

browser_run_code_unsafe

Destructive

Execute arbitrary Playwright JavaScript in the browser server process to run custom page interactions, such as clicking, navigating, or extracting data, inside an isolated session.

Instructions

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

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": {
      "session": "<session>"
    },
    "name": "browser_run_code_unsafe"
  }
}

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(); }`
colorNoOptional Chrome tab group color override for a newly created session.
accountNoChrome account profile to use (defaults to 'default'). Configured accounts: 'default' (Isolated Browser).default
sessionYesRequired isolated session name (also displayed as the Chrome tab group title), e.g. "T1867-api-debug" or "home-css". Use a unique, descriptive task name per conversation so concurrent agents never hijack each other's active tab.
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

B3.2/5.0
Behavior3/5

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

Annotations already declare destructiveHint=true and openWorldHint=true, so the bar is lower, and the description does add real value by explaining why: it executes arbitrary JavaScript in the Playwright server process and is RCE-equivalent. It still leaves behavioral details unstated, such as whether the code runs in the browser page context or the server context, what happens to session state, and what the function's return value becomes the tool result.

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?

Two sentences, front-loaded, with zero filler; the verb+resource leads and the risk clause follows immediately. The phrase "is RCE-equivalent" is dense and earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool whose complexity is 'arbitrary code execution,' the description covers the safety hazard but omits how results come back (no output schema exists) and how it relates to browser_evaluate. The schema fills the parameter side completely, so this is adequate but not complete.

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%, so the schema already documents the code/filename precedence, the required session name, the account and color options. The description adds no parameter meaning beyond that, 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." That distinguishes it from the narrow action tools (browser_click, browser_navigate) by being a general code executor, but it never differentiates itself from browser_evaluate, which is the closest sibling and the one an agent would most likely confuse it with.

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 when to prefer this over the dedicated per-action tools or over browser_evaluate, and nothing says when to avoid it. The word "Unsafe" is a hazard label, not usage guidance.

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