Skip to main content
Glama

Surgical find/replace in one file

update_file_content
Destructive

Apply literal find/replace edits to one file in one call, for small changes where uploading the whole file is wasteful. Each edit states how many matches it expects; any mismatch aborts the call with no writes. Served-file (dist) edits go live at once; source edits ship with build_and_deploy. Use apply_edits for several files.

Input Schema

NameRequiredDescriptionDefault
nameYesSite name as shown by list_sites, e.g. my-portfolio.
pathYesPath inside the chosen tree, e.g. index.html.
editsYesOrdered edits `{find, replace, count?}`, applied together; if any match count differs, nothing is written.
targetNo'dist' (default) edits the served file, live at once. 'source' edits the editable source tree; build_and_deploy ships it.

Output Schema

NameRequiredDescriptionDefault
nameYes
pathYes
editsYes
siteIdYes
targetYes
warningsNoSecret-scanner findings in the rewritten file that did not block the edit (AWS Access Key, Stripe Key, JWT Token, etc.). Malicious content blocks the edit with MALICIOUS_CONTENT instead.
afterBytesYes
beforeBytesYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changed
    • changedInput schema / properties / edits / description
      Previous value: -"Ordered list of edits to apply atomically. Each is `{find, replace, count?}`. If any edit's match count doesn't equal its expected count, the whole call aborts with no writes."New value: +"Ordered edits `{find, replace, count?}`, applied together; if any match count differs, nothing is written."
    • changedInput schema / properties / edits / items / properties / count / description
      Previous value: -"Expected number of matches. Default 1 (fail if 0 or >1 — protects against unintended bulk edits). Use -1 for replace-all. Use a positive integer to assert an exact count."New value: +"Expected matches: default 1 (fails on 0 or more than 1), -1 = replace all, or an exact number."
    • changedInput schema / properties / edits / items / properties / find / description
      Previous value: -"Literal string to find. Not a regex (no escaping needed). Max 64 KB."New value: +"Literal text to find (not a regex). Max 64 KB."
    • changedInput schema / properties / edits / items / properties / replace / description
      Previous value: -"Literal replacement. Max 64 KB. Empty string to delete the matched text."New value: +"Literal replacement; empty string deletes the match. Max 64 KB."
    • changedInput schema / properties / name / description
      Previous value: -"Site name."New value: +"Site name as shown by list_sites, e.g. my-portfolio."
    • changedInput schema / properties / path / description
      Previous value: -"File-relative path inside the chosen target tree."New value: +"Path inside the chosen tree, e.g. index.html."
    • changedInput schema / properties / target / description
      Previous value: -"Which tree to edit. 'dist' (default) edits the served file directly — visitors see the change immediately. 'source' edits the editable source tree; you'll need build_and_deploy (or it short-circuits via noBuild) to ship."New value: +"'dist' (default) edits the served file, live at once. 'source' edits the editable source tree; build_and_deploy ships it."
  2. Changed1 schema field changed
    • removedOutput schema / properties / request_id
      Removed value: -{
      -  "description": "Server-assigned request correlation id. Quote it when contacting support.",
      -  "type": "string"
      -}
  3. Changed1 schema field changed
    • addedOutput schema / properties / warnings
      Added value: +{
      +  "description": "Secret-scanner findings in the rewritten file that did not block the edit (AWS Access Key, Stripe Key, JWT Token, etc.). Malicious content blocks the edit with MALICIOUS_CONTENT instead.",
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "file": {
      +        "type": "string"
      +      },
      +      "line": {
      +        "type": "number"
      +      },
      +      "match": {
      +        "type": "string"
      +      },
      +      "type": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "file",
      +      "line",
      +      "type",
      +      "match"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
  4. Changed1 schema field changed
    • addedOutput schema / properties / request_id
      Added value: +{
      +  "description": "Server-assigned request correlation id. Quote it when contacting support.",
      +  "type": "string"
      +}
  5. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare destructive/non-idempotent/openWorld, but the description adds the crucial atomicity contract ('any mismatch aborts the call with no writes') and the differing deploy semantics of dist vs source. These are high-value behavioral traits beyond what the structured fields provide.

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?

Four tight sentences, front-loaded with the core action, then atomicity, then deploy timing, then the sibling pointer. Every sentence carries distinct information with no padding.

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?

With a 100%-covered schema and an output schema handling return values, the description supplies exactly the missing pieces: atomicity guarantee, dist/source behavior, and sibling routing. Complete for a mutation tool of this complexity.

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 name/path/edits/target and the nested count semantics are already fully documented. The description reinforces 'literal' and the expected-match-count idea but adds no syntax or format detail beyond the schema, so baseline 3 applies.

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?

States a specific verb+resource ('Apply literal find/replace edits to one file') with the scope qualifier 'in one call' and explicitly routes multi-file work to apply_edits. An agent can distinguish it from siblings like apply_edits, write_source_files, and read_file without opening a schema.

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

Usage Guidelines5/5

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

Gives an explicit when-to-use rationale ('for small changes where uploading the whole file is wasteful'), names the alternative for the multi-file case ('Use apply_edits for several files'), and clarifies the dist-vs-source timing consequence with build_and_deploy. Nothing about tool selection is left to inference.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.