Skip to main content
Glama

browser_run_code_unsafe

Destructive

Execute arbitrary Playwright JavaScript in the browser server process to automate page interactions, with the caveat that it is RCE-equivalent and unsafe for untrusted code.

Instructions

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

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(); }`
sessionNoSession id (default "default"). Each session is an isolated browser (own cookies, tabs) that runs in parallel with the others. Created on first use.
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 observedv1.0.0

TDQS

A3.5/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and openWorldHint=true, so the safety profile is partly covered; the description adds genuinely new context by explaining WHY — arbitrary JS runs in the server process and is RCE-equivalent. It stops short of stating consequences (workspace filesystem access, credential exposure) or that the snippet's return value is passed back.

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, zero filler, with the risk warning placed immediately after the purpose so it cannot be missed before the agent crafts a snippet.

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?

The danger is well communicated and parameters are self-documenting, but with no output schema the description never states that the returned value of the async function is surfaced to the caller, nor whether side effects persist across sessions. Adequate but with a visible gap for a high-risk tool.

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%, so all three parameters (code, session, filename) are fully documented in the schema, including the precedence rule when both code and filename are supplied. The description adds nothing beyond that, which matches the baseline for fully documented schemas.

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?

Specific verb+resource ('Run a Playwright code snippet') with an explicit safety qualifier naming the execution context (Playwright server process). It is distinguishable from page-scoped siblings like browser_evaluate, though it never names that sibling to make the contrast airtight.

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?

No when-to-use guidance and no explicit alternatives — the description never says to prefer browser_evaluate or session-scoped tools for normal interaction. The 'Unsafe' label hints at last-resort use but leaves the routing decision entirely to inference.

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