Skip to main content
Glama
sangingeum
by sangingeum

file_replace_lines

Destructive

Replace an inclusive 1-based line range with new content, preview changes with a dry run, and keep each edit undoable while preserving file formatting.

Instructions

Replace an inclusive 1-based line range and return operation_id and undo_available.

    Use this for genuinely positional work; file_replace_text is cheaper when
    the line numbers are not already known. Out-of-range references are
    refused, never clamped. The file's newline convention and byte-order mark
    are preserved, and a replacement without a trailing newline does not fuse
    lines. dry_run returns a unified diff preview and writes nothing.
    Otherwise the operation is recorded and undoable.
    

Input Schema

NameRequiredDescriptionDefault
pathYes
dry_runNo
end_lineYes
start_lineYes
replacementYes
expected_hashNo
expected_contentNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.8

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already flag destructive/not-idempotent, and the description adds substantial beyond-schema behavior: out-of-range is refused rather than clamped, newline convention and BOM are preserved, no line fusion without trailing newline, dry_run writes nothing, and successful writes are recorded and undoable. It omits what happens when expected_hash/expected_content preconditions fail, which is the one behavioral gap.

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?

Front-loads the action and return values, and each sentence adds a distinct fact. Slightly longer than necessary and the newline-fusion sentence is a touch verbose, but nothing is wasted.

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?

With no output schema, the description helpfully names the return contract (operation_id, undo_available, unified diff on dry_run) and the write/undo lifecycle. It is only incomplete around the precondition parameters and their failure behavior.

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 0%, so names alone carry the parameters. The description rescues start_line/end_line (inclusive, 1-based, out-of-range refused) and dry_run (returns a unified diff, writes nothing), but says nothing about expected_hash or expected_content, leaving two concurrency-guard parameters entirely unexplained.

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 precise verb and resource — replace an inclusive 1-based line range — and immediately distinguishes itself from the sibling file_replace_text by cost/positional semantics. An agent can tell exactly which file-edit sibling to pick.

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?

Explicitly names the alternative (file_replace_text) and the condition that should redirect the agent there ('when the line numbers are not already known'), plus the dry_run prerequisite path. No inference required for tool selection.

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