Skip to main content
Glama
N0moreher0
by N0moreher0

Edit file

project_edit_file

Edit a file by replacing exact text sections, using one old/new pair or multiple edits and an optional SHA-256 guard to prevent overwriting unintended changes.

Instructions

Edit a file by exact text replacement: one old_text/new_text pair, or edits[] for multiple sections. Use when: change one or a few text sections whose exact content you know; pair with expected_sha256 to guard against blind overwrites. Avoid when: the whole file must change (project_write_file), or you have not read the file to know old_text. Speed: fast; clears the read/list/search cache for the affected path. Output: file_written: replacements, sha256_before/after. Batch-safe: no

Input Schema

NameRequiredDescriptionDefault
editsNo
new_textNo
old_textNo
replace_allNo
relative_pathYesPath inside the workspace (relative, or absolute inside the workspace)
expected_sha256No

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.1

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare mutation, non-idempotent, non-destructive status, so the description's job is to add non-obvious traits — it does: cache invalidation for the affected path, speed profile, non-batch-safety, and the returned file_written/sha256_before-after fields. Missing only an explicit statement of failure behavior when old_text isn't found, which keeps it from a 5.

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?

Labeled clauses (Use when / Avoid when / Speed / Output / Batch-safe) front-load the core mechanism and route quickly. Efficient, though the telegraphic 'Batch-safe: no' phrasing is slightly cryptic versus prose.

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?

No output schema exists, but the description names the return fields so the agent knows what comes back, and it covers caching side effects and the primary param meanings. Reasonably complete for a 6-param mutation tool, with the replace_all gap the main omission.

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 only 17%, so the description must compensate; it explains expected_sha256's purpose ('guard against blind overwrites') and the edits[] vs single-pair relationship, which is genuinely useful. However replace_all and the multi-section maxItems:64 limit are never explained, leaving key semantics undocumented.

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 ('Edit a file by exact text replacement') plus the two supported mechanisms (single old_text/new_text pair or edits[] batch). It explicitly contrasts with project_write_file, so the agent can pick this tool over its closest sibling without reading either 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?

Explicit 'Use when' (one or a few known text sections, pair with expected_sha256) and 'Avoid when' (whole-file rewrite -> project_write_file; haven't read the file for old_text). Alternatives and exclusions are named directly.

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