ohm-mcp MCP Server
AST-based Python refactoring MCP server with safe automated refactorings and rollback
ohm-mcp scores 53 (Fair), licensed MIT and written in Python. It installs as a local process. It declares 29 tools. Filed under Developer tools. GitHub shows 2 stars. Package registries report about 131 downloads a week. Install configs are generated for 10 clients. Being listed in the registry is not the same as being vendor-official.
Fair trust
53 of 100 from six public signals. Nobody can buy a point.
- Listed in the official MCP registry.
- OSI-style license: mit.
License, quality and maintenance
Quality: Grade B
73/100 for listing completeness. Lost points: 24 of 29 tools barely described, short summary, no docs link.
How quality is graded
Where the 53 comes from
22 + 5 + 2 + 10 + 4 + 10 = 53. Each factor is capped, so no single signal can carry a listing.
Active in the official MCP registry, plus a known vendor namespace.
Registry: 22 of 30 points.How recently the repository saw a commit or release.
Maintenance: 5 of 20 points.GitHub stars and weekly downloads, on a log scale.
Popularity: 2 of 20 points.A clear, OSI-style open-source license.
License: 10 of 10 points.Not archived, a secure install path, a pinned version.
Security: 4 of 10 points.A real summary, a README with depth, listed tools.
Docs: 10 of 10 points.Install
Pick your client, copy the config, paste it in.
Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.
{ "mcpServers": { "murugarajr-ohm-mcp": { "command": "npx", "args": [ "-y", "ohm-mcp@1.0.1" ] } }}
Environment variables
This server does not declare environment variables.
Tools29Tool docs quality grade D
All capabilitiesDetect God Objects, SOLID violations
analyze_codebasetoolComprehensive code analysis
Find bottlenecks
Find coupling issues
Check type coverage
Find wildcard imports
Apply function-level refactor
Auto-apply refactoring with safety checks
Clean up old backup files
Generate unified diff patches
Find DRY violations
detect_dead_codetoolFind unused code
About
OHM-MCP
AI-Powered Python Refactoring & Code Quality Assistant
Works with GitHub Copilot, Cursor IDE, Cline, and any MCP-compatible AI assistant.
โจ Core Capabilities
๐๏ธ Architecture
- God Object Detection
- SOLID Violation Analysis
- Design Pattern Suggestions
- Dependency Injection Refactoring
๐ง Code Quality
- AST Extract Method (100% accurate)
- Dead Code Elimination
- Import Refactoring
- Symbol Renaming (project-wide)
- Duplication Detection
๐ Type Safety
- Type Coverage Analysis
- Type Stub Generation
- Auto Test Generation
โก Performance
- O(nยฒ) Pattern Detection
- Hotspot Analysis
- Coverage-Driven Prioritization
๐ค Automation
- Auto-Apply with Rollback
- Operation History
- Quality Dashboard
๐ Quick Start
Installation
๐ฆ Recommended: NPM Method (Auto-installs dependencies)
No installation required! Use NPX to run the latest version automatically:
npx -y ohm-mcp@latest
This is the easiest way to get started. Just add the configuration to your AI assistant (see IDE Configuration below).
MCP Registry: mcp-name: io.github.Murugarajr/ohm-mcp
๐ Alternative: PyPI Method (For local development)
Use this method when you need to:
- Develop locally with the Python package
- Use a specific Python virtual environment
- Install from source for customization
Install from PyPI:
pip install ohm-mcp
Install from source (for development):
pip install -e .
IDE Configuration
๐ฆ Option 1: NPX (Recommended - Auto-installs dependencies)
After publishing to npm:
{
"mcpServers": {
"ohm-mcp": {
"command": "npx",
"args": ["ohm-mcp@latest"]
}
}
}
For local development:
{
"mcpServers": {
"ohm-mcp": {
"command": "npx",
"args": ["--package", "/path/to/ohm-mcp-npm", "ohm-mcp"]
}
}
}
Usage:
- Open Copilot Chat
- Type
#and selectohm-mcptools - Ask: "Analyze this file and suggest refactorings"
Global (After publishing to npm):
{
"mcpServers": {
"ohm-mcp": {
"command": "npx",
"args": ["-y", "ohm-mcp@latest"]
}
}
}
For local development:
{
"mcpServers": {
"ohm-mcp": {
"command": "npx",
"args": ["--package", "/path/to/ohm-mcp-npm", "ohm-mcp"]
}
}
}
Usage:
- Open Cursor Chat (Cmd+L / Ctrl+L)
- Tools are automatically available
- Ask: "Use ohm-mcp to detect dead code"
Global (After publishing to npm):
{
"mcpServers": {
"ohm-mcp": {
"command": "npx",
"args": ["-y", "ohm-mcp@latest"]
}
}
}
For local development:
{
"mcpServers": {
"ohm-mcp": {
"command": "npx",
"args": ["--package", "/path/to/ohm-mcp-npm", "ohm-mcp"]
}
}
}
Usage:
- Open Cline panel
- Tools are available in agent context
- Ask: "Analyze type coverage and suggest improvements"
Global (After publishing to npm):
{
"mcpServers": {
"ohm-mcp": {
"command": "npx",
"args": ["-y", "ohm-mcp@latest"],
"env": {
"PYTHONUNBUFFERED": "1"
}
}
}
}
Usage:
- Tools are automatically available in Antigravity
- Ask: "Use ohm-mcp to analyze architecture"
Global (After publishing to npm):
{
"mcpServers": {
"ohm-mcp": {
"command": "npx",
"args": ["-y", "ohm-mcp@latest"]
}
}
}
Usage:
- Open Roo Code panel
- Tools are available in agent context
- Ask: "Use ohm-mcp to detect duplicates"
Configuration (config.toml):
[mcp_servers.ohm-mcp]
args = ["-y", "ohm-mcp@latest"]
command = "npx"
Usage:
- Open Codex panel
- Tools are automatically available
- Ask: "Use ohm-mcp to suggest design patterns"
Local (For local development with virtual environment):
{
"mcpServers": {
"ohm-mcp": {
"command": "/Users/username/project/venv/bin/python",
"args": ["-m", "ohm_mcp.server"],
"disabled": false,
"alwaysAllow": []
}
}
}
Global (After publishing to npm):
{
"mcpServers": {
"ohm-mcp": {
"command": "npx",
"args": ["-y", "ohm-mcp@latest"]
}
}
}
Usage:
- Open Kilo Code panel
- Tools are available in agent context
- Ask: "Use ohm-mcp for refactoring"
๐ Option 2: Direct Python (Manual setup)
First install: pip install ohm-mcp
Then add to .vscode/mcp.json:
{
"servers": {
"ohm-mcp": {
"command": "python",
"args": ["-m", "ohm_mcp.server"]
}
},
"inputs": []
}
Usage:
- Open Copilot Chat
- Type
#and selectohm-mcptools - Ask: "Analyze this file and suggest refactorings"
First install: pip install ohm-mcp
Then add to Cursor's MCP settings file (.cursorrules or MCP config):
{
"mcpServers": {
"ohm-mcp": {
"command": "python",
"args": ["-m", "ohm_mcp.server"]
}
},
"inputs": []
}
Example with virtual environment:
{
"mcpServers": {
"ohm-mcp": {
"command": "/Users/username/projects/venv/bin/python",
"args": ["-m", "ohm_mcp.server"]
}
}
}
Usage:
- Open Cursor Chat (Cmd+L / Ctrl+L)
- Tools are automatically available
- Ask: "Use ohm-mcp to detect dead code"
First install: pip install ohm-mcp
Then add to Cline's MCP settings:
{
"mcpServers": {
"ohm-mcp": {
"command": "python",
"args": ["-m", "ohm_mcp.server"]
}
}
}
Example with virtual environment:
{
"mcpServers": {
"ohm-mcp": {
"command": "/Users/username/projects/venv/bin/python",
"args": ["-m", "ohm_mcp.server"]
}
}
}
Note: Cline requires absolute paths for both command and cwd.
Usage:
- Open Cline panel
- Tools are available in agent context
- Ask: "Analyze type coverage and suggest improvements"
Any MCP-compatible client can use this server. General configuration:
{
"mcpServers": {
"ohm-mcp": {
"command": "<python-interpreter-path>",
"args": ["<path-to-mcp_server.py>"],
"cwd": "<project-directory>"
}
}
}
Finding your Python path:
# Unix/Mac
which python
# or
which python3
# Windows
where python
๐ก Quick Usage Examples
Once configured, simply reference tools in your AI assistant chat using the format: use #ohm-mcp.tool_name on the current file or @file_name.py
๐๏ธ Find Dead Code
Use #ohm-mcp.detect_dead_code on @utils.py
This will detect:
- โ Unused imports (import statements never referenced)
- โ Unused variables (assigned but never read)
- โ Unreachable code (after return/raise/break/continue)
- โ Unused functions (defined but never called)
- โ Shadowed variables (inner scope hides outer scope variable)
๐ Code Duplication Detection
Use #ohm-mcp.detect_code_duplicates to find duplicates in /path/to/project
Finds:
- โ Exact duplicates (100% identical code blocks)
- โ Near duplicates (90%+ similarity)
- โ Duplicate functions (same structure, different names)
- โ Provides refactoring suggestions to eliminate duplication
๐๏ธ Architecture Analysis
Analyze architecture of @my_module.py using #ohm-mcp.analyze_architecture
Detects:
- โ God Objects (classes doing too much)
- โ SOLID principle violations
- โ Circular dependencies
- โ High coupling issues
โ๏ธ Extract Method Refactoring
Use #ohm-mcp.extract_method_ast to extract lines 45-60 from @handler.py into a new function called "process_request"
Automatically:
- โ Detects required parameters
- โ Identifies return values
- โ Generates refactored code
- โ Creates unified diff patch
๐ Safe Symbol Renaming
Use #ohm-mcp.rename_symbol to rename "old_function_name" to "new_function_name" in /path/to/project
Features:
- โ AST-based (100% accurate)
- โ Detects naming conflicts
- โ Shows all occurrences before applying
- โ Updates docstrings and comments
๐ Type Coverage Analysis
Analyze type hints in @module.py using #ohm-mcp.analyze_type_hints
Provides:
- โ Coverage percentage and grade
- โ Functions missing type hints
- โ Suggested type annotations
- โ Migration plan with priorities
โก Performance Optimization
Use #ohm-mcp.analyze_performance on @slow_module.py
Detects:
- โ Nested loops (O(nยฒ) complexity)
- โ Quadratic list operations
- โ Repeated function calls (missing caching)
- โ Mutable default arguments
- โ Inefficient string concatenation
๐งช Auto-Generate Tests
Generate tests for @calculator.py using #ohm-mcp.generate_characterization_tests
Creates:
- โ Happy path test cases
- โ Edge cases (None, zero, negative, empty)
- โ Ready-to-run pytest code
- โ Preserves current behavior before refactoring
๐จ Design Pattern Suggestions
Suggest design patterns for @legacy_code.py using #ohm-mcp.suggest_design_patterns
Recommends:
- โ Strategy pattern for long if/elif chains
- โ Factory pattern for repetitive object creation
- โ Observer pattern for callback hell
- โ Decorator pattern for cross-cutting concerns
๐ง Import Refactoring
Use #ohm-mcp.refactor_imports to update all files in /path/to/project from "old.module" to "new.module"
Handles:
- โ
Direct imports (
import old.module) - โ
From imports (
from old.module import X) - โ Submodule imports
- โ Import aliases
๐ฏ Key Tools (30 Total)
| Tool | Purpose | Output |
|---|---|---|
analyze_codebase | Comprehensive code analysis | Issues + refactoring plan |
propose_function_refactor | Function-level refactor planning | Detailed refactor proposal |
explain_refactoring | Explain refactoring patterns | Educational guidance |
create_refactor_patch | Generate unified diff patches | Patch file |
| Tool | Purpose | Output |
|---|---|---|
analyze_architecture | Detect God Objects, SOLID violations | Detailed issue report |
suggest_design_patterns | Recommend patterns (Strategy, Factory, Observer) | Pattern suggestions + examples |
analyze_tight_coupling | Find coupling issues | DI recommendations |
suggest_di_refactor | Generate DI code | Before/after refactor |
| Tool | Purpose | Key Feature |
|---|---|---|
extract_method_ast | Extract code into function | 100% AST-based accuracy |
suggest_extractable_methods | Find extractable blocks | Cohesion scoring |
detect_dead_code | Find unused code | 5 types of dead code |
refactor_imports | Update imports project-wide | Safe module renaming |
refactor_single_file_imports | Refactor imports in one file | Single file focus |
analyze_wildcard_imports | Find wildcard imports | Explicit replacements |
rename_symbol | Rename across codebase | Conflict detection |
detect_code_duplicates | Find DRY violations | Exact + near duplicates |
extract_function_code | Extract single function code | Code extraction utility |
apply_function_refactor | Apply function-level refactor | Direct code modification |
Example - Extract Method:
# Input: Lines 45-60
result = extract_method_ast(code, 45, 60, "calculate_total")
# Output: Refactored code + patch + auto-detected params/returns
| Tool | Purpose | Benefit |
|---|---|---|
analyze_type_hints | Check type coverage | Migration plan |
generate_type_stub | Create .pyi files | Gradual typing |
generate_characterization_tests | Auto-generate tests | Safe refactoring |
generate_test_for_function | Single function tests | Targeted testing |
suggest_tests | Suggest test strategies | Test planning |
| Tool | Purpose | Detects |
|---|---|---|
analyze_performance | Find bottlenecks | Nested loops, mutable defaults, O(nยฒ) |
prioritize_by_coverage | Risk-based prioritization | High-risk uncovered code |
graph LR
A[apply_refactoring] --> B{Dry Run?}
B -->|Yes| C[Show Preview]
B -->|No| D[Create Backup]
D --> E[Apply Changes]
E --> F{Run Tests}
F -->|Pass| G[Success]
F -->|Fail| H[Auto Rollback]
H --> I[rollback_refactoring]
| Tool | Purpose |
|---|---|
apply_refactoring | Auto-apply refactoring with safety checks |
rollback_refactoring | Rollback previous refactoring |
show_refactoring_history | View refactoring audit trail |
cleanup_old_backups | Clean up old backup files |
Features:
- โ Automatic backup before changes
- โ Test execution validation
- โ Auto-rollback on failure
- โ Full audit trail with history
- โ Automatic backup cleanup
generate_quality_report - Comprehensive dashboard in HTML/Markdown/JSON
Output Preview:
๐ Health Score: 85/100 (Good)
๐ Files: 47 | Lines: 12,450 | Tech Debt: 23 pts
๐ Type Coverage: 67%
๐๏ธ Dead Code: 8 imports, 12 variables, 3 functions
โก Performance: 4 nested loops, 2 mutable defaults
๐ Duplication: 3 exact, 5 near-duplicates
Visual Dashboard:
- ๐จ Circular health gauge
- ๐ Color-coded metrics (๐ข๐ก๐ด)
- ๐ Trend tracking ready
- ๐ CI/CD integration (JSON export)
๐ก Common Workflows
1๏ธโฃ Safe Refactoring
generate_characterization_tests โ pytest โ extract_method_ast โ pytest
2๏ธโฃ Eliminate Duplication
detect_code_duplicates โ review suggestions โ extract_method_ast
3๏ธโฃ Type Migration
analyze_type_hints โ follow migration plan โ generate_type_stub
4๏ธโฃ Performance Optimization
analyze_performance โ prioritize_by_coverage โ apply fixes
5๏ธโฃ Module Refactoring
refactor_imports(old="myapp.old", new="myapp.new") โ review patches
6๏ธโฃ Symbol Renaming
rename_symbol(old="calc", new="calculate", preview_only=True) โ apply
7๏ธโฃ Quality Tracking
generate_quality_report(format="html") โ open dashboard โ track trends
๐จ Visual Examples
Quality Dashboard Preview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Code Quality Dashboard โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โญโโโโโโโโโโฎ ๐ Overview โ
โ โ 85 โ Files: 47 โ
โ โ /100 โ Lines: 12,450 โ
โ โฐโโโโโโโโโโฏ Tech Debt: 23 โ
โ Health Score โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Type Coverage โก Performance โ
โ โโโโโโโโโโ 67% ๐ด 4 nested loops โ
โ 120/180 typed ๐ก 2 mutable args โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐๏ธ Dead Code ๐ Duplication โ
โ 8 imports 3 exact โ
โ 12 variables 5 near โ
โ 3 functions โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Symbol Rename Preview
# Before
- def calc(x, y):
- return x + y
- result = calc(5, 3)
# After
+ def calculate_sum(x, y):
+ return x + y
+ result = calculate_sum(5, 3)
โ
1 function renamed
โ
3 call sites updated
โ
0 conflicts detected
๐ง Design Principles
| Principle | Implementation |
|---|---|
| ๐งช Test-First | Auto-generate characterization tests before refactoring |
| โฉ๏ธ Reversible | Every change = backup + rollback capability |
| ๐ฏ AST-Driven | 100% accurate (no regex) |
| ๐ Risk-Aware | Coverage + complexity = prioritization |
| ๐๏ธ SOLID | Detect violations + concrete fixes |
| ๐ซ No Blindness | Analyze โ Plan โ Validate |
๐ IDE Compatibility
๐ Comparison
| Feature | OHM MCP | Traditional Tools |
|---|---|---|
| Accuracy | 100% AST | ~70% Regex |
| Safety | Auto backup/rollback | Manual |
| Testing | Auto-generates | Manual |
| Automation | Full | Suggestions only |
| Dashboard | HTML/JSON/MD | Text logs |
| IDE Support | Copilot/Cursor/Cline | Limited |
๐ฏ Use Cases
๐ Metrics
โ
30 MCP Tools
โ
40+ Static Checks
โ
100% AST Accuracy
โ
Zero Regex Patterns
โ
Automated Execution with Rollback
โ
Beautiful Dashboards (HTML/JSON/MD)
โ
Universal MCP Compatibility
โ
Safe Refactoring with Auto-Backup
๐ ๏ธ Troubleshooting
-
Verify Python path:
which python # Unix/Mac where python # Windows -
Test MCP server directly:
python -m ohm_mcp.server -
Check logs:
- VS Code: Check Output panel
- Cursor: Check Cursor logs
- Cline: Check Cline settings panel
-
Common issues:
- โ Relative paths in
commandโ Use absolute paths - โ Missing virtual environment โ Activate venv first
- โ Wrong
cwdfor Cline โ Must be absolute path
- โ Relative paths in
๐ค Contributing
Run before submitting:
./static_analyser.sh # Runs ruff, mypy, pylint, flake8
pytest # All tests must pass
๐ Credits
Built with Model Context Protocol โข Python AST โข Compatible with GitHub Copilot, Cursor IDE, Cline
Made with โค๏ธ for better code quality
โญ Star this repo if it helps you write cleaner code!
Frequently asked questions
What is ohm-mcp MCP Server?
AST-based Python refactoring MCP server with safe automated refactorings and rollback
How do I install ohm-mcp MCP Server in Claude Desktop, Cursor, or VS Code?
Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. ohm-mcp MCP Server runs locally from the npm package ohm-mcp with the command npx -y ohm-mcp@1.0.1.
Is ohm-mcp MCP Server free and open source?
Yes. ohm-mcp MCP Server is released under the MIT license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.
Does ohm-mcp MCP Server support remote (HTTP) connections?
No remote endpoint is listed for ohm-mcp MCP Server. It runs locally on your machine over stdio, started by your MCP client.
What tools does ohm-mcp MCP Server provide?
ohm-mcp MCP Server provides 29 tools, including analyze_architecture, analyze_codebase, analyze_performance, and analyze_tight_coupling. See the full tool list for descriptions and parameters.
How is ohm-mcp MCP Server's trust score calculated?
ohm-mcp MCP Server scores 53 out of 100 (Fair). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.
Reviews
No reviews yetโBe the first to review
No published reviews yet. Used it? Tell the next person how it went.
Sign inA verified email is required to review this server.
Add badge to your README
Paste either snippet into the repository README. The image links to this listing.