Skip to main content
Glama

rename_symbol

Rename a Java symbol across a project by generating compiler-accurate text edits for all occurrences, with file renames and conflict warnings returned for you to apply.

Instructions

Rename a symbol (variable, method, field, class, etc.) across the project.

Returns text edits for all occurrences that need to be changed. The caller should apply these edits to perform the rename.

USAGE: Position on symbol, provide new name OUTPUT: List of text edits to apply, and the files to rename

Each edit replaces exactly the symbol's simple name, also where a reference is qualified (an import, a static import, a qualified name in code or in a Javadoc link). An annotation element written as the single value of its annotation, @Tag("x"), is named before that value: @Tag(label = "x").

A type is renamed with its explicit constructors. A top-level type whose file is named after it renames that file: renamedFiles lists it, as {filePath, newFilePath}; apply the edits (editsByFile is keyed by the current paths), then rename the file. renamedFiles is present only when a file is renamed. A top-level type renamed to the name of a file that already exists in its folder is refused: INVALID_PARAMETER.

A method is renamed together with every method it overrides, every method that overrides it and every method a subtype inherits together with it, in and after lambda bodies included, and every call of them. A method of a class file, or a method renamed together with one, is refused, naming that method: it cannot be renamed.

A rename JDT's rename refactoring finds a conflict for is refused: INVALID_PARAMETER for newName, naming every conflict in JDT's words, by the place each names (a name another declaration in scope already has, a reference the renamed element would take over or lose, a unit with syntax errors, a native method, a static import of the new name). The conflicts of a type, a field, a local variable, a type parameter and a private, static or constructor method are those JDT's rename processors find; those of any other method are the conditions of JDT's method rename (RenameMethodProcessor, RenameVirtualMethodProcessor) checked on the Java model's own hierarchy, local and anonymous classes in lambda bodies included. JDT's warnings on a rename that goes ahead (such as a discouraged name, a constructor's name, or a method of the hierarchy with the new name and other parameter types) are listed in warnings, by place; warnings is present only when there is one.

A place JDT's search reports but cannot confirm as a reference, where a type or name does not resolve, is never edited: potentialMatches lists every one, to review by hand. A position on a name the compiler cannot resolve has no symbol to rename: SYMBOL_NOT_FOUND.

IMPORTANT: Uses ZERO-BASED coordinates.

potentialMatches, present only when there are any, holds the places JDT's search reports as possible matches but cannot confirm, because a type or name there does not resolve (a missing dependency or a compile error): count is their exact number, and locations lists them, as many as the results it stands beside may list. They are never counted or listed as results.

A module is renamed in its declaration and its references. A package (renamed with its folder, which no text edit does), a package declaration, an import declaration or the import list is refused: INVALID_PARAMETER for position, naming it. So is a type, field or method of a library (binary), which has no source to edit.

Requires load_project to be called first.

Input Schema

NameRequiredDescriptionDefault
lineYesZero-based line number
columnYesZero-based column number
newNameYesNew name for the symbol
filePathYesPath to source file containing the symbol

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.3.4
  2. Removedv1.3.3
  3. First observedv1.2.0

TDQS

A4.4/5.0
Behavior5/5

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

With zero annotations provided, the description carries the full behavioral burden and does so exhaustively: it discloses the return shape (text edits to apply, renamedFiles keyed structure), error codes (INVALID_PARAMETER, SYMBOL_NOT_FOUND), which renames are refused and why, warnings semantics, and the zero-based coordinate convention. This is far beyond what the schema conveys.

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

Conciseness2/5

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

The purpose is front-loaded, but the body runs several hundred words of JDT-implementation detail (RenameMethodProcessor, RenameVirtualMethodProcessor, hierarchy checks) that is well past what an agent needs to select and call the tool. potentialMatches is effectively described twice, signaling redundancy rather than economy.

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

Completeness5/5

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

There is no output schema, so the description must explain return values — and it does, covering the edit list, renamedFiles, warnings, and potentialMatches. For a refactoring tool of this complexity, nothing needed to invoke it correctly is missing.

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 description coverage is 100%, so the baseline is 3. The description adds real meaning beyond the schema: it explains what newName must satisfy (conflicts are refused), that position on unresolvable names yields SYMBOL_NOT_FOUND, and that positions on packages/imports are refused. This exceeds the baseline.

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 opening states a specific verb+resource+scope: 'Rename a symbol (variable, method, field, class, etc.) across the project.' This clearly distinguishes it from siblings like change_method_signature or move_type_to_new_file, which the agent can rule out without opening schemas.

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 invocation context ('USAGE: Position on symbol, provide new name') and a hard precondition ('Requires load_project to be called first'). It does not, however, name an alternative refactoring tool or give explicit when-not-to-use conditions beyond the refusal cases.

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