Skip to main content
Glama

CDP: Inject

cdp_inject
Destructive

Register a persistent userscript on an attached browser so it re-runs at document-start on every navigation, current and future, not just once.

Instructions

Register a persistent userscript on the attached browser (CDP Page.addScriptToEvaluateOnNewDocument) — re-runs at document-start on every navigation, current and future pages. Unlike cdp_eval (one-shot).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabNoTab index from cdp_tabs to act on.
urlNoPick the tab whose URL contains this substring.
portNoCDP debug port (default 9222).
scriptYesUser script source to register on the attached browser

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Going beyond destructive/readOnly annotations, it discloses lifetime behavior: re-runs at document-start on every navigation, affecting current and future pages. This is exactly the extra context an agent needs for a persistent mutation.

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?

Front-loaded with the verb and resource. The parenthetical CDP method and contrasting clause about cdp_eval each earn their place; no sentence is wasted.

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 mutation tool with full schema descriptions and destructive annotations, the key behavioral traits (persistent lifetime, document-start execution, future navigation scope) are fully covered. No output schema is needed.

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 coverage is 100%, so the schema already explains all four parameters. The description only implies the required 'script' parameter via 'userscript' and adds no syntax, format, or constraint details beyond the schema.

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?

Names the specific action 'register a persistent userscript' and the exact CDP method, and explicitly distinguishes it from the sibling cdp_eval as one-shot. An agent can identify the tool's role without opening the schema.

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?

Names the alternative cdp_eval and states the key difference: persistent vs one-shot. This gives clear context for choosing between them, though it stops short of explicit when-not conditions.

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