Skip to main content
Glama

Edit Lines

edit_lines
Destructive

Edit files by line number to replace, insert, or delete lines. Use when you know the location but not the exact text.

Instructions

Edit a file by line numbers: replace a line range, insert text, or delete lines. Use read_file with line_numbers=true first to get the exact numbers. Prefer edit_file when you can copy the exact text; use this when you know the location but not the exact characters. IMPORTANT: line numbers shift after every edit — re-read the file before making another line-based edit.

Args:

  • path (string): File to edit.

  • mode ('replace'|'insert_before'|'insert_after'|'delete'): What to do (default 'replace').

  • start_line (number): First line affected (1-based, inclusive).

  • end_line (number): Last line affected (default start_line). Ignored for inserts.

  • new_text (string): The new lines (required except for delete).

  • dry_run (boolean): Preview the change without writing (default false).

Returns a confirmation plus the edited region with line numbers.

Example: { "path": "~/app.py", "mode": "replace", "start_line": 12, "end_line": 14, "new_text": "def main():\n run()" }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile to edit
modeNoEdit operationreplace
start_lineYesFirst line (1-based)
end_lineNoLast line (default start_line)
new_textNoReplacement/inserted text (not used for delete)
dry_runNoPreview without writing
Behavior5/5

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

Annotations declare destructiveHint=true and readOnlyHint=false. Description adds crucial behavioral detail: line numbers shift after every edit, requiring re-read before next edit. Also notes dry_run preview mode.

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?

Well-structured with sections, bullet points for args, and an example. Slightly lengthy but appropriate given the tool's complexity. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no output schema, description is complete: it explains workflow (pre-read), return value (confirmation + edited region), and edge cases (line shift). No missing pieces.

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?

Schema covers all 6 parameters (100% coverage). Description adds semantic value by explaining mode behaviors (end_line ignored for inserts, new_text not used for delete) and includes an example. Slightly above baseline.

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?

Clearly states 'Edit a file by line numbers' and enumerates operations (replace, insert, delete). Explicitly distinguishes from sibling edit_file by specifying when to use each ('Prefer edit_file when you can copy exact text').

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?

Provides explicit when-to-use advice: 'Use read_file with line_numbers=true first to get exact numbers' and warns about line number shifting. Also gives alternative tool guidance (edit_file for exact text copies).

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/highercomve/mcptools'

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