ts-morph Refactoring Tools is an MCP server that provides AST-based refactoring operations for TypeScript and JavaScript projects using the ts-morph library. It connects MCP-compatible AI clients to the TypeScript compiler API and ts-morph AST engine, allowing developers and automated agents to execute precise codebase modifications while maintaining overall project integrity. The server provides tools to safely rename symbols across all references, rename files and directories while automatically updating import and export statements, and move individual declarations between files along with their internal dependencies. It also enables checking inferred types at specific positions, altering function signatures across all calling sites, replacing path aliases with relative paths, and auditing codebases for unused exports. By relying on compiler-level abstract syntax tree analysis rather than naive text replacements, ts-morph Refactoring Tools allows software engineers and coding assistants to carry out complex architectural migrations and structural cleanups safely without breaking project references or introducing syntax issues.
Category: Developer Tools & Code Intelligence
Tags: code analysis, javascript, refactoring, ts-morph, typescript
Visit ts-morph Refactoring Tools
mcp.json). 3. Add the server under the mcpServers block using npx: json { "mcpServers": { "mcp-tsmorph-refactor": { "command": "npx", "args": ["-y", "@sirosuzume/mcp-tsmorph-refactor"], "env": {} } } } 4. Optional: Configure logging by adding LOG_LEVEL (e.g., debug), LOG_OUTPUT (console or file), and LOG_FILE_PATH to the env object. 5. Restart your MCP client to load the tools.Part of MCP Servers
You can add it directly to your MCP client configuration file, such as mcp.json, under the mcpServers property. Set the command to npx and pass the arguments -y and @sirosuzume/mcp-tsmorph-refactor. No manual global installation is required.
It provides tools to refactor TypeScript and JavaScript code using ts-morph. You can rename symbols, rename files and directories, move declarations between files, update function call signatures, inspect inferred types at specific locations, convert path aliases to relative paths, and scan for unused exports.
It works with any MCP-compliant client that supports standard I/O server configurations. This includes Claude Desktop, Cursor, and developer debugging tools like MCP Inspector.
Yes, ts-morph Refactoring Tools is an open source project available on GitHub under the repository SiroSuzume/mcp-ts-morph.
Yes, every tool provided by this MCP server requires the path to your project tsconfig.json file so that the ts-morph engine can accurately parse the abstract syntax tree and resolve type definitions across the codebase.