Refactoring MCP Server

io.github.marshally由 GitHub 帳號 marshally 發布v0.1.2更新於 Oct 24, 2026

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

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

一個本機 MCP 伺服器,向助理提供 Martin Fowler 重構目錄,可列出、預覽、套用與分析程式碼重構。

可以做什麼
依語言與類別列出可用重構及其參數約定,依據 Martin Fowler 的 71 項以上重構目錄,涵蓋組合方法、搬移特性、組織資料、簡化條件、簡化方法呼叫與處理泛化。以試執行方式預覽某次重構會帶來的變更。對指定目標(檔案、類別、方法或行範圍)套用重構。檢視程式碼在檔案、類別或方法層級的結構資訊。分析程式碼中的壞味道並建議重構。
適用情境
適合助理需要清理或重構 Python 程式碼時使用,讓它依循有名稱、有目錄的重構集合工作,並在實際變更前先預覽。最適合已使用受支援語言後端的開發者。
執行需求
以本機程序執行,通常用 uvx 啟動,或透過 pip、pipx 安裝。需要 Python 3.10+ 以及語言後端(例如 Python 的 molting-cli)。選用設定位於設定檔,或透過 MCP_REFACTORING_PYTHON_COMMAND、MCP_REFACTORING_PYTHON_ENABLED 等環境變數設定。未宣告驗證機制。
安裝前請注意
apply_refactoring 工具會修改程式碼庫中的原始檔,變更應經審查並納入版本控制;預覽模式是較安全的第一步。目前僅說明已實作 Python,Ruby、Java 與 Go 尚在規劃中。它依賴一個獨立的後端指令,其路徑可透過環境變數覆寫。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Refactoring MCP Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

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.

來源:README.md,提交 30d981a

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分