Skip to main content
Glama

browser_add_preload_script

Inject custom JavaScript into every new document before page scripts load to add hooks or Tampermonkey-style behavior.

Instructions

Inject custom JavaScript to run on every new document before page scripts load (hooks / Tampermonkey).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesJavaScript source code to evaluate

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.8.0

TDQS

A3.6/5.0
Behavior3/5

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

With no annotations, the description must carry the behavioral load. It usefully discloses the execution timing (before page scripts) and the persistence scope (every new document), which are the two traits that matter most here. It omits whether the script persists across browser restarts, whether it applies to already-open tabs, and that browser_remove_preload_script is required to undo it.

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?

A single sentence that front-loads the action and its timing, with the analogy parenthetical earning its place. Nothing is redundant or padded.

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?

For a one-parameter tool with no output schema, the description covers the essentials: what is injected, when it runs, and the mental model for it. It is nearly complete; persistence semantics across sessions and the removal path are the remaining gaps.

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?

Only one parameter ('source') and schema description coverage is 100%, so the schema already documents the argument fully. The description adds only the framing word 'custom JavaScript', which is marginal value beyond the schema's 'JavaScript source code to evaluate'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb ('Inject') plus resource ('custom JavaScript') and the critical timing constraint ('on every new document before page scripts load'). It clearly reads as distinct from browser_eval, which executes on demand in the current context. It does not name browser_remove_preload_script as the inverse, but the purpose itself is unambiguous.

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

Usage Guidelines3/5

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

The parenthetical '(hooks / Tampermonkey)' implies the use case (persistent instrumentation of future documents), which is decent implied guidance. However, it gives no explicit when-not guidance or alternatives — e.g., that browser_eval should be used for one-off evaluation rather than persistent injection.

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