MCP ts-morph Refactoring Tools

Integrations

  • Enables AST-based code refactoring operations for JavaScript files including symbol renaming, file/folder renaming with automatic import path updates, and reference finding.

  • Provides a Node.js-based refactoring server that can be integrated with editor extensions like Cursor to perform code transformations.

  • Provides refactoring capabilities for TypeScript codebases including symbol renaming, finding references, and updating import paths, all performed using AST-based analysis.

MCP ts-morph Refactoring Tools

개요

이 MCP 서버는 ts-morph 를 사용하여 TypeScript 및 JavaScript 코드베이스에 대한 리팩토링 작업을 제공합니다.

환경 구축

mcp.json 에 다음과 같이 설정을 추가합니다.

{ "mcpServers": { "mcp-tsmorph-refactor": { // 任意のサーバー名 "command": "node", // TODO: ビルド後のエントリポイントへのパスを指定してください "args": ["/path/to/this/repo/dist/index.js"], "env": {} } } }

제공되는 기능

이 MCP 서버는 다음 리팩토링 기능을 제공합니다. 각 기능은 ts-morph 사용하여 AST를 구문 분석하고 전체 프로젝트의 무결성을 유지하면서 변경합니다.

기호 이름 변경 ( rename_symbol_by_tsmorph )

  • 기능 : 지정된 파일의 특정 위치에 있는 심볼(함수, 변수, 클래스, 인터페이스 등)의 이름을 프로젝트 전체에서 일괄 변경합니다.
  • 유스 케이스 : 함수명이나 변수명을 변경하고 싶지만, 참조 부분이 많고 수작업으로의 변경이 곤란한 경우.
  • 필요한 정보 : 프로젝트의 tsconfig.json 경로, 대상 파일의 경로, 기호 위치 (행 / 열), 현재 기호 이름, 새 기호 이름

파일 / 폴더 이름 변경 ( rename_filesystem_entry_by_tsmorph )

  • 기능 : 지정된 파일 또는 폴더의 이름을 바꾸고 프로젝트의 모든 import / export 문 경로를 자동으로 업데이트합니다.
  • 사용 사례 : 파일 구성을 변경하고 이에 따라 가져오기 경로를 수정하려는 경우.
  • 필요한 정보 : 프로젝트의 tsconfig.json 경로, 변경 전 경로, 변경 후 경로.
  • 참고 : 경로 @/* 이나 상대 인덱스 ".." 업데이트가 불완전할 수 있습니다. 변경 후 수동 "." 이 필요할 수 있습니다.

참조 위치 찾기 ( find_references_by_tsmorph )

  • 기능 : 지정된 파일 내의 특정 위치에 있는 심볼의 정의 부분과 프로젝트 전체의 모든 참조 부분을 검색하여 나열합니다.
  • 사용 사례 : 특정 함수나 변수가 어디에서 사용되는지 파악하고 싶은 경우.
  • 필수 정보 : 프로젝트의 tsconfig.json 경로, 대상 파일의 경로 및 기호의 위치 (행 / 열).

경로 별칭 삭제 ( remove_path_alias_by_tsmorph )

  • 기능 : 지정된 파일 또는 디렉토리내의 import / export 문에 포함되는 패스 앨리어스 ( @/components 등)를, 상대 패스 ( ../../components 등)로 치환합니다.
  • 사용 사례 : 프로젝트의 이식성을 높이고 싶거나 특정 코딩 규칙에 맞추고 싶을 때.
  • 필수 정보 : 프로젝트의 tsconfig.json 경로, 처리할 파일 또는 디렉토리의 경로.

(기타 기능이 있으면 추가)

개발자 정보

전제 조건

  • Node.js (버전은 .node-version 또는 package.jsonvolta 필드 참조)
  • pnpm (버전은 package.jsonpackageManager 필드 참조)

설정

리포지토리를 복제하고 종속성을 설치합니다.

git clone https://github.com/sirosuzume/mcp-tsmorph-refactor.git cd mcp-tsmorph-refactor pnpm install

빌드

TypeScript 코드를 JavaScript로 컴파일합니다.

pnpm build

빌드 아티팩트는 dist 디렉토리에 출력됩니다.

테스트

단위 테스트를 실행합니다.

pnpm test

린팅 및 포맷

코드의 정적 해석과 포맷을 실시합니다.

# Lintチェック pnpm lint # Lint修正 pnpm lint:fix # フォーマット pnpm format

라이센스

이 프로젝트는 MIT 라이센스하에 게시됩니다. 자세한 내용은 LICENSE 파일을 참조하십시오.

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Provides TypeScript and JavaScript code refactoring operations using ts-morph, allowing AST-based symbol renaming, file/folder renaming, reference searching, and path alias removal when integrated with editor extensions like Cursor.

  1. 概要
    1. 環境構築
      1. 提供される機能
        1. シンボル名の変更 (rename_symbol_by_tsmorph)
        2. ファイル/フォルダ名の変更 (rename_filesystem_entry_by_tsmorph)
        3. 参照箇所の検索 (find_references_by_tsmorph)
        4. パスエイリアスの削除 (remove_path_alias_by_tsmorph)
      2. 開発者向け情報
        1. 前提条件
        2. セットアップ
        3. ビルド
        4. テスト
        5. リンティングとフォーマット
      3. ライセンス

        Related MCP Servers

        • A
          security
          A
          license
          A
          quality
          TypeScript-based MCP server designed to enhance code editing experiences by providing features such as hover information, code completion, and diagnostics.
          Last updated -
          3
          13
          MIT License
          • Apple
        • A
          security
          A
          license
          A
          quality
          A TypeScript MCP server port of Anthropic's filesystem editing tools, allowing file manipulation via client-approved operations without automated writes to prevent system harm.
          Last updated -
          5
          5
          TypeScript
          MIT License
        • -
          security
          A
          license
          -
          quality
          A TypeScript-based MCP server that provides tools for making precise line-based edits to text files within allowed directories.
          Last updated -
          18
          TypeScript
          MIT License
          • Apple
        • A
          security
          F
          license
          A
          quality
          A TypeScript-based server that visualizes project directory structures in Markdown format, automatically documenting file contents with syntax highlighting and supporting customizable exclusion patterns.
          Last updated -
          1
          3
          2
          TypeScript
          • Linux
          • Apple

        View all related MCP servers

        ID: byunmqla3h