Python Refactoring Assistant

Python Refactoring Assistant

Educational Python refactoring assistant that provides guided suggestions for AI assistants. Features: • Step-by-step refactoring instructions without modifying code • Comprehensive code analysis using professional tools (Rope, Radon, Vulture, Jedi, LibCST, Pyrefly) • Educational approach teaching refactoring patterns through guided practice • Support for both guide-only and apply-changes modes • Identifies long functions, high complexity, dead code, and type issues • Provides precise line numbers and specific refactoring instructions • Compatible with all AI assistants (Claude, GPT, Cursor, Continue, etc.) Perfect for developers learning refactoring patterns while maintaining full control over code changes. Acts as a refactoring mentor rather than an automated code modifier.

1.2K

9 Tools

Packaged by
Add to Docker Desktop

Version 4.43 or later needs to be installed to add the server automatically

About

Python Refactoring Assistant MCP Server

Educational Python refactoring assistant that provides guided suggestions for AI assistants.

Features: • Step-by-step refactoring instructions without modifying code • Comprehensive code analysis using professional tools (Rope, Radon, Vulture, Jedi, LibCST, Pyrefly) • Educational approach teaching refactoring patterns through guided practice • Support for both guide-only and apply-changes modes • Identifies long functions, high complexity, dead code, and type issues • Provides precise line numbers and specific refactoring instructions • Compatible with all AI assistants (Claude, GPT, Cursor, Continue, etc.)

Perfect for developers learning refactoring patterns while maintaining full control over code changes. Acts as a refactoring mentor rather than an automated code modifier. .

What is an MCP Server?

Characteristics

AttributeDetails
Docker Imagemcp/mcp-python-refactoring
Authorslamer59
Repositoryhttps://github.com/slamer59/mcp-python-refactoring
Dockerfilehttps://github.com/slamer59/mcp-python-refactoring/blob/main/Dockerfile
Docker Image built byDocker Inc.
Docker Scout Health ScoreDocker Scout Health Score
Verify SignatureCOSIGN_REPOSITORY=mcp/signatures cosign verify mcp/mcp-python-refactoring --key https://raw.githubusercontent.com/docker/keyring/refs/heads/main/public/mcp/latest.pub
LicenceMIT License

Available Tools (9)

Tools provided by this ServerShort Description
analyze_python_fileAnalyze Python file for refactoring opportunities with precise guidance
analyze_python_packageComprehensive package/folder analysis for refactoring opportunities
analyze_security_and_patternsComprehensive security scanning and modern Python patterns analysis
analyze_test_coverageAnalyze Python test coverage and suggest improvements
find_long_functionsFind functions that are candidates for extraction
find_package_issuesIdentify package-level refactoring opportunities and structural issues
get_extraction_guidanceGet detailed step-by-step guidance for extracting functions
get_package_metricsGet aggregated metrics for a Python package
tdd_refactoring_guidanceGenerate TDD-based refactoring guidance: test first, refactor, test again

Tools Details

Tool: analyze_python_file

Analyze Python file for refactoring opportunities with precise guidance

ParametersTypeDescription
contentstringPython file content to analyze
file_pathstringoptionalPath to Python file to analyze

Tool: analyze_python_package

Comprehensive package/folder analysis for refactoring opportunities

ParametersTypeDescription
package_pathstringPath to Python package/folder to analyze
package_namestringoptionalName of the package (optional, will be inferred from path)

Tool: analyze_security_and_patterns

Comprehensive security scanning and modern Python patterns analysis

ParametersTypeDescription
contentstringPython file content to analyze
file_pathstringoptionalPath to Python file to analyze
include_dependency_scanbooleanoptionalInclude dependency vulnerability scanning (default: true)
include_modernizationbooleanoptionalInclude modern Python pattern suggestions (default: true)
include_security_scanbooleanoptionalInclude code security vulnerability scanning (default: true)

Tool: analyze_test_coverage

Analyze Python test coverage and suggest improvements

ParametersTypeDescription
source_pathstringPath to source code directory or file
target_coverageintegeroptionalTarget coverage percentage (default: 80)
test_pathstringoptionalPath to test directory (optional)

Tool: find_long_functions

Find functions that are candidates for extraction

ParametersTypeDescription
contentstringPython file content to analyze
line_thresholdintegeroptionalMinimum lines to consider a function long (default: 20)

Tool: find_package_issues

Identify package-level refactoring opportunities and structural issues

ParametersTypeDescription
package_pathstringPath to Python package/folder
issue_typesarrayoptionalSpecific types of issues to look for (optional): scattered_functionality, god_package, circular_dependency, etc.

Tool: get_extraction_guidance

Get detailed step-by-step guidance for extracting functions

ParametersTypeDescription
contentstringPython file content
file_pathstringoptionalPath to Python file
function_namestringoptionalName of function to analyze for extraction

Tool: get_package_metrics

Get aggregated metrics for a Python package

ParametersTypeDescription
package_pathstringPath to Python package/folder
package_namestringoptionalName of the package (optional)

Tool: tdd_refactoring_guidance

Generate TDD-based refactoring guidance: test first, refactor, test again

ParametersTypeDescription
contentstringPython code content to refactor
function_namestringoptionalSpecific function/class to refactor (optional)
test_pathstringoptionalPath to test directory (optional)

Use this MCP Server

{
  "mcpServers": {
    "mcp-python-refactoring": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp/mcp-python-refactoring"
      ]
    }
  }
}

Why is it safer to run MCP Servers with Docker?

Manual installation

You can install the MCP server using:

Installation for

Related servers