Skip to main content
Glama

edit_leading_comment

Add, replace, or remove the leading comment block above a named function or class in your code.

Instructions

Edit the contiguous leading-comment block above a named symbol. One tool covering three operations on the same comment block.

Supported values for op:

  • "add": Insert a new comment block above the symbol. Requires comment. Raises if a leading comment already exists and would be pushed down as a separate block.

  • "replace": Replace the existing leading comment block with comment; if no leading comment exists, inserts one. Requires comment.

  • "remove": Delete the existing leading comment block. comment is ignored.

The comment must include the language's comment marker (# for Python/Ruby/YAML/TOML, // or /* ... */ for JS/TS/C/C++/Go/Java, /** ... */ Javadoc for Java). Supports multi-line C-style block comments as a single contiguous run.

Use this when: You want to document, update, or delete a leading comment on a function/class/method. Don't use this when: You want a Python docstring (which lives inside the function body) -> use replace_docstring. You want to edit text inside the function body itself -> use replace_in_body.

Example: target="LRUCache.get", op="add", comment=" # Retrieve an item by key, returning None if absent"

target="LRUCache.get", op="replace",
comment="    # Retrieve an item from the cache"

target="LRUCache.get", op="remove"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
targetYes
opYes
commentNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

No annotations provided, so description carries full burden. It details behavior for each op: add raises if comment exists, replace inserts if none, remove ignores comment. Also notes comment marker requirements. Misses potential error conditions or idempotency, but covers core behavior well.

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?

Reasonably concise given the three-operation scope. Structured with sections for op details, comment syntax, usage guidelines, and examples. Each sentence adds value, though could be slightly trimmed without losing clarity.

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?

With an output schema present, description doesn't need return value details. Covers operation semantics, comment syntax prerequisites, and usage conditions. Does not mention concurrency or performance, but acceptable for a single-file editing tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, but description thoroughly explains 'op' with three enumerated values and their semantics. Requires 'comment' only for add/replace, demonstrated in examples. Lacks detail on 'file_path' and 'target' formats, but examples and context imply they follow symbol naming conventions.

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?

Clearly states the tool edits the contiguous leading-comment block above a named symbol, with three operations (add/replace/remove). Distinguishes from sibling tools like replace_docstring and replace_in_body by explicitly contrasting use cases.

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?

Explicitly says when to use ('You want to document, update, or delete a leading comment') and when not to use ('You want a Python docstring' -> use replace_docstring; 'edit text inside the function body' -> use replace_in_body). Provides clear alternatives.

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/kambleakash0/ast-editor'

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