Skip to main content
Glama

rename_symbol

Destructive

Rename Python symbols everywhere they are used, type-check the result before writing, and include linked overrides or Protocol members to prevent broken references.

Instructions

Rename a symbol everywhere it is used, type-checking the result before writing it.

Example: rename_symbol(name="UserService.create_user", new_name="register_user"). Give name (dotted Class.method accepted; file_path narrows it) or file_path + line + column (1-indexed). Use parameter="x" with a function's name to rename one of its parameters (keyword arguments at call sites follow).

Built on ty's rename (imports, aliases, keyword arguments) plus what ty misses: with linked=true (default) overriding methods in subclasses, super().name() calls, and Protocol members together with the classes that satisfy them are renamed as one, since renaming only one side would silently break the override or the conformance. The result lists every extra member it included, and the places still using the old name that the type checker could not link (untyped attribute accesses, strings, comments, docs).

Writing: apply=true (default) writes when the new errors are within max_new_errors (default 0); otherwise nothing is written and you get a preview 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": {
      "new_name": "<new_name>"
    },
    "name": "rename_symbol"
  }
}

Input Schema

NameRequiredDescriptionDefault
lineNo
nameNo
applyNo
columnNo
linkedNo
new_nameYes
file_pathNo
parameterNo
allow_largeNo
max_new_errorsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.4

TDQS

A4.4/5.0
Behavior5/5

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

Annotations already flag destructiveHint=true and non-idempotent, and the description adds the important mechanics behind that: edits are type-checked first and are only written when new errors stay within max_new_errors (default 0), otherwise nothing is written. It also discloses the linked-rename expansion (overrides, super() calls, Protocol members) and that the result enumerates extra members plus unlinked stale references — exactly the risk information a destructive tool needs.

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 action and an executable example, then organized by targeting, linking, and writing semantics — every block maps to a real decision. Some sentences are dense and parenthetical-heavy (the ty/linked explanation), but for a 10-parameter destructive tool the length is largely earned.

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?

No output schema exists, yet the description explains what the result contains (included extra members, unlinked old-name sites) and the full write/preview/undo lifecycle. The only substantive omission is allow_large, which matters for a tool whose failure mode is refusing or balking at large rewrites.

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?

With 0% schema description coverage, the description carries the load and mostly succeeds: it explains name form, the 1-indexed line/column, parameter targeting, linked (default true), apply (default true), max_new_errors (default 0), and shows a concrete call example. The one gap is allow_large, which appears in the schema with a default of false but is neither explained nor mentioned, leaving an agent unsure when large renames are refused.

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?

"Rename a symbol everywhere it is used, type-checking the result before writing it" is a specific verb+resource with an added quality guarantee, and it is distinct from change_signature or edit_symbol in intent. It never explicitly contrasts itself with those siblings, so an agent must infer the boundary from behavior alone.

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?

It spells out three distinct ways to target the symbol (dotted name, name+file_path, file_path+line+column), when to use parameter= for a function parameter, and the exact decision rule between preview and write. It also names the follow-on tools (apply_edit for a preview id, undo_edit to revert), so the agent knows the alternatives and when each applies.

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