Graph-powered refactoring operations. Unified entry point for rename previews, dead code detection, and refactoring suggestions. Modes: - rename: Preview renaming a symbol. Returns an edit list and a refactor_id to pass to apply_refactor_tool. Requires old_name and new_name.
(
mode: str = "rename",
old_name: Optional[str] = None,
new_name: Optional[str] = None,
kind: Optional[str] = None,
file_pattern: Optional[str] = None,
repo_root: Optional[str] = None,
)
| 625 | |
| 626 | @mcp.tool() |
| 627 | def refactor_tool( |
| 628 | mode: str = "rename", |
| 629 | old_name: Optional[str] = None, |
| 630 | new_name: Optional[str] = None, |
| 631 | kind: Optional[str] = None, |
| 632 | file_pattern: Optional[str] = None, |
| 633 | repo_root: Optional[str] = None, |
| 634 | ) -> dict: |
| 635 | """Graph-powered refactoring operations. |
| 636 | |
| 637 | Unified entry point for rename previews, dead code detection, and |
| 638 | refactoring suggestions. |
| 639 | |
| 640 | Modes: |
| 641 | - rename: Preview renaming a symbol. Returns an edit list and a refactor_id |
| 642 | to pass to apply_refactor_tool. Requires old_name and new_name. |
| 643 | - dead_code: Find unreferenced functions/classes (no callers, tests, or |
| 644 | importers, and not entry points). |
| 645 | - suggest: Get community-driven refactoring suggestions (move misplaced |
| 646 | functions, remove dead code). |
| 647 | |
| 648 | Args: |
| 649 | mode: Operation mode: "rename", "dead_code", or "suggest". |
| 650 | old_name: (rename) Current symbol name to rename. |
| 651 | new_name: (rename) Desired new name for the symbol. |
| 652 | kind: (dead_code) Optional filter: Function or Class. |
| 653 | file_pattern: (dead_code) Filter by file path substring. |
| 654 | repo_root: Repository root path. Auto-detected if omitted. |
| 655 | """ |
| 656 | return refactor_func( |
| 657 | mode=mode, old_name=old_name, new_name=new_name, |
| 658 | kind=kind, file_pattern=file_pattern, repo_root=_resolve_repo_root(repo_root), |
| 659 | ) |
| 660 | |
| 661 | |
| 662 | @mcp.tool() |
nothing calls this directly
no test coverage detected