Skip to main content
Glama

replace_in_html_file

Find and replace exact text in HTML tool files under resources/html/; returns a validation summary and flags missing or ambiguous matches.

Instructions

Find and replace exact text in an HTML tool file (paths under resources/html/ only). Errors if searchText is missing or ambiguous (multiple matches) — expand searchText, or pass replaceAll/occurrenceIndex. The result includes a validation summary.

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": {
      "workspacePath": "<workspacePath>",
      "filePath": "<filePath>",
      "searchText": "<searchText>",
      "replaceText": "<replaceText>"
    },
    "name": "replace_in_html_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
filePathYesFile path relative to the workspace root (e.g. "resources/html/my-tool/index.html")
replaceAllNoReplace every occurrence of searchText (default false)
searchTextYesExact text to find, copied verbatim (must be unique in the file unless replaceAll or occurrenceIndex is passed)
replaceTextYesText to replace it with
workspacePathYesAbsolute path to the workspace directory
occurrenceIndexNoReplace only the Nth occurrence (1-based). Alternative to expanding searchText when it appears multiple times.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.19.0
    • addedInput schema / properties / occurrenceIndex
      Added value: +{
      +  "description": "Replace only the Nth occurrence (1-based). Alternative to expanding searchText when it appears multiple times.",
      +  "type": "integer"
      +}
    • addedInput schema / properties / replaceAll
      Added value: +{
      +  "description": "Replace every occurrence of searchText (default false)",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / searchText / description
      Previous value: -"Text to search for (must be unique enough to identify the exact location)"New value: +"Exact text to find, copied verbatim (must be unique in the file unless replaceAll or occurrenceIndex is passed)"
  2. First observedv0.6.0

TDQS

A3.9/5.0
Behavior4/5

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

With no annotations, the description carries the full burden, and it does disclose the key behavioral traits: uniqueness is enforced, ambiguity is an error rather than a silent first-match, and a validation summary comes back. It never explicitly says the file is rewritten on disk or whether the edit is reversible/atomic, which keeps it below a 5 for a mutation tool.

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?

Three sentences, front-loaded with the operation and scope, then the error contract, then the return note. Tight overall, with only mild restatement of schema-documented options (replaceAll/occurrenceIndex).

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 six-parameter mutation tool with no annotations and no output schema, the definition covers purpose, scope, error semantics, and return shape, which is most of what an agent needs. The remaining gap is write-side behavior: whether the file is modified in place, and any permission or backup considerations.

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 all six parameters, including the default of replaceAll and the 1-based indexing of occurrenceIndex, are already documented. The description restates the interaction between searchText uniqueness and replaceAll/occurrenceIndex but adds no format or syntax detail beyond the schema, so the baseline 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?

"Find and replace exact text in an HTML tool file" is a specific verb+resource pair, and the parenthetical "paths under resources/html/ only" scopes it away from generic siblings like replace_content. It stops short of naming an alternative tool outright, so the differentiation is implied by path scope rather than stated.

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?

The description explains the failure path (missing or ambiguous searchText) and tells the agent exactly how to recover: expand searchText, or pass replaceAll/occurrenceIndex. The resources/html/ restriction acts as an implicit when-not-to-use rule, but no sibling alternative is named for the out-of-scope case.

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