A bare regex rename hits every occurrence in the repository, including the ones in comments and strings you did not think about. Constraining the match to a surrounding context, or to a file glob, is what makes the rewrite safe. Search first with the matched text included, read what came back, then run the replacement.
Two tools — find a pattern, replace a pattern — with scoping that keeps a repo-wide regex from doing repo-wide damage.
- code_search finds a regular expression across the tree and returns file paths with line numbers or line ranges
- code_refactor performs the replacement, with capture groups available in the replacement pattern as $1, $2
- context_pattern on both tools: only match where the surrounding context matches as well — rename legacy_sdk inside import statements without touching it anywhere else
- file_pattern to scope either tool with a glob, such as *.js or src/**/*.ts
- Options to include the matched text and the capture groups in the result, so you can see exactly what was caught before acting on it
- The same two operations as a command-line tool, where a dry run previews the replacements instead of writing them
Nothing to authorize. Run it over stdio with npx @myuon/refactor-mcp@latest, or install @myuon/refactor-mcp globally. The same binary doubles as a CLI — put cli after the command to search or refactor from a terminal, where a dry run shows the changes before anything is written. One shell caveat there: escape the dollar sign in capture groups so the shell does not expand them before the tool sees them.
One command — npx @myuon/refactor-mcp@latest
