Skip to main content
Glama

browser_run_code_unsafe

Execute raw Playwright JavaScript snippets against the active page and receive their JSON results, enabling custom automation when unsafe mode is enabled.

Instructions

DANGEROUS: run a raw Playwright JavaScript snippet (async function body with page in scope) against the active page and return its JSON result. Disabled unless LAYA_ALLOW_UNSAFE_CODE=true.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesA JavaScript snippet run as an async function body with the Playwright `page` in scope, e.g. 'return await page.title();'.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

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

With no annotations, the description carries full responsibility for behavioral disclosure. It reveals that the tool executes arbitrary async code with `page` in scope, targets the active page, returns JSON, is dangerous, and requires an environment variable. It stops short of detailing failure modes or side effects beyond the generic danger warning.

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?

The description is two sentences with no fluff, front-loading the critical 'DANGEROUS' warning before the technical details. Each clause conveys essential information: danger, execution model, target, return type, and activation requirement.

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 single-parameter code execution tool with no output schema, the description covers the execution environment, the active-page scope, the JSON result, and the required environment flag. It omits explicit error-handling or serialization caveats, but these are not essential given the simple signature and the strong overall context provided.

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?

The input schema already fully describes the `code` parameter with a clear example and notes the async function body and `page` scope. The description adds little beyond repeating that same execution model, so it does not meaningfully supplement the schema. Baseline 3 is appropriate since coverage is 100%.

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?

The description clearly states that the tool runs a raw Playwright JavaScript snippet against the active page and returns its JSON result. It gives a specific verb ('run') and resource ('active page'), but it does not explicitly differentiate this from the sibling browser_evaluate tool. This is clear but lacks explicit sibling differentiation.

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 description provides context through the 'DANGEROUS' warning and the operational gate 'Disabled unless LAYA_ALLOW_UNSAFE_CODE=true.' However, it does not explicitly state when to use this tool instead of safer alternatives like browser_evaluate, nor does it give exclusion criteria. The usage context is implied but not fully directive.

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