insert_before_symbol
Add content before a specified symbol's definition in a file, such as classes, functions, or imports, using semantic code editing tools on the Serena MCP Server.
Instructions
Inserts the given body/content before the beginning of the definition of the given symbol (via the symbol's location). A typical use case is to insert a new class, function, method, field or variable assignment. It also can be used to insert a new import statement before the first symbol in the file.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
body | Yes | The body/content to be inserted before the line in which the referenced symbol is defined. | |
name_path | Yes | Name path of the symbol before which to insert content (definitions in the `find_symbol` tool apply). | |
relative_path | Yes | The relative path to the file containing the symbol. |
Input Schema (JSON Schema)
{
"properties": {
"body": {
"description": "The body/content to be inserted before the line in which the referenced symbol is defined.",
"title": "Body",
"type": "string"
},
"name_path": {
"description": "Name path of the symbol before which to insert content (definitions in the `find_symbol` tool apply).",
"title": "Name Path",
"type": "string"
},
"relative_path": {
"description": "The relative path to the file containing the symbol.",
"title": "Relative Path",
"type": "string"
}
},
"required": [
"name_path",
"relative_path",
"body"
],
"title": "applyArguments",
"type": "object"
}