Skip to main content
Glama
GeminiDesk MCP
by LZ7TOP

Patch File by Exact Line Range

fs_patch_lines

Replace or delete exact 1-based line ranges in a file; pass an empty string to remove the selected lines. Use with line-reading or outline tools for precise code edits.

Instructions

按精确 1-based 起止行号替换或删除代码行(可配合 fs_read_lines / fs_outline 使用)。

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "path": "<path>",
      "startLine": "<startLine>",
      "endLine": "<endLine>",
      "newContent": "<newContent>"
    },
    "name": "fs_patch_lines"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYes目标文件路径
endLineYes结束行号(1-based,含)
startLineYes起始行号(1-based,含)
newContentYes替换后的新文本(传空字符串则删除该区间行)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

B3.3/5.0
Behavior2/5

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

With no annotations, the description must carry the full behavioral burden. It discloses that the operation mutates (replace or delete) and that an empty newContent deletes the range, but says nothing about irreversibility, backups, atomicity, what happens when startLine/endLine exceed file length, or whether the tool reports the resulting line count.

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?

A single sentence front-loads the operation and scope, with the companion tools confined to one short parenthetical. Nothing is redundant or padded.

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

Completeness3/5

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

For a four-parameter destructive mutation with no annotations and no output schema, the description covers what the tool does but not the failure modes or post-state an agent needs before calling it. Adding a sentence on range validation and on verifying results via fs_read_lines would close the gap.

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 100%, with path, startLine, endLine, and newContent each already documented including the 1-based inclusive semantics and the empty-string deletion rule. The description only restates the 1-based range concept, adding no format, ordering, or edge-case meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource — replace or delete code lines by exact 1-based start/end line range — which naturally separates it from string-matching editors like fs_edit_file. It stops short of naming that alternative explicitly, so the differentiation is inferable rather than stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The parenthetical suggests a workflow with fs_read_lines / fs_outline to obtain line numbers first, which implies 'read the lines, then patch by range'. There is no explicit when-to-use versus fs_edit_file / fs_multi_edit, and no stated preconditions such as 'file must exist' or 'range must be within the file'.

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