Skip to main content
Glama

Edit part of a file

edit_block
Destructive

Replace exact text inside an existing text file. Safer than rewriting the whole file: it fails, and changes nothing, if old_string is not found or appears a different number of times than expected_replacements (default 1).

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": {
      "path": "<path>",
      "old_string": "<old_string>",
      "new_string": "<new_string>"
    },
    "name": "edit_block"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYes
deviceNoDevice name. Optional when the account has only one online device.
new_stringYesText to put in its place.
old_stringYesExact text to find (including whitespace). Must not be empty.
expected_replacementsNoHow many times old_string should appear. Default 1.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior5/5

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

Adds substantial context beyond the destructiveHint annotation: it discloses the atomic no-op-on-failure guarantee and the precise matching semantics tied to expected_replacements, which is exactly the behavioral detail an agent needs on a destructive edit.

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?

Two tight sentences; the safer-than-alternative claim and the failure semantics are front-loaded with no filler.

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?

Complete for a 5-param destructive edit tool with no output schema, since annotations cover safety and the description covers failure behavior. It could mention the multi-device 'device' parameter or permissions, but the essentials are present.

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 80%, so the schema already documents path, old_string, new_string, and expected_replacements well. The description reinforces the old_string matching rule and default count but adds no new parameter syntax 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?

States a specific verb and resource ('Replace exact text inside an existing text file') and distinguishes itself from the obvious sibling write_file by framing itself as a targeted alternative to 'rewriting the whole file'.

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?

Clearly implies when to prefer this over write_file ('safer than rewriting the whole file'), but never explicitly names write_file or states when not to use this tool (e.g., for wholesale rewrites).

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.

Resources