Skip to main content
Glama

dom.set_html

Replace an element and its subtree with new HTML markup using a CSS selector, XPath, text, snapshot ref, or backend node ID to update page content.

Instructions

Replace an element and its subtree with new markup.

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": {
      "html": "<html>"
    },
    "name": "dom.set_html"
  }
}

Input Schema

NameRequiredDescriptionDefault
nthNoZero-based index when the locator matches several elements.
refNoSnapshot ref (eNN) from page.snapshot.
htmlYes
textNoVisible text of the element.
xpathNoXPath expression.
frame_idNoFrame to search within; see page.list_frames.
selectorNoCSS selector; pierces shadow DOM.
target_idNoTarget handle (tgt_*). Omit for the active page.
browser_idNoBrowser handle (br_*). Omit to use the only running browser, or auto-launch one.
backend_node_idNoCDP backendNodeId, e.g. from inspector.pick.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.1/5.0
Behavior3/5

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

The annotations state readOnlyHint=false and openWorldHint=true, so the mutating nature is already declared; the description adds the useful detail that the existing subtree is destroyed, not merged. However, it says nothing about what happens when a locator matches multiple elements, whether the replacement is undoable, or how frame/target scoping affects execution, which matters for a 10-parameter live-DOM write.

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; every word carries information and the destructive scope of the operation appears first. It is terse to the point of under-specification, but no sentence is wasted.

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 tool with 10 parameters spanning browser, target, frame, and five alternative locator strategies, one sentence is far too thin. With no output schema present, the description should at least state what is returned or how the locator is resolved, and it does neither.

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 90%, so nearly every parameter is already documented in the schema. The description adds no meaning beyond that—it does not say that one of the several locator parameters (ref, selector, xpath, text, backend_node_id) must be supplied to identify the target, nor how nth interacts with a multi-match locator.

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 gives a specific verb and resource: 'Replace an element and its subtree with new markup.' This clearly distinguishes it from read-only siblings like dom.get_html and from attribute-level edits like dom.set_attribute. It doesn't explicitly name a sibling to route away from, keeping it at 4 rather than 5.

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

Usage Guidelines2/5

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

There is no guidance on when to use this tool instead of dom.set_attribute, dom.remove, or dom.export, and no prerequisites such as requiring a snapshot or an attached target. The agent must infer from the name alone that this is the wholesale-replacement variant.

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