Skip to main content
Glama

update_file

Destructive

Replace a selected line range in an existing UTF-8 text file. Re-read the file between updates to avoid line-number shifts.

Instructions

Replace an inclusive 1-based line range in an existing UTF-8 text file. Line numbers shift after every edit, so read the file again between updates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath relative to the workspace root, or an allowed absolute path.
contentYesReplacement content; an empty string deletes the selected lines.
end_lineYesLast line to replace (inclusive).
start_lineYesFirst line to replace (1-based).
expected_sha256NoOptional SHA-256 returned by a previous read or write. The call fails if the file changed since then.
Behavior4/5

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

Annotations already declare destructiveHint=true, and the description adds valuable beyond that: it warns that line numbers shift after every edit and that the target must be an existing UTF-8 text file. This gives the agent important behavioral expectations without contradicting the annotations.

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 sentences with no filler: the first states the core action and constraints, the second delivers the critical caveat about line shifts. Every word earns its place.

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 destructive line-range mutation, the description covers the operation, file constraints, and the freshness caveat. The schema covers parameter semantics and the optional SHA check. It does not explain edge cases like start_line > end_line or return values, but these are not essential given the schema and annotations.

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 the schema already documents all parameters thoroughly, including optional expected_sha256. The description adds the line-shift caveat, which is relevant to start_line/end_line usage, but does not provide additional per-parameter detail beyond what the schema offers.

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?

The description states a specific operation: replacing an inclusive, 1-based line range in an existing UTF-8 text file. This clearly distinguishes it from sibling tools like write_file, which writes whole files, and apply_patch, which applies patches.

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 makes clear that the file must already exist and provides an important sequencing rule: read the file again between edits because line numbers shift. It does not explicitly mention alternatives or when not to use this tool, but the context is clear enough for an agent to decide when line-range editing is appropriate.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JonusNattapong/ChatGPTMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server