Labsco
MCP SERVER

ts-morph Refactoring Tools

by SiroSuzume

Rename a symbol, move a file, relocate a declaration or change a function's parameters across a TypeScript project, with the type checker updating every call site and import path.

Code Generation, Scaffolding & MigrationVerified
Summary
Refactors that a type checker performs, in place of an edit-and-grep pass that misses re-exports.

The distinction that matters is between the tools that rewrite the project and the ones that only report: find_references_by_tsmorph, find_unused_exports_by_tsmorph and get_type_at_position_by_tsmorph answer questions without touching a file, which makes them the natural first call before a rename or a signature change. Scope is a single project per call — every tool takes tsconfigPath — so a monorepo is handled a package at a time. The rewriting tools each accept dryRun, and rename_filesystem_entry_by_tsmorph also takes timeoutSeconds, which suggests large moves are expected to run long.

What it is

A ts-morph refactoring server for one TypeScript or JavaScript project, addressed by tsconfigPath: eight tools that either rewrite the project through the type checker or report on it.

What you get
  • Project-wide symbol renames that follow re-exports and JSX attribute usage instead of matching identifier text
  • Files and folders renamed or moved singly or in batches, with every import and export path rewritten, path aliases included
  • One top-level symbol moved to another file, carrying its internal-only dependencies and rewriting imports across the project
  • Function parameters added, removed or reordered, with the matching argument changes propagated to every call site
  • Path-alias imports and exports converted to relative paths within a chosen file or directory
  • Read-only answers before anything changes: every reference to the symbol at a position, the type inferred there, and exports nobody outside the declaring file consumes
  • A dryRun switch on each rewriting tool, so the edit can be inspected before it lands
Requirements

A TypeScript or JavaScript project the tools can load through tsconfigPath. Positions are given as file path plus position, so the caller needs to know where the symbol sits, not just its name.

Setup effort

One command — npx -y @sirosuzume/mcp-tsmorph-refactor