Skip to main content
Glama

Insert Before Symbol

insert_before_symbol
Destructive

Inserts code content before a specific symbol definition in a file, enabling precise code modifications like adding imports, classes, or functions at targeted 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
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.
bodyYesThe body/content to be inserted before the line in which the referenced symbol is defined.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

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

Annotations already declare destructiveHint=true and readOnlyHint=false, so the agent knows this is a mutating operation. The description adds useful context about 'via the symbol's location' and typical use cases, but doesn't elaborate on potential side effects, error conditions, or how it interacts with the file system beyond what annotations provide.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences: the first states the core functionality, the second provides typical use cases. Both sentences add value without redundancy. It could be slightly more front-loaded by integrating the use case into the main statement.

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 destructive nature (annotations), 3 fully documented parameters (schema), and existence of an output schema, the description provides adequate context. It covers the core operation and typical use cases, though additional behavioral details about error handling or constraints would make it more complete for a destructive editing 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?

With 100% schema description coverage, all parameters are well-documented in the schema itself. The description mentions 'given content' and 'given symbol' which map to 'body' and 'name_path', but adds no additional semantic context beyond what the schema already provides about parameter meaning or usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('inserts') and target ('before the beginning of the definition of the given symbol'), with specific examples of typical use cases (classes, functions, imports). It distinguishes from sibling 'insert_after_symbol' by specifying 'before', but doesn't explicitly contrast with other editing tools like 'replace_content' or 'replace_symbol_body'.

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

Usage Guidelines3/5

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

The description provides a typical use case context (inserting new code elements or imports) which implies when to use it, and the 'before' wording distinguishes it from 'insert_after_symbol'. However, it lacks explicit guidance on when NOT to use it or alternatives for different editing scenarios among the many sibling tools.

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/chrisgreenx-ctrl/serena'

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