Regex-based code refactoring
## Refactor MCP Server: Intelligent Code Refactoring Assistant The **Refactor MCP Server** provides sophisticated code refactoring capabilities within Google Antigravity, enabling safe, automated code transformations that improve structure, readability, and maintainability while preserving functionality. ### Why Refactor MCP? - **Safe Transformations**: Apply complex refactoring patterns with confidence using AST-based transformations - **Pattern Detection**: Automatically identify code smells and suggest appropriate refactoring strategies - **Multi-File Refactoring**: Rename symbols, move functions, and restructure across entire codebases safely - **Preview Changes**: Review proposed changes before applying with detailed diff visualization - **Undo Capability**: Easily revert refactoring operations if results do not meet expectations ### Key Features #### 1. Code Restructuring ```python from anthropic import Anthropic client = Anthropic() response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Extract the validation logic from processOrder into a separate validateOrder function" }] ) ``` #### 2. Symbol Renaming ```python # Rename across codebase response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Rename the UserManager class to UserService across all files and update imports" }] ) ``` #### 3. Pattern Conversion ```python # Apply modern patterns response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Convert all Promise chains in the api/ directory to async/await syntax" }] ) ``` #### 4. Code Smell Detection ```python # Identify issues response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Analyze the utils/ directory for code smells and suggest refactoring opportunities" }] ) ``` ### Configuration ```json { "mcpServers": { "refactor": { "command": "npx", "args": ["-y", "@anthropic/mcp-server-refactor"], "env": { "REFACTOR_PREVIEW_MODE": "true", "REFACTOR_BACKUP_ENABLED": "true" } } } } ``` ### Use Cases **Technical Debt Reduction**: Systematically improve code quality by applying consistent refactoring patterns across the codebase. **API Evolution**: Safely rename and restructure public APIs while updating all dependent code automatically. **Framework Migration**: Transform code patterns when migrating between frameworks or library versions. **Code Review Implementation**: Apply reviewer suggestions as safe, trackable refactoring operations. The Refactor MCP Server brings professional-grade refactoring tools into the AI-assisted development workflow, making code improvement safe, efficient, and accessible.
{
"mcpServers": {
"refactor": {
"mcpServers": {
"refactor": {
"args": [
"-y",
"refactor-mcp"
],
"command": "npx"
}
}
}
}
}