ohm-mcp 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ohm_mcp-0.1.5/PKG-INFO +653 -0
- ohm_mcp-0.1.5/README.md +626 -0
- ohm_mcp-0.1.5/pyproject.toml +58 -0
- ohm_mcp-0.1.5/setup.cfg +4 -0
- ohm_mcp-0.1.5/src/ohm_mcp/__init__.py +3 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/__init__.py +40 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/analysis.py +192 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/architecture_analyzer.py +460 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/ast_refactorer.py +544 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/automated_executor.py +555 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/coverage_analyzer.py +511 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/dead_code_detector.py +525 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/dependency_injection_refactorer.py +525 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/duplication_detector.py +580 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/import_refactorer.py +420 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/metrics_reporter.py +533 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/patching.py +42 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/pattern_suggester.py +740 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/performance_analyzer.py +513 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/planning.py +69 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/symbol_renamer.py +586 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/test_generator.py +469 -0
- ohm_mcp-0.1.5/src/ohm_mcp/refactoring/type_hint_analyzer.py +567 -0
- ohm_mcp-0.1.5/src/ohm_mcp/server.py +1199 -0
- ohm_mcp-0.1.5/src/ohm_mcp.egg-info/PKG-INFO +653 -0
- ohm_mcp-0.1.5/src/ohm_mcp.egg-info/SOURCES.txt +28 -0
- ohm_mcp-0.1.5/src/ohm_mcp.egg-info/dependency_links.txt +1 -0
- ohm_mcp-0.1.5/src/ohm_mcp.egg-info/entry_points.txt +2 -0
- ohm_mcp-0.1.5/src/ohm_mcp.egg-info/requires.txt +1 -0
- ohm_mcp-0.1.5/src/ohm_mcp.egg-info/top_level.txt +1 -0
ohm_mcp-0.1.5/PKG-INFO
ADDED
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ohm-mcp
|
|
3
|
+
Version: 0.1.5
|
|
4
|
+
Summary: AI-Powered Python Refactoring & Code Quality Assistant - MCP Server with AST-based analysis
|
|
5
|
+
Author-email: Murugaraj <murugaraj@gmail.com>
|
|
6
|
+
Maintainer-email: Murugaraj <murugaraj@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://www.ohm-mcp.dev
|
|
9
|
+
Keywords: mcp,model-context-protocol,refactoring,code-quality,ast,python,static-analysis,testing,automation,developer-tools
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
Requires-Dist: mcp>=0.1.0
|
|
27
|
+
|
|
28
|
+
<div align="center">
|
|
29
|
+
|
|
30
|
+
<img src="https://raw.githubusercontent.com/Murugarajr/ohm-mcp-pypi/refs/heads/main/image/ohm-mcp.png" alt="OHM-MCP" width="300">
|
|
31
|
+
|
|
32
|
+
# OHM-MCP
|
|
33
|
+
|
|
34
|
+
**AI-Powered Python Refactoring & Code Quality Assistant**
|
|
35
|
+
|
|
36
|
+
Works with **GitHub Copilot**, **Cursor IDE**, **Cline**, and any MCP-compatible AI assistant.
|
|
37
|
+
|
|
38
|
+
[](https://www.python.org/downloads/)
|
|
39
|
+
[](https://modelcontextprotocol.io)
|
|
40
|
+
[]()
|
|
41
|
+
[]()
|
|
42
|
+
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## โจ Core Capabilities
|
|
48
|
+
|
|
49
|
+
<table>
|
|
50
|
+
<tr>
|
|
51
|
+
<td width="50%">
|
|
52
|
+
|
|
53
|
+
### ๐๏ธ **Architecture**
|
|
54
|
+
- God Object Detection
|
|
55
|
+
- SOLID Violation Analysis
|
|
56
|
+
- Design Pattern Suggestions
|
|
57
|
+
- Dependency Injection Refactoring
|
|
58
|
+
|
|
59
|
+
### ๐ง **Code Quality**
|
|
60
|
+
- AST Extract Method (100% accurate)
|
|
61
|
+
- Dead Code Elimination
|
|
62
|
+
- Import Refactoring
|
|
63
|
+
- Symbol Renaming (project-wide)
|
|
64
|
+
- Duplication Detection
|
|
65
|
+
|
|
66
|
+
</td>
|
|
67
|
+
<td width="50%">
|
|
68
|
+
|
|
69
|
+
### ๐ **Type Safety**
|
|
70
|
+
- Type Coverage Analysis
|
|
71
|
+
- Type Stub Generation
|
|
72
|
+
- Auto Test Generation
|
|
73
|
+
|
|
74
|
+
### โก **Performance**
|
|
75
|
+
- O(nยฒ) Pattern Detection
|
|
76
|
+
- Hotspot Analysis
|
|
77
|
+
- Coverage-Driven Prioritization
|
|
78
|
+
|
|
79
|
+
### ๐ค **Automation**
|
|
80
|
+
- Auto-Apply with Rollback
|
|
81
|
+
- Operation History
|
|
82
|
+
- Quality Dashboard
|
|
83
|
+
|
|
84
|
+
</td>
|
|
85
|
+
</tr>
|
|
86
|
+
</table>
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## ๐ Quick Start
|
|
91
|
+
|
|
92
|
+
### Installation
|
|
93
|
+
```bash
|
|
94
|
+
pip install -e .
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### IDE Configuration
|
|
98
|
+
|
|
99
|
+
#### ๐ฆ **Option 1: NPX (Recommended - Auto-installs dependencies)**
|
|
100
|
+
|
|
101
|
+
<details>
|
|
102
|
+
<summary><b>๐ต GitHub Copilot (VS Code) with NPX</b></summary>
|
|
103
|
+
|
|
104
|
+
**After publishing to npm:**
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"mcpServers": {
|
|
108
|
+
"ohm-mcp": {
|
|
109
|
+
"command": "npx",
|
|
110
|
+
"args": ["ohm-mcp@latest"]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**For local development:**
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"mcpServers": {
|
|
120
|
+
"ohm-mcp": {
|
|
121
|
+
"command": "npx",
|
|
122
|
+
"args": ["--package", "/path/to/ohm-mcp-npm", "ohm-mcp"]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Usage:**
|
|
129
|
+
- Open Copilot Chat
|
|
130
|
+
- Type `#` and select `ohm-mcp` tools
|
|
131
|
+
- Ask: "Analyze this file and suggest refactorings"
|
|
132
|
+
|
|
133
|
+
</details>
|
|
134
|
+
|
|
135
|
+
<details>
|
|
136
|
+
<summary><b>๐ฃ Cursor IDE with NPX</b></summary>
|
|
137
|
+
|
|
138
|
+
**After publishing to npm:**
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"ohm-mcp": {
|
|
143
|
+
"command": "npx",
|
|
144
|
+
"args": ["ohm-mcp@latest"]
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**For local development:**
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"mcpServers": {
|
|
154
|
+
"ohm-mcp": {
|
|
155
|
+
"command": "npx",
|
|
156
|
+
"args": ["--package", "/path/to/ohm-mcp-npm", "ohm-mcp"]
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Usage:**
|
|
163
|
+
- Open Cursor Chat (Cmd+L / Ctrl+L)
|
|
164
|
+
- Tools are automatically available
|
|
165
|
+
- Ask: "Use ohm-mcp to detect dead code"
|
|
166
|
+
|
|
167
|
+
</details>
|
|
168
|
+
|
|
169
|
+
<details>
|
|
170
|
+
<summary><b>๐ข Cline (VS Code Extension) with NPX</b></summary>
|
|
171
|
+
|
|
172
|
+
**After publishing to npm:**
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"mcpServers": {
|
|
176
|
+
"ohm-mcp": {
|
|
177
|
+
"command": "npx",
|
|
178
|
+
"args": ["ohm-mcp@latest"]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**For local development:**
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"mcpServers": {
|
|
188
|
+
"ohm-mcp": {
|
|
189
|
+
"command": "npx",
|
|
190
|
+
"args": ["--package", "/path/to/ohm-mcp-npm", "ohm-mcp"]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Usage:**
|
|
197
|
+
- Open Cline panel
|
|
198
|
+
- Tools are available in agent context
|
|
199
|
+
- Ask: "Analyze type coverage and suggest improvements"
|
|
200
|
+
|
|
201
|
+
</details>
|
|
202
|
+
|
|
203
|
+
#### ๐ **Option 2: Direct Python (Manual setup)**
|
|
204
|
+
|
|
205
|
+
<details>
|
|
206
|
+
<summary><b>๐ต GitHub Copilot (VS Code) with Python</b></summary>
|
|
207
|
+
|
|
208
|
+
First install: `pip install ohm-mcp`
|
|
209
|
+
|
|
210
|
+
Then add to `.vscode/mcp.json`:
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"servers": {
|
|
214
|
+
"ohm-mcp": {
|
|
215
|
+
"command": "python",
|
|
216
|
+
"args": ["-m", "ohm_mcp.server"]
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"inputs": []
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Usage:**
|
|
224
|
+
- Open Copilot Chat
|
|
225
|
+
- Type `#` and select `ohm-mcp` tools
|
|
226
|
+
- Ask: "Analyze this file and suggest refactorings"
|
|
227
|
+
|
|
228
|
+
</details>
|
|
229
|
+
|
|
230
|
+
<details>
|
|
231
|
+
<summary><b>๐ฃ Cursor IDE with Python</b></summary>
|
|
232
|
+
|
|
233
|
+
First install: `pip install ohm-mcp`
|
|
234
|
+
|
|
235
|
+
Then add to Cursor's MCP settings file (`.cursorrules` or MCP config):
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"mcpServers": {
|
|
239
|
+
"ohm-mcp": {
|
|
240
|
+
"command": "python",
|
|
241
|
+
"args": ["-m", "ohm_mcp.server"]
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
"inputs": []
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Example with virtual environment:**
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"mcpServers": {
|
|
252
|
+
"ohm-mcp": {
|
|
253
|
+
"command": "/Users/username/projects/venv/bin/python",
|
|
254
|
+
"args": ["-m", "ohm_mcp.server"]
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Usage:**
|
|
261
|
+
- Open Cursor Chat (Cmd+L / Ctrl+L)
|
|
262
|
+
- Tools are automatically available
|
|
263
|
+
- Ask: "Use ohm-mcp to detect dead code"
|
|
264
|
+
|
|
265
|
+
</details>
|
|
266
|
+
|
|
267
|
+
<details>
|
|
268
|
+
<summary><b>๐ข Cline (VS Code Extension) with Python</b></summary>
|
|
269
|
+
|
|
270
|
+
First install: `pip install ohm-mcp`
|
|
271
|
+
|
|
272
|
+
Then add to Cline's MCP settings:
|
|
273
|
+
```json
|
|
274
|
+
{
|
|
275
|
+
"mcpServers": {
|
|
276
|
+
"ohm-mcp": {
|
|
277
|
+
"command": "python",
|
|
278
|
+
"args": ["-m", "ohm_mcp.server"]
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Example with virtual environment:**
|
|
285
|
+
```json
|
|
286
|
+
{
|
|
287
|
+
"mcpServers": {
|
|
288
|
+
"ohm-mcp": {
|
|
289
|
+
"command": "/Users/username/projects/venv/bin/python",
|
|
290
|
+
"args": ["-m", "ohm_mcp.server"]
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Note:** Cline requires absolute paths for both `command` and `cwd`.
|
|
297
|
+
|
|
298
|
+
**Usage:**
|
|
299
|
+
- Open Cline panel
|
|
300
|
+
- Tools are available in agent context
|
|
301
|
+
- Ask: "Analyze type coverage and suggest improvements"
|
|
302
|
+
|
|
303
|
+
</details>
|
|
304
|
+
|
|
305
|
+
<details>
|
|
306
|
+
<summary><b>๐ง Other MCP-Compatible Clients</b></summary>
|
|
307
|
+
|
|
308
|
+
Any MCP-compatible client can use this server. General configuration:
|
|
309
|
+
|
|
310
|
+
```json
|
|
311
|
+
{
|
|
312
|
+
"mcpServers": {
|
|
313
|
+
"ohm-mcp": {
|
|
314
|
+
"command": "<python-interpreter-path>",
|
|
315
|
+
"args": ["<path-to-mcp_server.py>"],
|
|
316
|
+
"cwd": "<project-directory>"
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**Finding your Python path:**
|
|
323
|
+
```bash
|
|
324
|
+
# Unix/Mac
|
|
325
|
+
which python
|
|
326
|
+
# or
|
|
327
|
+
which python3
|
|
328
|
+
|
|
329
|
+
# Windows
|
|
330
|
+
where python
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
</details>
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## ๐ฏ Key Tools
|
|
338
|
+
|
|
339
|
+
<details>
|
|
340
|
+
<summary><b>๐๏ธ Architecture & Design (4 tools)</b></summary>
|
|
341
|
+
|
|
342
|
+
| Tool | Purpose | Output |
|
|
343
|
+
|------|---------|--------|
|
|
344
|
+
| `analyze_architecture` | Detect God Objects, SOLID violations | Detailed issue report |
|
|
345
|
+
| `suggest_design_patterns` | Recommend patterns (Strategy, Factory, Observer) | Pattern suggestions + examples |
|
|
346
|
+
| `analyze_tight_coupling` | Find coupling issues | DI recommendations |
|
|
347
|
+
| `suggest_di_refactor` | Generate DI code | Before/after refactor |
|
|
348
|
+
|
|
349
|
+
</details>
|
|
350
|
+
|
|
351
|
+
<details>
|
|
352
|
+
<summary><b>๐ง Code Quality & Refactoring (6 tools)</b></summary>
|
|
353
|
+
|
|
354
|
+
| Tool | Purpose | Key Feature |
|
|
355
|
+
|------|---------|-------------|
|
|
356
|
+
| `extract_method_ast` | Extract code into function | 100% AST-based accuracy |
|
|
357
|
+
| `suggest_extractable_methods` | Find extractable blocks | Cohesion scoring |
|
|
358
|
+
| `detect_dead_code` | Find unused code | 5 types of dead code |
|
|
359
|
+
| `refactor_imports` | Update imports project-wide | Safe module renaming |
|
|
360
|
+
| `rename_symbol` | Rename across codebase | Conflict detection |
|
|
361
|
+
| `detect_code_duplicates` | Find DRY violations | Exact + near duplicates |
|
|
362
|
+
|
|
363
|
+
**Example - Extract Method:**
|
|
364
|
+
```python
|
|
365
|
+
# Input: Lines 45-60
|
|
366
|
+
result = extract_method_ast(code, 45, 60, "calculate_total")
|
|
367
|
+
|
|
368
|
+
# Output: Refactored code + patch + auto-detected params/returns
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
</details>
|
|
372
|
+
|
|
373
|
+
<details>
|
|
374
|
+
<summary><b>๐ Type Safety & Testing (4 tools)</b></summary>
|
|
375
|
+
|
|
376
|
+
| Tool | Purpose | Benefit |
|
|
377
|
+
|------|---------|---------|
|
|
378
|
+
| `analyze_type_hints` | Check type coverage | Migration plan |
|
|
379
|
+
| `generate_type_stub` | Create .pyi files | Gradual typing |
|
|
380
|
+
| `generate_characterization_tests` | Auto-generate tests | Safe refactoring |
|
|
381
|
+
| `generate_test_for_function` | Single function tests | Targeted testing |
|
|
382
|
+
|
|
383
|
+
</details>
|
|
384
|
+
|
|
385
|
+
<details>
|
|
386
|
+
<summary><b>โก Performance & Coverage (2 tools)</b></summary>
|
|
387
|
+
|
|
388
|
+
| Tool | Purpose | Detects |
|
|
389
|
+
|------|---------|---------|
|
|
390
|
+
| `analyze_performance` | Find bottlenecks | Nested loops, mutable defaults, O(nยฒ) |
|
|
391
|
+
| `prioritize_by_coverage` | Risk-based prioritization | High-risk uncovered code |
|
|
392
|
+
|
|
393
|
+
</details>
|
|
394
|
+
|
|
395
|
+
<details>
|
|
396
|
+
<summary><b>๐ค Automated Execution (3 tools)</b></summary>
|
|
397
|
+
|
|
398
|
+
```mermaid
|
|
399
|
+
graph LR
|
|
400
|
+
A[apply_refactoring] --> B{Dry Run?}
|
|
401
|
+
B -->|Yes| C[Show Preview]
|
|
402
|
+
B -->|No| D[Create Backup]
|
|
403
|
+
D --> E[Apply Changes]
|
|
404
|
+
E --> F{Run Tests}
|
|
405
|
+
F -->|Pass| G[Success]
|
|
406
|
+
F -->|Fail| H[Auto Rollback]
|
|
407
|
+
H --> I[rollback_refactoring]
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
**Features:**
|
|
411
|
+
- โ
Automatic backup before changes
|
|
412
|
+
- โ
Test execution validation
|
|
413
|
+
- โ
Auto-rollback on failure
|
|
414
|
+
- โ
Full audit trail (`show_refactoring_history`)
|
|
415
|
+
|
|
416
|
+
</details>
|
|
417
|
+
|
|
418
|
+
<details>
|
|
419
|
+
<summary><b>๐ Metrics & Reporting (1 tool)</b></summary>
|
|
420
|
+
|
|
421
|
+
**`generate_quality_report`** - Comprehensive dashboard in HTML/Markdown/JSON
|
|
422
|
+
|
|
423
|
+
**Output Preview:**
|
|
424
|
+
|
|
425
|
+
```
|
|
426
|
+
๐ Health Score: 85/100 (Good)
|
|
427
|
+
๐ Files: 47 | Lines: 12,450 | Tech Debt: 23 pts
|
|
428
|
+
|
|
429
|
+
๐ Type Coverage: 67%
|
|
430
|
+
๐๏ธ Dead Code: 8 imports, 12 variables, 3 functions
|
|
431
|
+
โก Performance: 4 nested loops, 2 mutable defaults
|
|
432
|
+
๐ Duplication: 3 exact, 5 near-duplicates
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**Visual Dashboard:**
|
|
436
|
+
- ๐จ Circular health gauge
|
|
437
|
+
- ๐ Color-coded metrics (๐ข๐ก๐ด)
|
|
438
|
+
- ๐ Trend tracking ready
|
|
439
|
+
- ๐ CI/CD integration (JSON export)
|
|
440
|
+
|
|
441
|
+
</details>
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## ๐ก Common Workflows
|
|
446
|
+
|
|
447
|
+
### 1๏ธโฃ **Safe Refactoring**
|
|
448
|
+
```bash
|
|
449
|
+
generate_characterization_tests โ pytest โ extract_method_ast โ pytest
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### 2๏ธโฃ **Eliminate Duplication**
|
|
453
|
+
```bash
|
|
454
|
+
detect_code_duplicates โ review suggestions โ extract_method_ast
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### 3๏ธโฃ **Type Migration**
|
|
458
|
+
```bash
|
|
459
|
+
analyze_type_hints โ follow migration plan โ generate_type_stub
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### 4๏ธโฃ **Performance Optimization**
|
|
463
|
+
```bash
|
|
464
|
+
analyze_performance โ prioritize_by_coverage โ apply fixes
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### 5๏ธโฃ **Module Refactoring**
|
|
468
|
+
```bash
|
|
469
|
+
refactor_imports(old="myapp.old", new="myapp.new") โ review patches
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### 6๏ธโฃ **Symbol Renaming**
|
|
473
|
+
```bash
|
|
474
|
+
rename_symbol(old="calc", new="calculate", preview_only=True) โ apply
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### 7๏ธโฃ **Quality Tracking**
|
|
478
|
+
```bash
|
|
479
|
+
generate_quality_report(format="html") โ open dashboard โ track trends
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
## ๐จ Visual Examples
|
|
485
|
+
|
|
486
|
+
### Quality Dashboard Preview
|
|
487
|
+
|
|
488
|
+
```
|
|
489
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
490
|
+
โ ๐ Code Quality Dashboard โ
|
|
491
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
492
|
+
โ โ
|
|
493
|
+
โ โญโโโโโโโโโโฎ ๐ Overview โ
|
|
494
|
+
โ โ 85 โ Files: 47 โ
|
|
495
|
+
โ โ /100 โ Lines: 12,450 โ
|
|
496
|
+
โ โฐโโโโโโโโโโฏ Tech Debt: 23 โ
|
|
497
|
+
โ Health Score โ
|
|
498
|
+
โ โ
|
|
499
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
500
|
+
โ ๐ Type Coverage โก Performance โ
|
|
501
|
+
โ โโโโโโโโโโ 67% ๐ด 4 nested loops โ
|
|
502
|
+
โ 120/180 typed ๐ก 2 mutable args โ
|
|
503
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
504
|
+
โ ๐๏ธ Dead Code ๐ Duplication โ
|
|
505
|
+
โ 8 imports 3 exact โ
|
|
506
|
+
โ 12 variables 5 near โ
|
|
507
|
+
โ 3 functions โ
|
|
508
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### Symbol Rename Preview
|
|
512
|
+
|
|
513
|
+
```diff
|
|
514
|
+
# Before
|
|
515
|
+
- def calc(x, y):
|
|
516
|
+
- return x + y
|
|
517
|
+
- result = calc(5, 3)
|
|
518
|
+
|
|
519
|
+
# After
|
|
520
|
+
+ def calculate_sum(x, y):
|
|
521
|
+
+ return x + y
|
|
522
|
+
+ result = calculate_sum(5, 3)
|
|
523
|
+
|
|
524
|
+
โ
1 function renamed
|
|
525
|
+
โ
3 call sites updated
|
|
526
|
+
โ
0 conflicts detected
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
531
|
+
## ๐ง Design Principles
|
|
532
|
+
|
|
533
|
+
| Principle | Implementation |
|
|
534
|
+
|-----------|----------------|
|
|
535
|
+
| ๐งช **Test-First** | Auto-generate characterization tests before refactoring |
|
|
536
|
+
| โฉ๏ธ **Reversible** | Every change = backup + rollback capability |
|
|
537
|
+
| ๐ฏ **AST-Driven** | 100% accurate (no regex) |
|
|
538
|
+
| ๐ **Risk-Aware** | Coverage + complexity = prioritization |
|
|
539
|
+
| ๐๏ธ **SOLID** | Detect violations + concrete fixes |
|
|
540
|
+
| ๐ซ **No Blindness** | Analyze โ Plan โ Validate |
|
|
541
|
+
|
|
542
|
+
---
|
|
543
|
+
|
|
544
|
+
## ๐ IDE Compatibility
|
|
545
|
+
|
|
546
|
+
<table>
|
|
547
|
+
<tr>
|
|
548
|
+
<td align="center" width="100%">
|
|
549
|
+
<b>๐ค Any MCP Client</b><br>
|
|
550
|
+
โ
Standard Protocol<br>
|
|
551
|
+
โ
Easy Setup<br>
|
|
552
|
+
โ
Works with all MCP-compatible AI assistants
|
|
553
|
+
</td>
|
|
554
|
+
</tr>
|
|
555
|
+
</table>
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
## ๐ Comparison
|
|
561
|
+
|
|
562
|
+
| Feature | OHM MCP | Traditional Tools |
|
|
563
|
+
|---------|---------|-------------------|
|
|
564
|
+
| Accuracy | 100% AST | ~70% Regex |
|
|
565
|
+
| Safety | Auto backup/rollback | Manual |
|
|
566
|
+
| Testing | Auto-generates | Manual |
|
|
567
|
+
| Automation | Full | Suggestions only |
|
|
568
|
+
| Dashboard | HTML/JSON/MD | Text logs |
|
|
569
|
+
| IDE Support | Copilot/Cursor/Cline | Limited |
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
## ๐ฏ Use Cases
|
|
574
|
+
|
|
575
|
+
<table>
|
|
576
|
+
<tr>
|
|
577
|
+
<td><b>๐จโ๐ป Developers</b><br>โข Refactor legacy code safely<br>โข Find dead code<br>โข Optimize performance</td>
|
|
578
|
+
<td><b>๐ฅ Teams</b><br>โข Track tech debt<br>โข Enforce standards<br>โข Design patterns</td>
|
|
579
|
+
<td><b>๐ CI/CD</b><br>โข Quality gates<br>โข Trend tracking<br>โข Block bad PRs</td>
|
|
580
|
+
</tr>
|
|
581
|
+
</table>
|
|
582
|
+
|
|
583
|
+
---
|
|
584
|
+
|
|
585
|
+
## ๐ Metrics
|
|
586
|
+
|
|
587
|
+
```
|
|
588
|
+
โ
13 Advanced Capabilities
|
|
589
|
+
โ
30+ Static Checks
|
|
590
|
+
โ
100% AST Accuracy
|
|
591
|
+
โ
Zero Regex Patterns
|
|
592
|
+
โ
Automated Execution
|
|
593
|
+
โ
Beautiful Dashboards
|
|
594
|
+
โ
Universal MCP Compatibility
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
## ๐ ๏ธ Troubleshooting
|
|
600
|
+
|
|
601
|
+
<details>
|
|
602
|
+
<summary><b>MCP Connection Issues</b></summary>
|
|
603
|
+
|
|
604
|
+
1. **Verify Python path:**
|
|
605
|
+
```bash
|
|
606
|
+
which python # Unix/Mac
|
|
607
|
+
where python # Windows
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
2. **Test MCP server directly:**
|
|
611
|
+
```bash
|
|
612
|
+
python mcp_server.py
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
3. **Check logs:**
|
|
616
|
+
- VS Code: Check Output panel
|
|
617
|
+
- Cursor: Check Cursor logs
|
|
618
|
+
- Cline: Check Cline settings panel
|
|
619
|
+
|
|
620
|
+
4. **Common issues:**
|
|
621
|
+
- โ Relative paths in `command` โ Use absolute paths
|
|
622
|
+
- โ Missing virtual environment โ Activate venv first
|
|
623
|
+
- โ Wrong `cwd` for Cline โ Must be absolute path
|
|
624
|
+
|
|
625
|
+
</details>
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
629
|
+
## ๐ค Contributing
|
|
630
|
+
|
|
631
|
+
Run before submitting:
|
|
632
|
+
```bash
|
|
633
|
+
./static_analyser.sh # Runs ruff, mypy, pylint, flake8
|
|
634
|
+
pytest # All tests must pass
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
---
|
|
638
|
+
|
|
639
|
+
## ๐ Credits
|
|
640
|
+
|
|
641
|
+
Built with [Model Context Protocol](https://modelcontextprotocol.io) โข Python AST โข Compatible with GitHub Copilot, Cursor IDE, Cline
|
|
642
|
+
|
|
643
|
+
---
|
|
644
|
+
|
|
645
|
+
<div align="center">
|
|
646
|
+
|
|
647
|
+
**Made with โค๏ธ for better code quality**
|
|
648
|
+
|
|
649
|
+
โญ **Star this repo** if it helps you write cleaner code!
|
|
650
|
+
|
|
651
|
+
[Documentation](https://www.ohm-mcp.dev)
|
|
652
|
+
|
|
653
|
+
</div>
|