Skip to main content
Glama
lin2000wl

Serena MCP Server

by lin2000wl

insert_at_line

Insert content at a specific line in a file to make targeted code edits without replacing entire sections, using line-based positioning for precise modifications.

Instructions

Inserts the given content at the given line in the file, pushing existing content of the line down. In general, symbolic insert operations like insert_after_symbol or insert_before_symbol should be preferred if you know which symbol you are looking for. However, this can also be useful for small targeted edits of the body of a longer symbol (without replacing the entire body).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relative_pathYesThe relative path to the file.
lineYesThe 0-based index of the line to insert content at.
contentYesThe content to be inserted.

Implementation Reference

  • Handler function for the 'insert_at_line' tool in SymbolManager class. Inserts content at a specified line (0-based) in the given relative_path file using the language server's insert_text_at_position.
    def insert_at_line(self, relative_path: str, line: int, content: str) -> None:
        """
        Inserts content at the given line in the given file.
    
        :param line: the 0-based index of the line to insert content at
        :param content: the content to insert
        """
        with self._edited_file(relative_path):
            self._lang_server.insert_text_at_position(relative_path, line, 0, content)
Behavior3/5

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

With no annotations provided, the description carries the full burden. It explains the insertion behavior ('pushing existing content down') and mentions use cases, but lacks details on error handling (e.g., what happens if the line index is out of bounds), file permissions, or whether the operation is atomic. It provides basic behavioral context but misses advanced operational traits.

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 efficiently structured in three sentences: the first states the core functionality, the second provides usage guidance relative to alternatives, and the third adds a specific use case. Every sentence adds value without redundancy, making it front-loaded and appropriately sized.

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 moderate complexity (file editing with line-based insertion), no annotations, and no output schema, the description does well by explaining the operation, comparing to siblings, and suggesting use cases. However, it lacks details on error conditions or return values, leaving some gaps in full contextual understanding.

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 three parameters thoroughly. The description adds no additional parameter semantics beyond what the schema provides (e.g., no clarification on line numbering conventions or content formatting). The baseline score of 3 reflects adequate coverage via the schema alone.

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 ('inserts the given content at the given line') and resource ('in the file'), with precise mechanics ('pushing existing content of the line down'). It explicitly distinguishes from sibling tools like 'insert_after_symbol' and 'insert_before_symbol', making the purpose unambiguous.

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 provides explicit guidance on when to use alternatives ('symbolic insert operations... should be preferred if you know which symbol you are looking for') and when this tool is appropriate ('small targeted edits of the body of a longer symbol without replacing the entire body'). This clearly defines the tool's niche relative to siblings.

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