Skip to main content
POST
Rename Symbol

Overview

Rename a Python symbol (function, class, variable, parameter, etc.) across your entire workspace. This tool finds all references and provides the exact text edits needed to rename safely.

Request

string
required
File URI (e.g., file:///workspace/main.py)
number
required
Line number where symbol appears (0-indexed)
number
required
Character position (0-indexed)
string
required
New name for the symbol

Response

object
Map of file URIs to arrays of text edits
number
Total number of edits across all files
number
Number of files that will be modified

Example Request

Example Response

Use Cases

Rename Function

Rename Class

Rename Variable

Rename Parameter

What Gets Renamed

Definition

The original symbol definition

All References

Every place the symbol is used

Imports

Import statements are updated

String Literals

Not renamed (only code references)

Safety Features

Scope-Aware: Only renames symbols in the same scope
Conflict Detection: Warns if new name conflicts with existing symbols
Atomic Operation: All files updated together or none at all
Preview First: Get all edits before applying

Applying Edits

The rename tool returns edits but doesn’t apply them automatically. You need to apply the changes:

Validation

Before renaming, the tool validates:

Error Responses

Rate Limits

Rename operations are expensive. Use sparingly and cache results.

Best Practices

Preview First: Always review the changes before applying them
Use Version Control: Commit before renaming so you can revert if needed
Test After: Run tests after renaming to catch any issues
Atomic Apply: Apply all edits at once, not file by file

Get References

Preview what will be renamed

Get Definition

Find the symbol’s definition

Apply Workspace Edit

Apply text edits to files

Get Diagnostics

Check for errors after renaming