Skip to main content
Glama
CapMonsterCloud

capmonster-mcp-patchright

Official

browser_run_code_unsafe

Run arbitrary JavaScript in a page context. Use isolated world for stealth or main world to access page-defined globals, making scripts interact with anti-bot-protected sites.

Instructions

Execute arbitrary JavaScript in page context. Prefer browser_evaluate when possible. Runs in the isolated stealth world by default; set world:'main' to run in the page's real world (page-defined window globals visible/callable).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNo
worldNoExecution world. 'isolated' (default) = stealth; 'main' = page's real world, page globals visible/callable.
scriptYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

B3.4/5.0
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits itself. It only restates the world behavior already present in the schema ('isolated stealth world by default; set world:'main'...'), and fails to mention risks, side effects, return value, or error behavior—critical for an 'unsafe' code execution tool.

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?

At two sentences, the description is concise and front-loaded with the core action and the browser_evaluate preference. The second sentence about world is relevant but duplicates the schema, so it is not entirely necessary. Overall, every sentence earns its place, though the duplication is a minor inefficiency.

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

Completeness2/5

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

For a tool executing arbitrary JavaScript, the description omits essential information: what the tool returns, whether it can disrupt the page, how errors surface, and security implications. With no output schema and no annotations, the agent is left to guess at critical behaviors, making the definition incomplete for safe and correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With schema description coverage at only 33% (only 'world' has a description), the description should compensate by explaining 'script' and 'args'. It does not—it only repeats the world guidance already in the schema. The description adds no meaning for the script or args parameters beyond their bare types.

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 uses the verb 'Execute' with a specific resource ('arbitrary JavaScript in page context'), and immediately distinguishes from browser_evaluate by saying 'Prefer browser_evaluate when possible.' This clearly identifies what the tool does and separates it from its closest sibling.

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 explicitly advises 'Prefer browser_evaluate when possible,' giving agents a clear directive on when to choose this tool over the alternative. It also explains the world parameter's behavior and when to set world:'main', providing practical usage context beyond the basic enum.

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