Skip to main content
Glama

interceptor_browser_inject_init_script

Inject a JavaScript file as an init script that runs before any page script on every navigation, enabling prototype/global patches without DOM artifacts. Navigate again to apply to the current page.

Instructions

Inject a JS file as an init script (Playwright page.addInitScript). Runs before any page script on every subsequent navigation/frame. Runs in the isolated utility world — no DOM artifact; patches to shared prototypes/globals reach the page main world via utility-world sharing. Does NOT affect the currently loaded document — navigate again to apply.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_idYesTarget ID from interceptor_browser_launch
script_pathYesAbsolute path to a .js file to inject before page scripts on every load.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv3.5.3
    • changedInput schema / properties / target_id / description
      Previous value: -"Target ID from interceptor_browser_launch or interceptor_camoufox_launch"New value: +"Target ID from interceptor_browser_launch"
  2. Addedv3.2.0

TDQS

A4.5/5.0
Behavior5/5

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

With no annotations provided, the description carries the full behavioral burden and does it well. It discloses the isolated utility world execution, the absence of a DOM artifact, that prototype/global patches reach the main world via utility-world sharing, and the critical caveat that the current document is unaffected. This is rich, non-obvious behavior beyond what the schema reveals.

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 dense sentences with zero filler. The core action and timing are front-loaded, followed by the isolated-world behavior and the navigation caveat. Every sentence earns its place.

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

Completeness5/5

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

For a two-parameter action with no output schema, the description provides everything an agent needs to invoke it correctly: target_id and script_path are covered by the schema, and the description explains when it runs, where it runs, and the key limitation about the current document. No critical operational detail is missing.

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 description coverage is 100%, so the baseline is 3. The description reinforces the meaning of script_path by explaining when it executes, but it does not add parameter-specific semantics beyond what the schema already states. target_id is adequately documented in the schema as coming from interceptor_browser_launch.

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 states a specific verb and resource ('Inject a JS file as an init script') and clarifies the exact execution timing. It effectively distinguishes this tool from one-off injection/evaluation tools like interceptor_browser_add_script_tag and interceptor_browser_evaluate by emphasizing it runs on every subsequent navigation/frame and not the current document.

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 clearly conveys when to use the tool: when a script must run before page scripts on every future navigation/frame. It also gives an exclusion by noting it does not affect the currently loaded document and instructs to navigate again to apply. It stops short of explicitly naming sibling alternatives, but the context is clear.

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

Deploy Server

Other Tools