Mcp Python Refactoring
About
Educational Python refactoring assistant with guided suggestions for AI assistants
Explore
Returns server capabilities and available analysis tools.
Returns: List of available tools: rope, radon, vulture, jedi, libcst, pyrefly, mccabe, complexipy
Code Quality Issues Detected:
- Functions over 20 lines (extract method opportunities)
- High cyclomatic complexity (>10) using McCabe analysis
- High cognitive complexity (>15) using Complexipy analysis
- Functions with too many parameters (>5)
- Dead/unused code (consolidated suggestions) via Vulture
- Low maintainability index (<20) using Radon metrics
- Type annotation problems detected by Pyrefly
- Large files (>500 lines) with module splitting recommendations
- Files with too many imports (>20) suggesting restructuring
Additional Analysis Tools:
- Security Analysis: Vulnerability detection and security best practices
- Performance Analysis: Bottleneck identification and optimization suggestions
- Type Hints: Missing type annotation detection
- Documentation: Docstring coverage and quality assessment
Professional Tools Used:
- Rope: Professional refactoring analysis and extract method detection
- Radon: Code complexity metrics (cyclomatic, maintainability index)
- Vulture: Dead code detection and unused import analysis
- Jedi: Semantic code analysis and variable tracking
- LibCST: Syntax tree manipulation for precise code analysis
- Pyrefly: Advanced type checking and quality analysis
- McCabe: Cyclomatic complexity measurement
- Complexipy: Advanced complexity analysis and cognitive complexity
- Built-in File Analysis: File size analysis and module splitting recommendations
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
Mcp Python RefactoringCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Once all registries are live, users can discover via:
- MCP catalog - Official registry search
- Docker Desktop - MCP Toolkit integration
- Community lists - GitHub awesome lists
- Docker Hub - mcp/mcp-python-refactoring (with enhanced security)
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir -e .
uvx --from git+https://github.com/slamer59/mcp-python-refactoring.git python-refactor server
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!
bash
git clone https://github.com/slamer59/mcp-python-refactoring.git
cd mcp-python-refactoring
uv sync
pip install -e .
python-refactor server
Fast analysis for immediate refactoring opportunities.
Parameters:
- content (required): Python file content
Returns: Quick summary of long functions and parameter issues
curl -fsSL https://bun.sh/install | bash
bun install -g @modelcontextprotocol/sdk
client-name --mcp-server "python -m mcp_refactoring_assistant server"
pip install mcpo
For AI Coding Assistants:
- Provides structured JSON responses with refactoring opportunities
- Identifies long functions, high complexity code, and dead code
- Gives precise line numbers for extract method refactoring
- Uses professional tools for comprehensive analysis
For Developers:
- Get step-by-step refactoring instructions
- Maintain full control over code changes
- Learn refactoring patterns through guided practice
- Improve code quality systematically
python -c "
from src.mcp_refactoring_assistant.server import EnhancedRefactoringAnalyzer
analyzer = EnhancedRefactoringAnalyzer()
print('Analyzer working')
"
```
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp python refactoring": {
"python-refactoring": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/slamer59/mcp-python-refactoring.git",
"python-refactor",
"server"
]
}
}
}
}
McpServers
{
"python-refactoring": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/slamer59/mcp-python-refactoring.git",
"python-refactor",
"server"
]
}
}
A Model Context Protocol (MCP) server that analyzes Python code and provides guided refactoring suggestions without automatically modifying your code.
Keywords
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.
What This Tool Does
For AI Coding Assistants:
- Provides structured JSON responses with refactoring opportunities
- Identifies long functions, high complexity code, and dead code
- Gives precise line numbers for extract method refactoring
- Uses professional tools for comprehensive analysis
For Developers:
- Get step-by-step refactoring instructions
- Maintain full control over code changes
- Learn refactoring patterns through guided practice
- Improve code quality systematically
How It Differs
| 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 |
Registry Submissions
This MCP server is available across the entire MCP ecosystem:
Official MCP Registry
Published and Live: registry.modelcontextprotocol.io - Server name:io.github.slamer59/mcp-python-refactoring
- Discoverable by all MCP-compatible clients
🟡 Docker MCP Registry
Pull Request Submitted: docker/mcp-registry #207 - Will be available asmcp/mcp-python-refactoring on Docker Hub
- Includes enhanced security: signatures, SBOM, provenance tracking
- Integrated into Docker Desktop's MCP Toolkit
🟡 Awesome MCP Servers Lists
Community Curated Lists: - appcypher/awesome-mcp-servers #180 - Development Tools section - punkpeye/awesome-mcp-servers #1321 - Code Execution section📦 Installation Options
Once all registries are live, users can discover via: - MCP catalog - Official registry search - Docker Desktop - MCP Toolkit integration - Community lists - GitHub awesome lists - Docker Hub -mcp/mcp-python-refactoring (with enhanced security)
Docker Support
Using with Docker MCP Catalog
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



