Skip to main content
Glama

page_init_script

Run custom JavaScript at document start on every navigation, before page scripts load, to intercept API responses, capture state, and patch the environment.

Instructions

INIT SCRIPTS: run your JS at DOCUMENT START on every navigation — BEFORE any page script loads. The deepest interception layer in Ghostfox: hooks installed here are what page libraries (gt.js, analytics, frameworks) capture, so their stored references are YOURS. Use for: API response interception (JSONP callback swaps), state capture, anti-detection instrumentation, environment patches. Applies to subsequent navigations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesJavaScript source to run at document start on every navigation.
page_idYes
session_idYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.7.3

TDQS

A3.7/5.0
Behavior3/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 important behavior: runs at document start, before page scripts, on every navigation, and applies to subsequent navigations. However, it does not mention potential side effects like page breakage or how to remove the script, which is a notable gap for a script-injection 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?

The description is front-loaded with a clear, bolded summary ('INIT SCRIPTS: run your JS at DOCUMENT START on every navigation') followed by relevant use cases. It is somewhat verbose but each sentence adds value, explaining the interception layer and why it matters. No filler or repetition exists.

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

Completeness3/5

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

The description adequately covers the core purpose, timing, and use cases for the tool. However, given that there is no output schema and no annotations, it misses key context: what session_id and page_id are for, how to undo or stop the script, and what happens on errors. These gaps leave an agent with uncertainty about full usage.

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?

Schema coverage is only 33% (only 'source' is described). The description explains the purpose of 'source' (run JS at document start) but provides no additional context for 'session_id' or 'page_id' beyond what the schema shows (which is nothing). It does not compensate for the low coverage, as these parameters are left ambiguous.

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 ('run') and resource ('your JS at DOCUMENT START on every navigation') with explicit timing. It clearly distinguishes itself from sibling tools like page_eval by emphasizing it runs before any page script loads and applies to subsequent navigations, making its purpose unmistakable.

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 provides clear use cases ('Use for: API response interception, state capture, anti-detection instrumentation, environment patches') and timing context. However, it does not explicitly mention when not to use this tool or name alternative tools (e.g., page_eval for one-time execution), so it lacks explicit exclusions/alternatives.

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