mcp-refactoring
An MCP (Model Context Protocol) server that exposes Martin Fowler's refactoring catalog to LLMs through a pluggable, language-agnostic architecture.
Features
71+ Refactorings: Full implementation of Martin Fowler's refactoring catalog
Pluggable Architecture: Support for multiple languages (Python first, Ruby/Java/Go planned)
Safe by Default: Preview mode shows changes before applying
LLM-Optimized: TOON output format for token efficiency
Installation
Requirements
Python 3.10+
A language backend (e.g.,
molting-clifor Python)
Install the Python backend:
Claude Desktop Configuration
Add to your Claude Desktop config:
Available Tools
list_refactorings
List available refactorings with their parameter contracts.
preview_refactoring
Preview what changes a refactoring would make (dry-run).
apply_refactoring
Apply a refactoring to the codebase.
inspect_structure
Get structural information about code.
analyze_code
Analyze code for smells and suggest refactorings.
Target Specification
Each language uses its native conventions:
Python
Configuration
Create ~/.mcp-refactoring/config.toml:
Environment variable overrides:
Refactoring Categories
Based on Martin Fowler's catalog:
Composing Methods: extract-method, inline-method, etc.
Moving Features: move-method, extract-class, etc.
Organizing Data: encapsulate-field, replace-type-code, etc.
Simplifying Conditionals: decompose-conditional, guard-clauses, etc.
Simplifying Method Calls: rename-method, add-parameter, etc.
Dealing with Generalization: pull-up-method, extract-interface, etc.
Development
License
MIT License - see LICENSE for details.