Skip to main content
Glama
Raheem-19

Serena MCP Server

by Raheem-19

insert_before_symbol

Insert new code before a symbol's definition to add functions, classes, or imports at precise locations.

Instructions

Inserts the given 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; or a new import statement before the first symbol in the file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyYesThe body/content to be inserted before the line in which the referenced symbol is defined.
name_pathYesName path of the symbol before which to insert content (definitions in the `find_symbol` tool apply).
relative_pathYesThe relative path to the file containing the symbol.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It indicates a mutation (inserts content) but does not explain side effects, such as how existing content is shifted, whether the symbol must exist, error behavior, or any permissions required. This is a significant gap 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?

The description is two sentences with no fluff. It front-loads the core action and then gives a concrete example of usage. Every word earns its place, making it concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has moderate complexity with 3 required parameters and no annotations. The description explains the core use case well, but it omits important behavioral details such as prerequisites (e.g., file and symbol must exist) and potential impacts on surrounding code. The presence of an output schema reduces the need to describe return values, but the behavioral gaps leave the description incomplete for an agent to use it effectively.

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 all parameters are already described in the schema. The description adds little over the schema—it refers to 'given content' and 'given symbol' but does not elaborate on the specific semantics of `name_path`, `relative_path`, or `body` beyond what the schema already provides. Baseline 3 is appropriate when the 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 action: 'Inserts the given content before the beginning of the definition of the given symbol.' It uses a specific verb and resource, and the placement 'before' distinguishes it from the sibling tool `insert_after_symbol`. Typical use cases are also listed, reinforcing purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use the tool (e.g., inserting a class, function, or import statement before a symbol). However, it does not explicitly mention when not to use it or point to alternatives like `insert_after_symbol` or `replace_symbol_body`. The usage context is clear but lacks explicit exclusions.

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/Raheem-19/serena-optimized'

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