
A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A Model Context Protocol server that analyzes Python code and offers step-by-step refactoring guidance, with options for guide-only or applied changes.
MCP Python Refactoring is cataloged as an MCP server attributed to slamer59. A Model Context Protocol server that analyzes Python code and offers step-by-step refactoring guidance, with options for guide-only or applied changes. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.
Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.
Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.
Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
Email delivery is not connected. This page does not collect email addresses or create subscriptions.
Browse the registry for current listings instead.
Reviews for MCP Python Refactoring are not available yet
Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.
It provides guided instructions with line numbers and an educational approach, keeping the developer in control rather than making all decisions automatically.
By default it returns instructions only; applied modification is available as an optional mode.
README.md · b2ade1fef496 · Fetched 2026-11-13 12:08:47 UTC
Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.
Showing the last retrieved documentation snapshot; check the source for current changes.
A Model Context Protocol (MCP) server that analyzes Python code and provides guided refactoring suggestions without automatically modifying your code.
python refactoring code-analysis mcp-server ai-assistant claude rope radon vulture jedi educational mentoring code-quality static-analysis complexity-analysis
This tool integrates with AI coding assistants (Claude, ChatGPT, Cursor, etc.) to provide intelligent refactoring guidance. Instead of making automatic code changes, it gives you precise instructions on how to improve your Python code, acting as your refactoring mentor.
For AI Coding Assistants:
For Developers:
| Approach | This Tool | Traditional Refactoring Tools |
|---|---|---|
| Integration | Works with any LLM/AI assistant | IDE-specific or standalone |
| Guidance | Step-by-step instructions with line numbers | Automatic changes only |
| Learning | Educational approach teaches patterns | No learning component |
| Control | Developer maintains full control | Tool makes all decisions |
This MCP server is available across the entire MCP ecosystem:
Published and Live: registry.modelcontextprotocol.io
io.github.slamer59/mcp-python-refactoringPull Request Submitted: docker/mcp-registry #207
mcp/mcp-python-refactoring on Docker HubCommunity Curated Lists:
Once all registries are live, users can discover via:
mcp/mcp-python-refactoring (with enhanced security)# Pull from Docker Hub (after registry approval)
docker run -i mcp/mcp-python-refactoring
# Or build locally
docker build -t mcp-python-refactoring .
docker run -i mcp-python-refactoring
FROM python:3.13-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy project files
COPY pyproject.toml README.md ./
COPY src/ ./src/
# Install the package
RUN pip install --no-cache-dir -e .
# Expose MCP server port (optional, for documentation)
EXPOSE 3000
# Run the MCP server
ENTRYPOINT ["python-refactor", "server"]
# Install and run MCP server directly from GitHub
uvx --from git+https://github.com/slamer59/mcp-python-refactoring.git python-refactor server
# Add to Claude Code MCP configuration
claude-code mcp add mcp-python-refactoring uvx --from git+https://github.com/slamer59/mcp-python-refactoring.git python-refactor server
After running this command, restart Claude Desktop and the Python refactoring tools will be available in your Claude conversations!
# Clone and setup for development
git clone https://github.com/slamer59/mcp-python-refactoring.git
cd mcp-python-refactoring
uv sync
# Run MCP server locally
python -m mcp_refactoring_assistant server
# Or use the entry point after installation
pip install -e .
python-refactor server
The python-refactor-cli entry point (installed via uv sync or pip install -e .)
runs every analysis standalone, without an MCP client — useful for scripts,
CI, or driving the tool directly from an agent's shell:
uv run python-refactor-cli --help
Commands are grouped by capability, and together they cover every MCP tool:
| Group | Commands | MCP tool(s) |
|---|---|---|
file | analyze, long-functions, extraction | analyze_python_file, find_long_functions, get_extraction_guidance |
test | coverage, tdd | analyze_test_coverage, tdd_refactoring_guidance |
security | scan | analyze_security_and_patterns |
package | analyze, metrics, issues, dependencies | analyze_python_package, get_package_metrics, find_package_issues |
repo | index, query | — |
uv run python-refactor-cli file long-functions src/app.py --line-threshold 30 --format json
uv run python-refactor-cli file extraction src/app.py --function-name process_order
uv run python-refactor-cli test coverage src/ --test-path tests/ --target-coverage 80
uv run python-refactor-cli test tdd src/app.py --function-name process_order
uv run python-refactor-cli security scan src/app.py --format table
uv run python-refactor-cli package metrics src/mypackage --format json
To list every command with its usage and examples, run python-refactor-cli skills
(or <group> <command> --help). The old flat names (find-long-functions,
security-scan, package-metrics, …) still work as hidden aliases.
Every command supports --format json for machine-readable output.
This project ships a SKILL.md describing how an agent should call it —
which command to use for which situation, and the JSON output contract.
uv run python-refactor-cli skills # print the skill + every command with examples
uv run python-refactor-cli skill path # print the path to SKILL.md
Point your coding agent (e.g. Claude Code) at the path this prints and ask it to load the skill file before refactoring Python code in this repo. A good generic prompt:
Run
uv run python-refactor-cli skillsand follow that skill for this session.
Single Server: Both guide-only and apply-changes modes in one server
Connection Options:
python-refactor server (default)python -m mcp_refactoring_assistant serveranalyze_python_codeComprehensive analysis with optional automatic refactoring.
Parameters:
content (required): Python file content as stringmode (optional): "guide_only" (default) or "apply_changes"file_path (optional): Path to the file for contextline_threshold (optional): Minimum lines for long functions (default: 20)Mode: guide_only - Returns instructions only Mode: apply_changes - Returns modified code
analyze_security_and_patterns 🔒 NEW!Comprehensive security scanning and modern Python patterns analysis.
Parameters:
content (required): Python file content as stringfile_path (optional): Path to the file for contextinclude_security_scan (optional): Enable security vulnerability scanning (default: true)include_dependency_scan (optional): Enable dependency vulnerability scanning (default: true)include_modernization (optional): Enable modern Python pattern suggestions (default: true)Features:
extract_functionExtract specific functions with guide or apply mode.
Parameters:
content (required): Python file contentmode (optional): "guide_only" or "apply_changes"function_name (optional): Specific function to targetstart_line, end_line (for apply_changes): Exact extraction rangenew_function_name (for apply_changes): Name for extracted functionquick_analyzeFast analysis for immediate refactoring opportunities.
Parameters:
content (required): Python file contentReturns: Quick summary of long functions and parameter issues
check_types_with_pyreflyAdvanced type checking and quality analysis using pyrefly.
Parameters:
content (required): Python code content to type checkReturns: Detailed type errors, quality issues, and improvement suggestions
get_server_capabilities (Internal)Returns server capabilities and available analysis tools.
Returns: List of available tools: rope, radon, vulture, jedi, libcst, pyrefly, mccabe, complexipy
Code Quality Issues Detected:
🔒 Security & Modernization Features (NEW!):
Additional Analysis Tools:
Professional Tools Used:
🔧 Core Refactoring Analysis:
🔒 Security & Modernization Tools (NEW!):
📁 Built-in Analysis:
# Launch MCP Inspector
bunx @modelcontextprotocol/inspector
# In the web interface:
# Command: python
# Args: -m mcp_refactoring_assistant server
# Working Directory: /path/to/your/project
Test Both Modes in Inspector:
Guide Mode Test:
{
"content": "def long_function():\n print('line1')\n # ... 20+ lines",
"mode": "guide_only"
}
Apply Mode Test:
{
"content": "def long_function():\n print('line1')\n # ... 20+ lines",
"mode": "apply_changes"
}
# Install Bun if not available
curl -fsSL https://bun.sh/install | bash
# Install MCP SDK
bun install -g @modelcontextprotocol/sdk
# Run tests
export PATH=.venv/bin:$PATH && bun run test_unified.js
# Simple Python test
python test_tool.py
# Test with example file
python -m mcp_refactoring_assistant --help
# Check dependencies
uv sync
# Verify MCP imports
python -c "import mcp; print('MCP available')"
# Test individual tools
python -c "
from src.mcp_refactoring_assistant.server import EnhancedRefactoringAnalyzer
analyzer = EnhancedRefactoringAnalyzer()
print('Analyzer working')
"
analyze_python_code with guide_only modeanalyze_python_code with apply_changes mode{
"analysis_summary": {
"total_issues_found": 2,
"medium_priority": 1,
"low_priority": 1
},
"refactoring_guidance": [
{
"issue_type": "extract_function",
"location": "Function 'process_data' lines 45-78",
"description": "Long function (34 lines) with extractable blocks",
"precise_steps": [
"SELECT lines 45-52 (validation block)",
"CREATE function: validate_input(data)",
"REPLACE with: is_valid = validate_input(data)"
]
},
{
"issue_type": "dead_code",
"location": "Multiple locations (6 items)",
"description": "6 unused items found",
"precise_steps": [
"Review all unused items listed below:",
"• Line 11: Unused import 're'",
"• Line 12: Unused import 'Optional'",
"Verify each item is truly unused",
"Remove confirmed unused code"
]
}
]
}
Add to your MCP configuration:
{
"servers": {
"python-refactoring": {
"command": "uvx",
"args": ["--from", "git+https://github.com/slamer59/mcp-python-refactoring.git", "python-refactor", "server"]
}
}
}
Or for local installation:
{
"servers": {
"python-refactoring": {
"command": "python",
"args": ["-m", "mcp_refactoring_assistant", "server"]
}
}
}
Add to claude_desktop_config.json:
{
"mcpServers": {
"python-refactoring": {
"command": "uvx",
"args": ["--from", "git+https://github.com/slamer59/mcp-python-refactoring.git", "python-refactor", "server"]
}
}
}
Or for local installation:
{
"mcpServers": {
"python-refactoring": {
"command": "python",
"args": ["-m", "mcp_refactoring_assistant", "server"]
}
}
}
In VSCode settings or .vscode/settings.json:
{
"cline.mcpServers": {
"python-refactoring": {
"command": "python",
"args": ["-m", "mcp_refactoring_assistant", "server"]
}
}
}
Add to Cursor's MCP configuration:
{
"mcpServers": {
"python-refactoring": {
"command": "python",
"args": ["-m", "mcp_refactoring_assistant", "server"]
}
}
}
In ~/.continue/config.json:
{
"mcpServers": [
{
"name": "python-refactoring",
"command": "python",
"args": ["-m", "mcp_refactoring_assistant", "server"]
}
]
}
Add to Windsurf MCP configuration:
{
"servers": {
"python-refactoring": {
"command": "python",
"args": ["-m", "mcp_refactoring_assistant", "server"]
}
}
}
Use with MCP bridge or direct integration:
aider --mcp-server "python -m mcp_refactoring_assistant server"
In OpenHands configuration:
mcp_servers:
python-refactoring:
command: python
args: ["-m", "mcp_refactoring_assistant", "server"]
Add to Roo-Code's MCP settings:
{
"mcpServers": {
"python-refactoring": {
"command": "python",
"args": ["-m", "mcp_refactoring_assistant", "server"]
}
}
}
Add to ~/.codex/config.toml:
[mcp_servers.python-refactoring]
command = "python"
args = ["-m", "mcp_refactoring_assistant", "server"]
For most terminal-based MCP clients:
# With uvx
client-name --mcp-server "uvx --from git+https://github.com/slamer59/mcp-python-refactoring.git python-refactor server"
# With local installation
client-name --mcp-server "python -m mcp_refactoring_assistant server"
For web-based clients that support SSE connections:
# SSE mode is not currently supported
# Use stdin/stdout mode instead
python-refactor server
For clients without native MCP support:
# Install mcpo
pip install mcpo
# Bridge MCP to OpenAI-compatible API
mcpo --mcp-server "python -m mcp_refactoring_assistant server" --port 8080
Then configure your client to use http://localhost:8080 as API endpoint.
python -m mcp_refactoring_assistant server for local installationsUsers report significant improvements in code quality understanding and refactoring skills when using this tool with AI assistants. The guided approach helps developers learn refactoring patterns while maintaining control over code changes.
"Finally, a tool that teaches me refactoring instead of doing it for me"
"The precise line numbers make it easy to follow the suggestions"
"Game changer for working with legacy code"
MCP Connection Issues:
uv syncwhich pythonpython -c "import mcp"Analysis Not Working:
python test_tool.pyls examples/Tool Responses Empty:
"line_threshold": 10SSE Connection Issues:
netstat -an | grep 3001uv add starlette uvicornPerformance Issues:
quick_analyze for immediate feedback on specific functionsSubmit to awesome lists and community catalogs:
🎉 What's New:
🔒 Security Scanning: Professional-grade vulnerability detection using Bandit
📦 Dependency Security: CVE scanning with pip-audit
⚡ Code Modernization: Python pattern suggestions using Refurb
🎯 Unified Analysis: Intelligent prioritization system
✅ Production Ready:
📊 Proven Results:
MIT License - Free for personal and commercial use.
Claim this server with your GitHub account to request manual ownership verification.
Link to the catalog listing for MCP Python Refactoring from your README. This badge does not certify ownership, compatibility or security.
[](https://awesome-mcp.com/servers/mcp-python-refactoring)Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.
Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.
No reviewed package or image identity; download statistics are not listed yet.
Alternative and complementary servers in the same category

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.