MCP Server Python · AST · Tests
New AI refactoring assistant for your IDE

Ship safer refactors without leaving chat.

Analyze Python code, design refactors, apply with backups, and run tests—all from your IDE.

Live in your local repo ⚙️ MCP · No cloud data upload 🧪 Test‑first, rollback‑safe refactors
Real‑time IDE integration Host: MCP
GitHub Copilot Chat Cursor IDE Cline (VS Code)
MCP connected
🧠 AST‑based analysis
✅ Dry‑run & rollback
Code Health Snapshot from generate_quality_report
85
Health / 100
📊 Type coverage: 67% 🗑️ Dead code issues: 23 ⚡ Perf hotspots: 6 📋 Duplicated lines: 140 🔁 Safe refactors: Backups + tests

What OHM-MCP Refactor does

Architecture, refactoring, tests & metrics in one server
🏗 Architecture & design God objects · SOLID

Detect violations and get pattern suggestions with DI refactors.

🔧 Code refactoring AST‑true

Extract methods, detect dead code, refactor imports, and rename symbols safely.

📊 Type safety & tests

Analyze type coverage, generate stubs, and auto-create tests for safe refactors.

⚡ Performance hotspots

Catch performance smells and prioritize fixes by coverage.

🤖 Automated, reversible execution

Dry-run, backup, apply patches, run tests, and auto-rollback on failure.

📈 Quality dashboard

Generate HTML, Markdown, and JSON reports with health scores and metrics.

🧬 Project‑wide symbol ops

Safely rename symbols across the entire project with conflict detection.

📦 Safer module migrations

Refactor imports when moving modules, keeping all call sites in sync.

Works where you code

Use the same MCP server across multiple IDEs
GitHub Copilot (VS Code)
Add to .vscode/mcp.json and use in Copilot Chat.
{ "servers": { "ohm-mcp-refactor": { "command": "python", "args": ["${workspaceFolder}/mcp_server.py"] } } }
Cursor IDE
Register in Cursor MCP settings. Tools appear in AI sidebar.
{ "mcpServers": { "ohm-mcp-refactor": { "command": "/path/to/python", "args": [ "${workspaceFolder}/ohm-mcp-refactor/mcp_server.py" ] } } }
Cline (VS Code)
Configure in Cline's MCP servers as your refactoring agent.
{ "mcpServers": { "ohm-mcp-refactor": { "command": "/path/to/python", "args": ["mcp_server.py"], "cwd": "/abs/path/to/ohm-mcp-refactor" } } }
Any MCP‑compatible host
Use with any MCP-aware assistant for consistent refactoring.
{ "mcpServers": { "ohm-mcp-refactor": { "command": "", "args": ["/mcp_server.py"], "cwd": "" } } }

Typical workflows

Everything lives in chat + patch view
🧪 Safe refactor loop

Generate tests → apply refactoring → run tests with automatic backups.

📋 Eliminate duplication

Detect duplicates and extract shared functions to reduce violations.

📊 Type‑hint migration

Gradually improve type coverage with prioritized hints and stubs.

⚡ Performance hardening

Focus optimization where complexity is high and tests are thin.

📦 Module & API reshapes

Safely move modules, rename APIs, and verify all tests still pass.

📈 CI quality gate

Enforce health scores in CI and track debt reduction over time.

🧵 Large feature refactor

Design refactor sequences and apply with test gates at each step.

🛡️ Legacy code hardening

Wrap legacy modules with tests and types before touching behavior.