Refactoring MCP Server — Claude Code MCP server: Fowler's catalog
Hands your agent Martin Fowler's refactoring catalog: 71+ moves, dry-run previews and smell analysis on the code you point it at.
claude mcp add mcp-refactoring -- uvx mcp-refactoringWhat Refactoring MCP Server does
The server registers five tools with your agent. list_refactorings returns the available moves and the parameters each one expects. preview_refactoring runs a change without touching the file, apply_refactoring writes it, inspect_structure reports how the code is laid out, and analyze_code flags smells and suggests what to do about them.
Targets follow each language's own notation: src/order.py::Order::calculate_total for a method, src/order.py::Order for a class, and #L10-L15 to narrow it to a line range. Moves are grouped the way Fowler groups them — composing methods, moving features, simplifying conditionals and so on. Language backends are pluggable. You declare them in ~/.mcp-refactoring/config.toml with a command and an enabled flag, and environment variables such as MCP_REFACTORING_PYTHON_COMMAND override those settings.
Python 3.10+ is required, plus a language backend — molting-cli for Python. No backend means nothing to apply the refactorings with. Python ships first; Ruby, Java and Go are planned.
What it helps with
- see what a refactoring changes before editing files
- pull a method out of a long class the Fowler way
- rename a method across the project without grep
- spot long methods and other smells in a file
- read a class structure before touching it
Example prompts for the agent
- List the Python refactorings in the composing methods category
- Preview extract-method on
src/order.py::Order::calculate#L10-L15with the namecalculate_tax - Apply rename-method to
src/order.py::Order::calcwith the new namecalculate_total
How to install Refactoring MCP Server
Platform CLI
claude mcp add mcp-refactoring -- uvx mcp-refactoringuvx runs the command named after the package; if the README names another one, use uvx --from mcp-refactoring <command>
Platform CLI
codex mcp add refactoring-mcp-server -- uvx mcp-refactoringuvx runs the command named after the package; if the README names another one, use uvx --from mcp-refactoring <command>
Config file
{
"mcpServers": {
"refactoring-mcp-server": {
"command": "uvx",
"args": [
"mcp-refactoring"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from mcp-refactoring <command>
Config file
{
"servers": {
"refactoring-mcp-server": {
"type": "stdio",
"command": "uvx",
"args": [
"mcp-refactoring"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from mcp-refactoring <command>
Platform CLI
gemini mcp add refactoring-mcp-server uvx mcp-refactoringuvx runs the command named after the package; if the README names another one, use uvx --from mcp-refactoring <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Refactoring MCP Server
How do I install Refactoring MCP Server in Claude Code?
Run claude mcp add mcp-refactoring -- uvx mcp-refactoring. That registers the server and launches it through uvx.
What does Refactoring MCP Server do?
It exposes Martin Fowler's refactoring catalog to the agent: listing moves, previewing changes, applying them, inspecting structure and analyzing smells.
What does the server need to run?
Python 3.10+ and a language backend — molting-cli for Python. Without a backend there is nothing to apply the refactorings with.