Skip to main content
Glama

edit_symbol

Destructive

Replace, insert, or delete Python functions, methods, and classes by name, with previews plus import and error checks.

Instructions

Replace, add or delete a function, method or class by name. Examples: edit_symbol(action="replace", name="Cart.total", source="def total(self): ..."), edit_symbol(action="insert", file_path="src/utils.py", name="parse", source="def helper(): ..."), edit_symbol(action="delete", name="legacy_parse").

  • action="replace": name (the symbol; dotted Class.method ok) and source (the complete new definition, decorators included: anything not given is dropped and the result says so). Re-indented to the old one's place, file style kept. A changed signature shows up as errors at call sites; to change a signature and its callers together use change_signature.

  • action="insert": source (the new definition) and file_path. position says where, relative to name: "after" (default when name is given) / "before" a symbol defined in the file (a method like Cart.total places it inside that class), "into" a class (appended to its body), or "end" of the file (default without name). PEP 8 blank lines, matching indentation. Refuses a name that already exists in that scope (use "replace").

  • action="delete": name only. Deletes only when nothing uses it, otherwise lists the users and writes nothing (force=true deletes anyway and shows what breaks). Imports that are the only remaining users are removed (prune_imports). Uses the type checker cannot see (strings, getattr, docs) are listed and the deletion is previewed. Comments directly above a definition are kept.

file_path narrows name when several symbols share it. imports (replace/insert) is a list of import statements the new code needs, added if missing. Writes when the new errors stay within max_new_errors (default 0, null = no limit); else previews with an id for apply_edit; apply=false always previews. undo_edit reverts.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "action": "<action>"
    },
    "name": "edit_symbol"
  }
}

Input Schema

NameRequiredDescriptionDefault
nameNo
applyNo
forceNo
actionYes
sourceNo
importsNo
positionNo
file_pathNo
prune_importsNo
max_new_errorsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.4

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and readOnlyHint=false, and the description goes well beyond them: delete lists users and writes nothing unless forced, import pruning behavior, type-checker-invisible usages are surfaced, comments above definitions are preserved, and writes are gated by max_new_errors with preview fallback. What it does not disclose is the shape of the returned preview/result payload, though it names the key affordances.

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?

Front-loaded with the verb and three runnable examples, then structured as one bullet per action, which suits a three-mode tool with ten parameters. A few clauses are dense or awkward ("anything not given is dropped and the result says so"), costing it the top mark.

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?

For a destructive, ten-parameter editing tool with no output schema, this covers preconditions, safety gates, and the preview/apply workflow. It stops short of describing the return payload's fields (error lists, preview ids, what a successful write reports), which an agent would otherwise need.

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

Parameters5/5

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

Schema description coverage is 0%, so the description carries the full burden and does: name (dotted Class.method allowed), source (complete definition, decorators included, omitted parts dropped), file_path (disambiguates duplicate names), position (with per-value meaning and defaults), imports, max_new_errors (0 default, null = unlimited), apply, force, prune_imports all get semantics the bare schema lacks.

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?

Opens with a specific verb set and target: "Replace, add or delete a function, method or class by name," then enumerates the three actions with concrete calls. It is immediately distinguishable from siblings like rename_symbol or change_signature, which it names explicitly.

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?

Gives explicit routing: use change_signature when a signature change must propagate to callers, use apply_edit with the returned preview id to commit, use undo_edit to revert. Each action branch states its own preconditions (insert refuses existing names, delete requires unused symbols unless force).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.