OHM-MCP
AST‑first refactoring server for Python codebases
Ship safer refactors without leaving chat.
Analyze Python code, design refactors, apply with backups, and run tests—all from your IDE.
generate_quality_report
What OHM-MCP Refactor does
Architecture, refactoring, tests & metrics in one serverDetect violations and get pattern suggestions with DI refactors.
Extract methods, detect dead code, refactor imports, and rename symbols safely.
Analyze type coverage, generate stubs, and auto-create tests for safe refactors.
Catch performance smells and prioritize fixes by coverage.
Dry-run, backup, apply patches, run tests, and auto-rollback on failure.
Generate HTML, Markdown, and JSON reports with health scores and metrics.
Safely rename symbols across the entire project with conflict detection.
Refactor imports when moving modules, keeping all call sites in sync.
Works where you code
Use the same MCP server across multiple IDEs.vscode/mcp.json and use in Copilot Chat.
{
"servers": {
"ohm-mcp-refactor": {
"command": "python",
"args": ["${workspaceFolder}/mcp_server.py"]
}
}
}
{
"mcpServers": {
"ohm-mcp-refactor": {
"command": "/path/to/python",
"args": [
"${workspaceFolder}/ohm-mcp-refactor/mcp_server.py"
]
}
}
}
{
"mcpServers": {
"ohm-mcp-refactor": {
"command": "/path/to/python",
"args": ["mcp_server.py"],
"cwd": "/abs/path/to/ohm-mcp-refactor"
}
}
}
{
"mcpServers": {
"ohm-mcp-refactor": {
"command": "",
"args": ["/mcp_server.py"],
"cwd": ""
}
}
}
Typical workflows
Everything lives in chat + patch viewGenerate tests → apply refactoring → run tests with automatic backups.
Detect duplicates and extract shared functions to reduce violations.
Gradually improve type coverage with prioritized hints and stubs.
Focus optimization where complexity is high and tests are thin.
Safely move modules, rename APIs, and verify all tests still pass.
Enforce health scores in CI and track debt reduction over time.
Design refactor sequences and apply with test gates at each step.
Wrap legacy modules with tests and types before touching behavior.