Skip to main content
Glama

chrome_inject_script

Inject JavaScript that executes before any page script on every navigation, enabling early instrumentation, customization, or interception in a Chrome tab.

Instructions

Inject a script that runs before any page script on every navigation

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": "chrome_inject_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
tabIdNo
sourceYesJavaScript source to inject

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.1/5.0
Behavior3/5

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

With no annotations supplied, the description carries the full burden, and it does disclose the important behavioral trait of early, per-navigation execution. It omits other critical behaviors: whether injection persists until removed, how to remove it, whether it requires a reload to take effect, and what happens if the tab navigates away or closes.

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?

A single front-loaded sentence with no filler, and the timing constraint is placed where it matters most. It is efficient but arguably too thin given the persistence and targeting questions left unanswered.

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

Completeness2/5

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

For a mutation-style tool with no annotations, no output schema, and an undocumented targeting parameter, the definition leaves too much unsaid. An agent cannot determine injection scope (single tab vs all), lifetime of the injected script, or how to reverse it.

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 50% — 'source' is documented in the schema, but 'tabId' is completely undocumented in both schema and description. The description never clarifies whether omitting tabId injects into the active tab or all tabs, which is the single most consequential ambiguity for this call.

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 states a specific verb+resource ('Inject a script') plus the key timing semantics ('runs before any page script on every navigation'), which clearly separates it from an evaluate-in-page-context tool. It stops short of naming the sibling it differs from (e.g., chrome_evaluate), so it is clear but not fully differentiated.

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 'before any page script on every navigation' phrasing implicitly signals when this tool is appropriate (persistent pre-page hooks) rather than one-off evaluation. However, there is no explicit when-to-use vs when-not guidance, no mention of how injection differs from chrome_evaluate, and no indication of how to undo it.

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