Skip to main content
Glama
SiroSuzume

MCP ts-morph Refactoring Tools

by SiroSuzume

rename_symbol_by_tsmorph

Renames any TypeScript or JavaScript symbol across the entire project by resolving all references via the type checker, ensuring safe and complete renaming.

Instructions

[ts-morph] Type-aware rename of a TypeScript/JavaScript symbol (function, variable, class, type, interface, enum, etc.) across the entire project.

When to use

  • Renaming any symbol that may be imported, re-exported, or referenced in other files.

  • Prefer this over manual Edit + grep / sed. Identifier-based search misses re-exports, JSX attribute usage, and matches unrelated same-name tokens. This tool resolves references via the type checker, so it is both safer and faster.

  • Even for a "local-only" symbol, this tool is the correct default: it costs nothing extra and guarantees no missed reference.

When NOT to use

  • Renaming a file or folder (and updating imports to it) -> use rename_filesystem_entry_by_tsmorph.

  • Moving a symbol to a different file -> use move_symbol_to_file_by_tsmorph.

  • Just looking up where a symbol is used (no rename) -> use find_references_by_tsmorph.

Critical constraints

  • position must point at the symbol's identifier (1-based line/column, as shown by editors). If the position lands on whitespace or a different token, the rename fails.

  • symbolName must match the identifier text at that position; it is used as a sanity check.

  • All paths (tsconfigPath, targetFilePath) MUST be absolute.

Tips

  • Run with dryRun: true first when the change spans many files, to preview the affected file list.

Result

Returns the list of modified (or to-be-modified, in dryRun) file paths, plus status and processing time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tsconfigPathYesPath to the project's tsconfig.json file.
targetFilePathYesPath to the file containing the symbol to rename.
positionYesThe exact position of the symbol to rename.
symbolNameYesThe current name of the symbol.
newNameYesThe new name for the symbol.
dryRunNoIf true, only show intended changes without modifying files.
Behavior4/5

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

No annotations are provided, so the description carries full burden. It describes the tool as type-aware, safe, and fast, and explains 'Critical constraints' about position and symbolName. However, it does not detail error handling or access permissions.

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

Conciseness5/5

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

The description is well-structured with clear sections and bullet points. It is concise yet comprehensive, with every sentence adding value. No redundant information.

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?

Given the tool's complexity (6 parameters, nested objects, no output schema), the description covers constraints, usage guidance, and result format thoroughly. It even includes a tip to use dryRun first.

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 100%, but the description adds significant value: it clarifies that position must be 1-based and point to the symbol's identifier, symbolName is a sanity check, paths must be absolute, and dryRun for preview. This goes beyond the schema.

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 description clearly states 'Type-aware rename of a TypeScript/JavaScript symbol across the entire project,' using specific verbs and resources. It distinguishes itself from sibling tools like rename_filesystem_entry_by_tsmorph and move_symbol_to_file_by_tsmorph by explicitly listing what it is not for.

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?

Dedicated 'When to use' and 'When NOT to use' sections provide explicit guidance, including when to prefer this over manual grep or sibling tools. It names alternatives (e.g., find_references_by_tsmorph) and clarifies when not to use it.

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/SiroSuzume/mcp-ts-morph'

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