Skip to main content
Glama
lin2000wl

Serena MCP Server

by lin2000wl

replace_lines

Replace specific line ranges in files after verifying them with read_file, enabling precise code modifications in Serena MCP Server's coding toolkit.

Instructions

Replaces the given range of lines in the given file. Requires that the same range of lines was previously read using the read_file tool to verify correctness of the operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relative_pathYesThe relative path to the file.
start_lineYesThe 0-based index of the first line to be deleted.
end_lineYesThe 0-based index of the last line to be deleted.
contentYesThe content to insert.
Behavior3/5

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

No annotations are provided, so the description carries full burden. It discloses the critical behavioral trait that prior reading with 'read_file' is required for correctness, which is essential for safe operation. However, it doesn't mention potential side effects like file locking, error handling, or whether changes are reversible, leaving gaps for a mutation tool.

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, front-loaded with the core purpose and followed by a crucial prerequisite. Every sentence earns its place with no wasted words, making it efficient and easy to parse.

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 mutation tool with no annotations and no output schema, the description is mostly complete: it clearly states the purpose, usage guidelines, and a key behavioral requirement. However, it lacks details on return values or error conditions, which could be important given the tool's complexity and potential for data loss.

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. The description adds no additional meaning beyond the schema, such as explaining how 'start_line' and 'end_line' define the range or how 'content' interacts with the replacement. Baseline 3 is appropriate when schema does the heavy lifting.

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 clearly states the specific action ('replaces'), the resource ('range of lines in the given file'), and distinguishes it from siblings like 'delete_lines', 'insert_at_line', and 'replace_symbol_body' by specifying it replaces a range with new content rather than deleting, inserting at a single line, or replacing symbol bodies.

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?

It explicitly states when to use this tool: 'Requires that the same range of lines was previously read using the `read_file` tool to verify correctness of the operation.' This provides clear prerequisites and distinguishes it from alternatives like 'insert_at_line' or 'replace_symbol_body' by emphasizing the need for prior verification.

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/lin2000wl/Serena-cursor-mcp'

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