Skip to main content
Glama
Chrome DevTools Debug MCP Server

Chrome DevTools Debug MCP Server

by m4eba

add_script_on_new_document

Inject JavaScript into every new document before other scripts run, enabling polyfills or hooks to be applied consistently across page loads.

Instructions

Add a script to be evaluated on every new document before any other scripts. Useful for injecting polyfills or hooks.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "source": "<source>"
    },
    "name": "add_script_on_new_document"
  }
}

Input Schema

NameRequiredDescriptionDefault
sourceYesJavaScript source code to evaluate
worldNameNoIsolated world name. If specified, script runs in isolated context.
runImmediatelyNoRun script immediately on existing documents
includeCommandLineAPINoInclude command line API (e.g., $, $$, $x)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.1

TDQS

A3.6/5.0
Behavior3/5

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

No annotations are supplied, so the description carries the full burden. It does disclose two real behavioral traits that are not in the schema: the script runs on every new document and is ordered before all other scripts. However, it omits lifecycle details an agent would want for a mutation-style tool – whether an identifier is returned for later removal, whether the registration survives reconnects, and what happens if the source throws.

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?

Two short sentences, front-loaded with the action and the timing guarantee. No wasted clauses, though the second sentence is a light 'useful for' aside rather than additional specification.

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?

With no output schema, the description plus a fully documented four-parameter schema is nearly sufficient for correct invocation. The remaining gap is lifecycle/removal guidance, which matters because a sibling exists for undoing this registration.

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 all four parameters (source, worldName, runImmediately, includeCommandLineAPI) are already documented in the schema. The description adds only the ordering context, not meaning for any individual parameter; the baseline of 3 applies.

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?

The description names a specific verb and resource ('Add a script') plus the trigger condition ('evaluated on every new document') and an ordering guarantee ('before any other scripts'). That is enough to distinguish it from remove_script_on_new_document and from one-shot evaluation tools, though it never names those alternatives directly.

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?

'Useful for injecting polyfills or hooks' gives clear positive usage context, and the 'every new document' framing implies persistent rather than one-shot execution. It stops short of exclusions (e.g., when to prefer evaluate_on_frame or an isolated world) and does not reference the sibling removal tool.

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