Refactoring MCP Server

io.github.marshallyPublished by GitHub account marshallyv0.1.2Updated Oct 24, 2026

MCP server exposing Martin Fowler's refactoring catalog to LLMs with 71+ refactorings

VerifiedSTDIODesktop onlyKnowledge & MemoryDeveloper Tools

Overview

AI-generated overview

A local MCP server that exposes Martin Fowler's refactoring catalog, letting an assistant list, preview, apply and analyze code refactorings.

What you can do
List available refactorings with their parameter contracts, filtered by language and category, based on Martin Fowler's catalog of 71+ refactorings across composing methods, moving features, organizing data, conditionals, method calls and generalization. Preview what a refactoring would change as a dry run before applying it. Apply a refactoring to a codebase at a specified target such as a file, class, method or line range. Inspect the structure of code at file, class or method depth. Analyze code for smells and suggest refactorings.
When to use it
Useful when an assistant is asked to clean up or restructure Python code and you want it to work from a named, catalog-based set of refactorings with a preview step before changes are applied. Best suited to developers already using a supported language backend.
Requirements
Runs as a local process, typically launched with uvx or installed via pip or pipx. Needs Python 3.10+ and a language backend such as molting-cli for Python. Optional configuration in a config file or via environment variables such as MCP_REFACTORING_PYTHON_COMMAND and MCP_REFACTORING_PYTHON_ENABLED. No authentication declared.
Before you install
The apply_refactoring tool modifies source files in the codebase, so changes should be reviewed and version-controlled; preview mode is the safer first step. Only Python is described as implemented, with Ruby, Java and Go planned. It relies on a separate backend command whose path can be overridden by environment variable.

Installation

In SourceWeft

  1. Open Refactoring MCP Server in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

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

bash
# Using uvx (recommended)uvx mcp-refactoring
# Using pippip install mcp-refactoring
# Using pipxpipx install mcp-refactoring

Requirements

  • Python 3.10+
  • A language backend (e.g., molting-cli for Python)

Install the Python backend:

bash
pip install molting-cli

Claude Desktop Configuration

Add to your Claude Desktop config:

json
{  "mcpServers": {    "refactoring": {      "command": "uvx",      "args": ["mcp-refactoring"]    }  }}

Available Tools

list_refactorings

List available refactorings with their parameter contracts.

list_refactorings(language="python", category="composing_methods")

preview_refactoring

Preview what changes a refactoring would make (dry-run).

preview_refactoring(    refactoring="extract-method",    target="src/order.py::Order::calculate#L10-L15",    params={"name": "calculate_tax"})

apply_refactoring

Apply a refactoring to the codebase.

apply_refactoring(    refactoring="rename-method",    target="src/order.py::Order::calc",    params={"new_name": "calculate_total"})

inspect_structure

Get structural information about code.

inspect_structure(path="src/order.py", depth="method")

analyze_code

Analyze code for smells and suggest refactorings.

analyze_code(path="src/order.py", smells=["long-method"])

Target Specification

Each language uses its native conventions:

Python

src/order.py::Order::calculate_total        # Methodsrc/order.py::Order::calculate_total#L10-L15  # Line rangesrc/order.py::Order                         # Class

Configuration

Create ~/.mcp-refactoring/config.toml:

toml
[backends.python]enabled = truecommand = "molting"
[backends.ruby]enabled = falsecommand = "molting-rb"

Environment variable overrides:

bash
MCP_REFACTORING_PYTHON_COMMAND=/path/to/moltingMCP_REFACTORING_PYTHON_ENABLED=true

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

bash
# Clone the repositorygit clone https://github.com/marshally/mcp-refactoring.gitcd mcp-refactoring
# Install in development modepip install -e ".[dev]"
# Run testspytest
# Run linterruff check .
# Run type checkermypy src/

License

MIT License - see LICENSE for details.

Source: README.md at commit 30d981a

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v0.1.2LatestSep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts