
Ohm Mcp
io.github.MurugarajrPublished by GitHub account Murugarajrv1.0.1Updated Oct 24, 2026
AST-based Python refactoring MCP server with safe automated refactorings and rollback
Overview
AST-based Python refactoring assistant that lets an AI client analyze code quality, plan refactorings, and apply them with backups and rollback.
- What you can do
- Analyze codebases and plan refactorings, including function-level proposals, explanations and unified diff patches
- Detect architecture and design issues such as God Objects, SOLID violations, tight coupling and design pattern opportunities
- Find code quality problems: dead code, duplicates, wildcard imports, and extract methods or rename symbols across a project
- Assess type coverage, generate type stubs and characterization tests, and flag performance hotspots like nested loops
- Apply refactorings with dry-run previews, backups, test validation and rollback, and review the operation history
- Produce quality reports and dashboards in HTML, Markdown or JSON
- When to use it
- Useful when working on an existing Python codebase and you want the assistant to find dead code, duplication, type gaps or performance issues and then carry out refactorings safely. Also suited to teams tracking technical debt or adding quality checks to CI.
- Requirements
- Runs locally over stdio. Either Node.js for the npm package via npx, or Python with the PyPI package installed and the interpreter path configured in the MCP client. No accounts, API keys or environment variables are declared.
Installation
In SourceWeft
- Open Ohm Mcp in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
OHM-MCP
AI-Powered Python Refactoring & Code Quality Assistant
Works with GitHub Copilot, Cursor IDE, Cline, and any MCP-compatible AI assistant.
✨ Core Capabilities
🚀 Quick Start
Installation
📦 Recommended: NPM Method (Auto-installs dependencies)
No installation required! Use NPX to run the latest version automatically:
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:
Install from source (for development):
IDE Configuration
📦 Option 1: NPX (Recommended - Auto-installs dependencies)
🔵 GitHub Copilot (VS Code) with NPX
After publishing to npm:
For local development:
Usage:
- Open Copilot Chat
- Type
#and selectohm-mcptools - Ask: "Analyze this file and suggest refactorings"
🟣 Cursor IDE with NPX
Global (After publishing to npm):
For local development:
Usage:
- Open Cursor Chat (Cmd+L / Ctrl+L)
- Tools are automatically available
- Ask: "Use ohm-mcp to detect dead code"
🟢 Cline (VS Code Extension) with NPX
Global (After publishing to npm):
For local development:
Usage:
- Open Cline panel
- Tools are available in agent context
- Ask: "Analyze type coverage and suggest improvements"
🟠 Antigravity with NPX
Global (After publishing to npm):
Usage:
- Tools are automatically available in Antigravity
- Ask: "Use ohm-mcp to analyze architecture"
🔴 Roo Code with NPX
Global (After publishing to npm):
Usage:
- Open Roo Code panel
- Tools are available in agent context
- Ask: "Use ohm-mcp to detect duplicates"
⚫ Codex VS Code with NPX
Configuration (config.toml):
Usage:
- Open Codex panel
- Tools are automatically available
- Ask: "Use ohm-mcp to suggest design patterns"
🟡 Kilo Code with NPX (Local/Global)
Local (For local development with virtual environment):
Global (After publishing to npm):
Usage:
- Open Kilo Code panel
- Tools are available in agent context
- Ask: "Use ohm-mcp for refactoring"
🐍 Option 2: Direct Python (Manual setup)
🔵 GitHub Copilot (VS Code) with Python
First install: pip install ohm-mcp
Then add to .vscode/mcp.json:
Usage:
- Open Copilot Chat
- Type
#and selectohm-mcptools - Ask: "Analyze this file and suggest refactorings"
🟣 Cursor IDE with Python
First install: pip install ohm-mcp
Then add to Cursor's MCP settings file (.cursorrules or MCP config):
Example with virtual environment:
Usage:
- Open Cursor Chat (Cmd+L / Ctrl+L)
- Tools are automatically available
- Ask: "Use ohm-mcp to detect dead code"
🟢 Cline (VS Code Extension) with Python
First install: pip install ohm-mcp
Then add to Cline's MCP settings:
Example with virtual environment:
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"
🔧 Other MCP-Compatible Clients
Any MCP-compatible client can use this server. General configuration:
Finding your Python path:
💡 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
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
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
Detects:
- ✅ God Objects (classes doing too much)
- ✅ SOLID principle violations
- ✅ Circular dependencies
- ✅ High coupling issues
✂️ Extract Method Refactoring
Automatically:
- ✅ Detects required parameters
- ✅ Identifies return values
- ✅ Generates refactored code
- ✅ Creates unified diff patch
🔄 Safe Symbol Renaming
Features:
- ✅ AST-based (100% accurate)
- ✅ Detects naming conflicts
- ✅ Shows all occurrences before applying
- ✅ Updates docstrings and comments
📊 Type Coverage Analysis
Provides:
- ✅ Coverage percentage and grade
- ✅ Functions missing type hints
- ✅ Suggested type annotations
- ✅ Migration plan with priorities
⚡ Performance Optimization
Detects:
- ✅ Nested loops (O(n²) complexity)
- ✅ Quadratic list operations
- ✅ Repeated function calls (missing caching)
- ✅ Mutable default arguments
- ✅ Inefficient string concatenation
🧪 Auto-Generate 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
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
Handles:
- ✅ Direct imports (
import old.module) - ✅ From imports (
from old.module import X) - ✅ Submodule imports
- ✅ Import aliases
🎯 Key Tools (30 Total)
📋 General Analysis & Planning (4 tools)
🏗️ Architecture & Design (4 tools)
🔧 Code Quality & Refactoring (10 tools)
Example - Extract Method:
📊 Type Safety & Testing (5 tools)
⚡ Performance & Prioritization (2 tools)
🤖 Automated Execution & History (4 tools)
Features:
- ✅ Automatic backup before changes
- ✅ Test execution validation
- ✅ Auto-rollback on failure
- ✅ Full audit trail with history
- ✅ Automatic backup cleanup
📈 Metrics & Reporting (1 tool)
generate_quality_report - Comprehensive dashboard in HTML/Markdown/JSON
Output Preview:
Visual Dashboard:
- 🎨 Circular health gauge
- 📊 Color-coded metrics (🟢🟡🔴)
- 📈 Trend tracking ready
- 🔗 CI/CD integration (JSON export)
💡 Common Workflows
1️⃣ Safe Refactoring
2️⃣ Eliminate Duplication
3️⃣ Type Migration
4️⃣ Performance Optimization
5️⃣ Module Refactoring
6️⃣ Symbol Renaming
7️⃣ Quality Tracking
🎨 Visual Examples
Quality Dashboard Preview
Symbol Rename Preview
🧠 Design Principles
🔌 IDE Compatibility
📊 Comparison
🎯 Use Cases
📈 Metrics
🛠️ Troubleshooting
MCP Connection Issues
-
Verify Python path:
-
Test MCP server directly:
-
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:
🙏 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!
Source: README.md at commit 755d161
Tools
0Version history
1- v1.0.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts