Skip to main content
Glama
lin2000wl

Serena MCP Server

by lin2000wl

delete_lines

Remove specific lines from files after verifying them with read_file to ensure accurate file modifications.

Instructions

Deletes the given lines in the 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.

Implementation Reference

  • The main handler function for the 'delete_lines' tool in the SymbolManager class. It deletes the specified range of lines (0-based indexing, inclusive) from the given relative file path by wrapping the language server's delete operation in a file editing context manager.
    def delete_lines(self, relative_path: str, start_line: int, end_line: int) -> None:
        """
        Deletes lines in the given file.
    
        :param start_line: the 0-based index of the first line to delete (inclusive)
        :param end_line: the 0-based index of the last line to delete (inclusive)
        """
        start_col = 0
        end_line_for_delete = end_line + 1
        end_col = 0
        with self._edited_file(relative_path):
            start_pos = Position(line=start_line, character=start_col)
            end_pos = Position(line=end_line_for_delete, character=end_col)
            self._lang_server.delete_text_between_positions(relative_path, start_pos, end_pos)
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses the prerequisite verification step, which is a key behavioral trait beyond basic deletion. However, it lacks details on permissions, error handling, or what happens if lines are out of bounds, leaving some behavioral aspects unclear for a destructive operation.

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 two sentences with zero waste: the first states the core purpose, and the second adds crucial usage guidance. It is front-loaded with the main action and appropriately sized, making every sentence earn its place.

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?

Given the tool's complexity (a destructive file operation with 3 parameters) and no annotations or output schema, the description is mostly complete. It covers purpose, usage guidelines, and a key behavioral trait, but lacks details on return values or error conditions, which could be important for an agent invoking this tool.

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 fully documents the three parameters (relative_path, start_line, end_line). The description does not add any additional meaning or context about the parameters beyond what the schema provides, such as format examples or constraints, meeting the baseline for high schema coverage.

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 ('deletes') and resource ('lines in the file'), distinguishing it from sibling tools like 'replace_lines' or 'delete_memory'. It precisely defines what the tool does without being vague or tautological.

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?

The description explicitly states when to use this tool by specifying a prerequisite: 'Requires that the same range of lines was previously read using the `read_file` tool to verify correctness of the operation.' This provides clear guidance on the necessary context and distinguishes it from alternatives that might not require such 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