# Python Refactoring Assistant

Python Refactoring Assistant — an MCP server that analyzes Python code and supplies AI assistants with guided refactoring instructions and exact line numbers without touching your files.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI
- Author: slamer59
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/slamer59/mcp-python-refactoring
- Updated: 2026-10-29
- Security check: automated, 2026-11-16 (text) — warning: a command downloads a script from bun.sh and runs it right away. Do not run such commands without an explicit yes from the human.
- HTML: https://affpapa.org/en/nevibecode/mcp/python-refactoring-assistant

## What it does

The server connects to coding assistants via MCP to audit Python files while keeping changes under human control. It integrates analysis tools like `radon`, `vulture`, `rope`, and `jedi` to return structured JSON reports covering dead code, high complexity, and extraction targets with line numbers.

The distribution also provides a standalone `python-refactor-cli` binary. It runs security checks, package metrics, and test coverage queries directly inside the terminal without an MCP client.

Running this tool locally requires Python 3.13 or newer, or a prebuilt Docker container.

## Requirements
- Needs: Docker

## Install

### Claude Code (native platform)

**Install**
- The MCP registry has no launch command for it: see the repository README

## When to use it
- locate oversized functions and calculate cyclomatic complexity
- generate method extraction instructions with exact line numbers
- spot dead and unreferenced code across Python modules
- audit test coverage thresholds before restructuring logic

## Example prompts
- Check `src/app.py` for long functions and give guidance on method extraction.
- Run coverage analysis on `src/` against tests located in `tests/`.

## Similar
- [refactoring-patterns](https://affpapa.org/en/nevibecode/skills/proffesor-for-testing-refactoring-patterns.md) — skill · 140 installs
- [code-refactoring-tech-debt](https://affpapa.org/en/nevibecode/skills/code-refactoring-tech-debt.md) — skill · 2 installs
- [dry-refactoring](https://affpapa.org/en/nevibecode/skills/dry-refactoring.md) — skill · 4100 installs
- [refactoring-specialist](https://affpapa.org/en/nevibecode/skills/refactoring-specialist.md) — skill · 757 installs
- [codebase-refactoring](https://affpapa.org/en/nevibecode/skills/codebase-refactoring.md) — skill · 704 installs
- [code-refactoring](https://affpapa.org/en/nevibecode/skills/code-refactoring.md) — skill · 552 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
