apply_refactor_tool writes to files with no dry-run or confirmation step
Problem
apply_refactor_tool modifies files on disk directly when called via MCP. There is no dry-run mode, no diff preview before applying, and no confirmation prompt. Once invoked, changes are applied immediately.
Impact
- An AI assistant can trigger file rewrites autonomously without the developer explicitly approving the specific changes
- There is no undo path beyond
git checkout— developers who haven't staged their work lose changes permanently - In an agentic workflow where multiple MCP tools are chained,
apply_refactor_toolcould be called as a side effect of a broader task the developer didn't intend to modify files for
Suggested Fix
- Add a
dry_run: boolparameter toapply_refactor_tool— when true, return the diff without writing to disk - Default behaviour should return a diff and require a second explicit call with
confirmed: trueto actually apply (two-step commit pattern) - At minimum, always return the full diff in the tool response so the AI assistant can show it to the user before they accept
Valid security/UX concern. apply_refactor_tool currently writes changes to disk immediately with no confirmation step. The suggested two-step approach (dry_run first, then confirmed=true to apply) is the right pattern for agentic workflows where side effects should be explicit.
This is a valid enhancement — a PR adding dry_run: bool parameter to apply_refactor_tool that returns a diff without writing when True would be a straightforward and valuable safety improvement.
@tirth8205 @dev-arctik can I work on this Issue and raise a PR as soon as possible??!