Skip to main content
Glama
CapMonsterCloud

capmonster-mcp-patchright

Official

browser_add_init_script

Add a JavaScript init script that runs before any page script on every navigation. Use it to preempt anti-bot checks like Cloudflare or Turnstile by calling it before navigating to the target URL.

Instructions

Register JavaScript that runs before any page script, on every navigation (Playwright's page.addInitScript — always in the page's main world). Unlike browser_evaluate, this is proactive: it wins the race against a site's own inline (e.g. Cloudflare/Turnstile checks that run synchronously on document parse), which a reactive evaluate call issued over the MCP connection cannot. Call this BEFORE browser_navigate to the target URL — it has no effect on a page already loaded, only on the page it's called on and future navigations of that same page. Scoped to the current page only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptNoDeprecated alias for function.
functionNoFunction body/expression to install as the init script, e.g. '() => { window.foo = 1; }'.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations, the description carries the full transparency burden, and it delivers: it discloses main-world execution, per-navigation timing, persistence on future navigations, current-page scoping, and the race condition with synchronous inline scripts. This goes well beyond a generic 'registers a script' statement.

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?

Three sentences, each with a distinct job: what it does, why it beats evaluate, and when/how to call it. No filler; every sentence earns its place despite the rich technical detail.

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?

The description covers purpose, timing, scoping, and comparison to alternatives, which is strong for a two-parameter tool with no output schema. It misses clarifying that at least one of script or function must be supplied, since the schema marks both optional; that ambiguity keeps it from a 5.

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% and both parameters already have meaningful descriptions ('Deprecated alias for function' and 'Function body/expression...'). The description adds no parameter-level semantics beyond the schema, so baseline 3 applies.

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: 'Register JavaScript that runs before any page script, on every navigation.' It explicitly distinguishes itself from browser_evaluate by framing its proactive nature, so an agent can immediately tell what this tool does and how it differs from a likely sibling.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives explicit timing guidance ('Call this BEFORE browser_navigate'), states the limitation ('no effect on a page already loaded'), and names the alternative browser_evaluate with the exact condition that selects between them (proactive init vs reactive evaluate). This is explicit when/when-not guidance.

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