Skip to main content
Glama
JEL-LL

file_utils MCP

by JEL-LL

edit_file_range

Replace a contiguous range in a file using anchor text or line numbers. Optionally require a content hash to avoid overwriting conflicting changes.

Instructions

Replace a contiguous span of a file with new content, addressed by anchors (primary) or line numbers (fallback). Optional expected_content_hash guards against stale edits; writes atomically. IMPORTANT: the from_anchor line and the to_anchor line are BOTH included in the replaced span — they are consumed, not preserved. If you want to keep the boundary lines, you must include them verbatim in new_content. Common mistake: anchoring on the last line of content you want to keep and then omitting it from new_content — that line will be silently dropped.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute or workspace-relative path to the file.
to_lineNo1-based end line, inclusive. Supports negative indexing. Mutually exclusive with to_anchor.
encodingNoFile encoding. Default: utf-8. Pass utf-8-sig to strip a BOM.utf-8
from_lineNo1-based start line. Supports negative indexing (-1 = last line). Mutually exclusive with from_anchor.
to_anchorNoStop at the matching line after the start (inclusive). Mutually exclusive with to_line.
from_anchorNoStart at the matching line (inclusive, substring, case-sensitive). Mutually exclusive with from_line.
new_contentYesReplacement text, written byte-for-byte after encoding. The caller is responsible for correct line endings and trailing newline.
project_rootNoSets (and remembers) the project root for resolving relative paths for this and subsequent calls in the session.
to_anchor_totalNoExpected total occurrences of to_anchor after the start. Optional: if omitted, the ambiguity guard is skipped and the to_anchor_occurrence-th match after the start is selected. Supply a value to re-enable the guard (ANCHOR_AMBIGUOUS on mismatch).
from_anchor_totalNoExpected total occurrences of from_anchor in the file.
to_anchor_occurrenceNoWhich occurrence of to_anchor (after the start) to use.
expected_content_hashNoSHA-256 hex digest of the span's current raw bytes (as returned by read_file_range). If provided and the current span does not match, the edit is rejected with HASH_MISMATCH.
from_anchor_occurrenceNoWhich occurrence of from_anchor to use (1-based).
Behavior4/5

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

With no annotations, the description takes on full behavioral disclosure. It discloses atomic writes, the inclusive consumption of both anchor lines, and a common mistake, which is substantial context beyond basic function. It does not cover error conditions or permissions, but the critical behavioral traps are addressed.

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?

The description is three sentences long, front-loaded with the primary purpose, followed by a high-value warning and a concrete mistake example. Every sentence provides meaningful information with no redundancy.

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 moderately complex edit tool with a complete parameter schema, the description covers the central behavioral risk and provides enough context to select and invoke it correctly. It lacks mention of error types or file prerequisites, but the given information is sufficient for most use cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema covers 100% of parameters, so the baseline is 3. The description adds value by explaining expected_content_hash's role as a stale-edit guard and by emphasizing that from_anchor/to_anchor lines are included in the replacement, deepening understanding beyond the schema descriptions.

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 'Replace a contiguous span of a file with new content' with a specific verb and resource, and clearly distinguishes itself from sibling insert/prepend/append tools. The mention of anchors and line numbers further defines the tool's scope.

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 context that this tool replaces a span is clear, implying use over insert/append, but it does not explicitly name alternatives or state when not to use it. The guidance on anchors versus line numbers ('primary' and 'fallback') provides useful selection criteria.

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/JEL-LL/file_utils'

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