Skip to main content
Glama
lin2000wl
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)

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