Skip to main content
Glama
CapMonsterCloud

capmonster-mcp-patchright

Official

browser_evaluate

Execute JavaScript in the active page or inside a specified iframe. Choose isolated world for stealth or main world to access page-defined globals.

Instructions

Evaluate JavaScript in the active page. Pass 'function' for a function body, 'expression' for a plain expression, or 'script' (deprecated). By default JS runs in an isolated stealth world (DOM is shared, but the page's own window globals are NOT visible). Set world:'main' to run in the page's real world — required to read or call globals the page defined (e.g. a page-registered callback). Pass frameSelector to run inside a specific iframe (including cross-origin ones, e.g. a captcha widget hosted on a different domain) instead of the top-level page — same CSS selector browser_click/browser_fill/browser_type already accept.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
worldNoExecution world. 'isolated' (default) = stealth, page globals hidden; 'main' = page's real world, page globals visible/callable.
scriptNo
functionNo
expressionNo
frameSelectorNoRun inside this iframe (CSS selector) instead of the top-level page — reaches cross-origin iframe content that plain JS (element.contentDocument) cannot, the same way browser_click/browser_fill/browser_type already do.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

A4.4/5.0
Behavior4/5

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

No annotations are provided, so the description carries the full burden. It discloses the isolated stealth world default, the DOM-sharing/global-hiding behavior, the main-world alternative, and the ability to reach cross-origin iframes. It also flags 'script' as deprecated. These are important behavioral traits beyond the schema.

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?

The description is longer than average, but every sentence carries necessary information: the evaluation modes, the stealth-world behavior, the main-world requirement, and the iframe targeting. It is front-loaded with the core purpose and then adds detail in a logical order, so the density is justified.

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?

Given the 5-parameter complexity and no output schema, the description addresses parameter selection, execution world, and iframe targeting thoroughly. The main gap is that it never states what the tool returns after evaluation (result value, formatting, promise handling), which an agent would need to know for downstream use. Still, the core calling context is well covered.

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

Parameters5/5

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

Schema description coverage is only 40%, with script, function, and expression left undocumented in the schema. The description explicitly explains what each of those three parameters expects and how to pass them, and it adds operational meaning to world and frameSelector. This fully compensates for the schema gaps.

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 opens with a specific verb and resource: 'Evaluate JavaScript in the active page.' It clearly distinguishes the tool's scope from the many other browser tools by focusing on JS execution, and it further clarifies variations (function body, expression, deprecated script) so an agent knows exactly what operation is offered.

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?

Provides concrete usage conditions: use world:'main' when page globals need to be read or called, and pass frameSelector to target a specific or cross-origin iframe. It does not explicitly name sibling alternatives to rule out, but the guidance is specific enough for an agent to select parameters correctly.

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