mcp-server-mcsa 0.1.0__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.
- mcp_server_mcsa-0.1.0/.github/workflows/ci.yml +37 -0
- mcp_server_mcsa-0.1.0/.gitignore +41 -0
- mcp_server_mcsa-0.1.0/Dockerfile +12 -0
- mcp_server_mcsa-0.1.0/LICENSE +21 -0
- mcp_server_mcsa-0.1.0/PKG-INFO +309 -0
- mcp_server_mcsa-0.1.0/README.md +279 -0
- mcp_server_mcsa-0.1.0/USAGE_GUIDE.md +620 -0
- mcp_server_mcsa-0.1.0/pyproject.toml +78 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/__init__.py +37 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/__main__.py +5 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/__init__.py +19 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/bearing.py +147 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/envelope.py +97 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/fault_detection.py +425 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/file_io.py +428 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/motor.py +145 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/preprocessing.py +180 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/spectral.py +172 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/test_signal.py +232 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/analysis/timefreq.py +132 -0
- mcp_server_mcsa-0.1.0/src/mcp_server_mcsa/server.py +955 -0
- mcp_server_mcsa-0.1.0/tests/__init__.py +0 -0
- mcp_server_mcsa-0.1.0/tests/conftest.py +49 -0
- mcp_server_mcsa-0.1.0/tests/test_bearing.py +92 -0
- mcp_server_mcsa-0.1.0/tests/test_envelope_timefreq.py +105 -0
- mcp_server_mcsa-0.1.0/tests/test_fault_detection.py +132 -0
- mcp_server_mcsa-0.1.0/tests/test_file_io.py +239 -0
- mcp_server_mcsa-0.1.0/tests/test_motor.py +78 -0
- mcp_server_mcsa-0.1.0/tests/test_preprocessing.py +117 -0
- mcp_server_mcsa-0.1.0/tests/test_signal_gen.py +91 -0
- mcp_server_mcsa-0.1.0/tests/test_spectral.py +108 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v4
|
|
21
|
+
with:
|
|
22
|
+
enable-cache: true
|
|
23
|
+
|
|
24
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
25
|
+
run: uv python install ${{ matrix.python-version }}
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --dev
|
|
29
|
+
|
|
30
|
+
- name: Lint with ruff
|
|
31
|
+
run: uv run ruff check src/ tests/
|
|
32
|
+
|
|
33
|
+
- name: Type check with pyright
|
|
34
|
+
run: uv run pyright src/
|
|
35
|
+
|
|
36
|
+
- name: Run tests
|
|
37
|
+
run: uv run pytest -v --tb=short
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg-info/
|
|
7
|
+
*.egg
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.eggs/
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
ENV/
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.vscode/
|
|
20
|
+
.idea/
|
|
21
|
+
*.swp
|
|
22
|
+
*.swo
|
|
23
|
+
*~
|
|
24
|
+
|
|
25
|
+
# OS
|
|
26
|
+
.DS_Store
|
|
27
|
+
Thumbs.db
|
|
28
|
+
desktop.ini
|
|
29
|
+
|
|
30
|
+
# Testing
|
|
31
|
+
.coverage
|
|
32
|
+
htmlcov/
|
|
33
|
+
.pytest_cache/
|
|
34
|
+
.mypy_cache/
|
|
35
|
+
|
|
36
|
+
# Distribution
|
|
37
|
+
*.whl
|
|
38
|
+
*.tar.gz
|
|
39
|
+
|
|
40
|
+
# uv
|
|
41
|
+
uv.lock
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-server-mcsa
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for Motor Current Signature Analysis (MCSA) — spectral analysis, fault frequency calculation, and fault detection in electric motors
|
|
5
|
+
Project-URL: Homepage, https://github.com/LGDiMaggio/mcp-motor-current-signature-analysis
|
|
6
|
+
Project-URL: Repository, https://github.com/LGDiMaggio/mcp-motor-current-signature-analysis
|
|
7
|
+
Project-URL: Issues, https://github.com/LGDiMaggio/mcp-motor-current-signature-analysis/issues
|
|
8
|
+
Author: LGDiMaggio
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: bearing-fault,broken-rotor-bar,condition-monitoring,fault-detection,induction-motor,mcp,mcsa,motor-current-signature-analysis,predictive-maintenance,spectral-analysis
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Manufacturing
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: mcp>=1.0.0
|
|
26
|
+
Requires-Dist: numpy>=1.24.0
|
|
27
|
+
Requires-Dist: pydantic>=2.0.0
|
|
28
|
+
Requires-Dist: scipy>=1.10.0
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# mcp-server-mcsa
|
|
32
|
+
|
|
33
|
+
[](https://opensource.org/licenses/MIT)
|
|
34
|
+
[](https://www.python.org/downloads/)
|
|
35
|
+
[](https://modelcontextprotocol.io)
|
|
36
|
+
|
|
37
|
+
A **Model Context Protocol (MCP) server** for **Motor Current Signature Analysis (MCSA)** — non-invasive spectral analysis and fault detection in electric motors using stator-current signals.
|
|
38
|
+
|
|
39
|
+
MCSA is an industry-standard condition-monitoring technique that analyses the harmonic content of the stator current to detect rotor, stator, bearing, and air-gap faults in electric motors — without requiring vibration sensors, downtime, or physical access to the machine. This server brings the full MCSA diagnostic workflow to any MCP-compatible AI assistant (Claude Desktop, VS Code Copilot, and others), enabling both interactive expert analysis and automated condition-monitoring pipelines.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Real signal loading** — read measured data from CSV, TSV, WAV, and NumPy `.npy` files
|
|
44
|
+
- **Motor parameter calculation** — slip, synchronous speed, rotor frequency from nameplate data
|
|
45
|
+
- **Fault frequency computation** — broken rotor bars, eccentricity, stator faults, mixed eccentricity
|
|
46
|
+
- **Bearing defect frequencies** — BPFO, BPFI, BSF, FTF from bearing geometry
|
|
47
|
+
- **Signal preprocessing** — DC removal, normalisation, windowing, bandpass/notch filtering
|
|
48
|
+
- **Spectral analysis** — FFT spectrum, Welch PSD, spectral peak detection
|
|
49
|
+
- **Envelope analysis** — Hilbert-transform demodulation for mechanical/bearing faults
|
|
50
|
+
- **Time-frequency analysis** — STFT with frequency tracking for non-stationary conditions
|
|
51
|
+
- **Fault detection** — automated severity classification (healthy / incipient / moderate / severe)
|
|
52
|
+
- **One-shot diagnostics** — full pipeline from signal array or directly from file
|
|
53
|
+
- **Test signal generation** — synthetic signals with configurable fault injection for demos and benchmarking
|
|
54
|
+
|
|
55
|
+
## Tools (19)
|
|
56
|
+
|
|
57
|
+
| Tool | Description |
|
|
58
|
+
|------|-------------|
|
|
59
|
+
| `inspect_signal_file` | Inspect a signal file format and metadata without loading |
|
|
60
|
+
| `load_signal_from_file` | Load a current signal from CSV / WAV / NPY file |
|
|
61
|
+
| `calculate_motor_params` | Compute slip, sync speed, rotor frequency from motor data |
|
|
62
|
+
| `compute_fault_frequencies` | Calculate expected fault frequencies for all common fault types |
|
|
63
|
+
| `compute_bearing_frequencies` | Calculate BPFO, BPFI, BSF, FTF from bearing geometry |
|
|
64
|
+
| `preprocess_signal` | DC removal, filtering, normalisation, windowing pipeline |
|
|
65
|
+
| `compute_spectrum` | Single-sided FFT amplitude spectrum |
|
|
66
|
+
| `compute_power_spectral_density` | Welch PSD estimation |
|
|
67
|
+
| `find_spectrum_peaks` | Detect and characterise peaks in a spectrum |
|
|
68
|
+
| `detect_broken_rotor_bars` | BRB fault index with severity classification |
|
|
69
|
+
| `detect_eccentricity` | Air-gap eccentricity detection via sidebands |
|
|
70
|
+
| `detect_stator_faults` | Stator inter-turn short circuit detection |
|
|
71
|
+
| `detect_bearing_faults` | Bearing defect detection from current spectrum |
|
|
72
|
+
| `compute_envelope_spectrum` | Hilbert envelope spectrum for modulation analysis |
|
|
73
|
+
| `compute_band_energy` | Integrated spectral energy in a frequency band |
|
|
74
|
+
| `compute_time_frequency` | STFT analysis with optional frequency tracking |
|
|
75
|
+
| `generate_test_current_signal` | Synthetic motor current with optional faults |
|
|
76
|
+
| `run_full_diagnosis` | Complete MCSA diagnostic pipeline from signal array |
|
|
77
|
+
| `diagnose_from_file` | Complete MCSA diagnostic pipeline directly from file |
|
|
78
|
+
|
|
79
|
+
## Resources
|
|
80
|
+
|
|
81
|
+
| URI | Description |
|
|
82
|
+
|-----|-------------|
|
|
83
|
+
| `mcsa://fault-signatures` | Reference table of fault signatures, frequencies, and empirical thresholds |
|
|
84
|
+
|
|
85
|
+
## Prompts
|
|
86
|
+
|
|
87
|
+
| Prompt | Description |
|
|
88
|
+
|--------|-------------|
|
|
89
|
+
| `analyze_motor_current` | Step-by-step guided workflow for MCSA analysis |
|
|
90
|
+
|
|
91
|
+
## Installation
|
|
92
|
+
|
|
93
|
+
### Using uv (recommended)
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
uvx mcp-server-mcsa
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Using pip
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pip install mcp-server-mcsa
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### From source
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
git clone https://github.com/LGDiMaggio/mcp-motor-current-signature-analysis.git
|
|
109
|
+
cd mcp-motor-current-signature-analysis
|
|
110
|
+
pip install -e .
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Configuration
|
|
114
|
+
|
|
115
|
+
### Claude Desktop
|
|
116
|
+
|
|
117
|
+
Add to your Claude Desktop configuration file:
|
|
118
|
+
|
|
119
|
+
<details>
|
|
120
|
+
<summary>Using uvx</summary>
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"mcpServers": {
|
|
125
|
+
"mcsa": {
|
|
126
|
+
"command": "uvx",
|
|
127
|
+
"args": ["mcp-server-mcsa"]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
</details>
|
|
133
|
+
|
|
134
|
+
<details>
|
|
135
|
+
<summary>Using pip</summary>
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"mcpServers": {
|
|
140
|
+
"mcsa": {
|
|
141
|
+
"command": "python",
|
|
142
|
+
"args": ["-m", "mcp_server_mcsa"]
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
</details>
|
|
148
|
+
|
|
149
|
+
### VS Code
|
|
150
|
+
|
|
151
|
+
Add to `.vscode/mcp.json` in your workspace:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"servers": {
|
|
156
|
+
"mcsa": {
|
|
157
|
+
"command": "uvx",
|
|
158
|
+
"args": ["mcp-server-mcsa"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Or with pip:
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"servers": {
|
|
169
|
+
"mcsa": {
|
|
170
|
+
"command": "python",
|
|
171
|
+
"args": ["-m", "mcp_server_mcsa"]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Usage Examples
|
|
178
|
+
|
|
179
|
+
### Real Signal — One-Shot Diagnosis
|
|
180
|
+
|
|
181
|
+
The fastest way to analyse a measured signal is the `diagnose_from_file`
|
|
182
|
+
tool. Simply provide the file path and motor nameplate data:
|
|
183
|
+
|
|
184
|
+
> "Diagnose the motor from `C:\data\motor_phaseA.csv` — 50 Hz supply,
|
|
185
|
+
> 4 poles, 1470 RPM"
|
|
186
|
+
|
|
187
|
+
The server loads the file, preprocesses the signal, computes the spectrum,
|
|
188
|
+
runs all fault detectors, and returns a complete JSON report with
|
|
189
|
+
severity-classified results.
|
|
190
|
+
|
|
191
|
+
### Step-by-Step Workflow
|
|
192
|
+
|
|
193
|
+
1. **Load a measured signal** (or generate a synthetic one):
|
|
194
|
+
> "Load the signal from `measurement.wav`"
|
|
195
|
+
> or: "Generate a test signal with a broken-rotor-bar fault"
|
|
196
|
+
|
|
197
|
+
2. **Calculate motor parameters**:
|
|
198
|
+
> "Calculate motor parameters for a 4-pole motor, 50 Hz supply, running at 1470 RPM"
|
|
199
|
+
|
|
200
|
+
3. **Compute expected fault frequencies**:
|
|
201
|
+
> "What are the expected fault frequencies for this motor?"
|
|
202
|
+
|
|
203
|
+
4. **Analyse the spectrum**:
|
|
204
|
+
> "Compute the FFT spectrum of this signal"
|
|
205
|
+
|
|
206
|
+
5. **Detect specific faults**:
|
|
207
|
+
> "Check for broken rotor bars in this spectrum"
|
|
208
|
+
|
|
209
|
+
6. **Envelope analysis (optional)**:
|
|
210
|
+
> "Compute the envelope spectrum to check for bearing modulation"
|
|
211
|
+
|
|
212
|
+
### Quick Diagnosis from Signal Array
|
|
213
|
+
|
|
214
|
+
The `run_full_diagnosis` tool runs the entire pipeline on a signal
|
|
215
|
+
already in memory in a single call:
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
Input: raw signal array + motor nameplate data
|
|
219
|
+
Output: complete report with fault severities and recommendations
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Bearing Analysis
|
|
223
|
+
|
|
224
|
+
For bearing fault analysis, you need the bearing geometry (number of balls,
|
|
225
|
+
ball diameter, pitch diameter, contact angle). The server will:
|
|
226
|
+
1. Calculate characteristic defect frequencies (BPFO, BPFI, BSF, FTF)
|
|
227
|
+
2. Compute expected current sidebands
|
|
228
|
+
3. Search the spectrum for those sidebands
|
|
229
|
+
|
|
230
|
+
### Supported File Formats
|
|
231
|
+
|
|
232
|
+
| Format | Extensions | Sampling Rate |
|
|
233
|
+
|--------|------------|---------------|
|
|
234
|
+
| CSV / TSV | `.csv`, `.tsv`, `.txt` | From time column or user-supplied |
|
|
235
|
+
| WAV | `.wav` | Embedded in header |
|
|
236
|
+
| NumPy | `.npy` | User-supplied |
|
|
237
|
+
|
|
238
|
+
## Fault Detection Theory
|
|
239
|
+
|
|
240
|
+
### Broken Rotor Bars (BRB)
|
|
241
|
+
Sidebands at $(1 \pm 2s) \cdot f_s$ where $s$ is slip and $f_s$ is supply frequency.
|
|
242
|
+
Severity is classified by the dB ratio of sideband to fundamental amplitude.
|
|
243
|
+
|
|
244
|
+
### Eccentricity
|
|
245
|
+
Sidebands at $f_s \pm k \cdot f_r$ where $f_r$ is the rotor mechanical frequency.
|
|
246
|
+
|
|
247
|
+
### Stator Inter-Turn Faults
|
|
248
|
+
Sidebands at $f_s \pm 2k \cdot f_r$ due to winding asymmetry.
|
|
249
|
+
|
|
250
|
+
### Bearing Defects
|
|
251
|
+
Torque oscillations modulate the stator current, creating sidebands at $f_s \pm k \cdot f_{defect}$.
|
|
252
|
+
Defect frequencies depend on bearing geometry (BPFO, BPFI, BSF, FTF).
|
|
253
|
+
|
|
254
|
+
### Severity Thresholds (dB below fundamental)
|
|
255
|
+
|
|
256
|
+
| Level | Range |
|
|
257
|
+
|-------|-------|
|
|
258
|
+
| Healthy | ≤ −50 dB |
|
|
259
|
+
| Incipient | −50 to −45 dB |
|
|
260
|
+
| Moderate | −45 to −40 dB |
|
|
261
|
+
| Severe | > −35 dB |
|
|
262
|
+
|
|
263
|
+
> **Note**: These are general guidelines. Actual thresholds should be adapted to the specific motor, load, and application based on baseline measurements.
|
|
264
|
+
|
|
265
|
+
## Development
|
|
266
|
+
|
|
267
|
+
### Setup
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
git clone https://github.com/LGDiMaggio/mcp-motor-current-signature-analysis.git
|
|
271
|
+
cd mcp-motor-current-signature-analysis
|
|
272
|
+
uv sync --dev
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Run tests
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
uv run pytest
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Run with MCP Inspector
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
uv run mcp dev src/mcp_server_mcsa/server.py
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Lint and type check
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
uv run ruff check src/ tests/
|
|
291
|
+
uv run pyright src/
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Dependencies
|
|
295
|
+
|
|
296
|
+
- [mcp](https://pypi.org/project/mcp/) — Model Context Protocol SDK
|
|
297
|
+
- [numpy](https://numpy.org/) — numerical computing
|
|
298
|
+
- [scipy](https://scipy.org/) — signal processing (FFT, filtering, Hilbert transform)
|
|
299
|
+
- [pydantic](https://docs.pydantic.dev/) — data validation
|
|
300
|
+
|
|
301
|
+
## Documentation
|
|
302
|
+
|
|
303
|
+
For a detailed reference of every tool, resource, and prompt — including
|
|
304
|
+
parameter tables, diagnostic workflows, integration patterns, and severity
|
|
305
|
+
thresholds — see the **[Usage Guide](USAGE_GUIDE.md)**.
|
|
306
|
+
|
|
307
|
+
## License
|
|
308
|
+
|
|
309
|
+
MIT — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# mcp-server-mcsa
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://modelcontextprotocol.io)
|
|
6
|
+
|
|
7
|
+
A **Model Context Protocol (MCP) server** for **Motor Current Signature Analysis (MCSA)** — non-invasive spectral analysis and fault detection in electric motors using stator-current signals.
|
|
8
|
+
|
|
9
|
+
MCSA is an industry-standard condition-monitoring technique that analyses the harmonic content of the stator current to detect rotor, stator, bearing, and air-gap faults in electric motors — without requiring vibration sensors, downtime, or physical access to the machine. This server brings the full MCSA diagnostic workflow to any MCP-compatible AI assistant (Claude Desktop, VS Code Copilot, and others), enabling both interactive expert analysis and automated condition-monitoring pipelines.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Real signal loading** — read measured data from CSV, TSV, WAV, and NumPy `.npy` files
|
|
14
|
+
- **Motor parameter calculation** — slip, synchronous speed, rotor frequency from nameplate data
|
|
15
|
+
- **Fault frequency computation** — broken rotor bars, eccentricity, stator faults, mixed eccentricity
|
|
16
|
+
- **Bearing defect frequencies** — BPFO, BPFI, BSF, FTF from bearing geometry
|
|
17
|
+
- **Signal preprocessing** — DC removal, normalisation, windowing, bandpass/notch filtering
|
|
18
|
+
- **Spectral analysis** — FFT spectrum, Welch PSD, spectral peak detection
|
|
19
|
+
- **Envelope analysis** — Hilbert-transform demodulation for mechanical/bearing faults
|
|
20
|
+
- **Time-frequency analysis** — STFT with frequency tracking for non-stationary conditions
|
|
21
|
+
- **Fault detection** — automated severity classification (healthy / incipient / moderate / severe)
|
|
22
|
+
- **One-shot diagnostics** — full pipeline from signal array or directly from file
|
|
23
|
+
- **Test signal generation** — synthetic signals with configurable fault injection for demos and benchmarking
|
|
24
|
+
|
|
25
|
+
## Tools (19)
|
|
26
|
+
|
|
27
|
+
| Tool | Description |
|
|
28
|
+
|------|-------------|
|
|
29
|
+
| `inspect_signal_file` | Inspect a signal file format and metadata without loading |
|
|
30
|
+
| `load_signal_from_file` | Load a current signal from CSV / WAV / NPY file |
|
|
31
|
+
| `calculate_motor_params` | Compute slip, sync speed, rotor frequency from motor data |
|
|
32
|
+
| `compute_fault_frequencies` | Calculate expected fault frequencies for all common fault types |
|
|
33
|
+
| `compute_bearing_frequencies` | Calculate BPFO, BPFI, BSF, FTF from bearing geometry |
|
|
34
|
+
| `preprocess_signal` | DC removal, filtering, normalisation, windowing pipeline |
|
|
35
|
+
| `compute_spectrum` | Single-sided FFT amplitude spectrum |
|
|
36
|
+
| `compute_power_spectral_density` | Welch PSD estimation |
|
|
37
|
+
| `find_spectrum_peaks` | Detect and characterise peaks in a spectrum |
|
|
38
|
+
| `detect_broken_rotor_bars` | BRB fault index with severity classification |
|
|
39
|
+
| `detect_eccentricity` | Air-gap eccentricity detection via sidebands |
|
|
40
|
+
| `detect_stator_faults` | Stator inter-turn short circuit detection |
|
|
41
|
+
| `detect_bearing_faults` | Bearing defect detection from current spectrum |
|
|
42
|
+
| `compute_envelope_spectrum` | Hilbert envelope spectrum for modulation analysis |
|
|
43
|
+
| `compute_band_energy` | Integrated spectral energy in a frequency band |
|
|
44
|
+
| `compute_time_frequency` | STFT analysis with optional frequency tracking |
|
|
45
|
+
| `generate_test_current_signal` | Synthetic motor current with optional faults |
|
|
46
|
+
| `run_full_diagnosis` | Complete MCSA diagnostic pipeline from signal array |
|
|
47
|
+
| `diagnose_from_file` | Complete MCSA diagnostic pipeline directly from file |
|
|
48
|
+
|
|
49
|
+
## Resources
|
|
50
|
+
|
|
51
|
+
| URI | Description |
|
|
52
|
+
|-----|-------------|
|
|
53
|
+
| `mcsa://fault-signatures` | Reference table of fault signatures, frequencies, and empirical thresholds |
|
|
54
|
+
|
|
55
|
+
## Prompts
|
|
56
|
+
|
|
57
|
+
| Prompt | Description |
|
|
58
|
+
|--------|-------------|
|
|
59
|
+
| `analyze_motor_current` | Step-by-step guided workflow for MCSA analysis |
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
### Using uv (recommended)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
uvx mcp-server-mcsa
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Using pip
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install mcp-server-mcsa
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### From source
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git clone https://github.com/LGDiMaggio/mcp-motor-current-signature-analysis.git
|
|
79
|
+
cd mcp-motor-current-signature-analysis
|
|
80
|
+
pip install -e .
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Configuration
|
|
84
|
+
|
|
85
|
+
### Claude Desktop
|
|
86
|
+
|
|
87
|
+
Add to your Claude Desktop configuration file:
|
|
88
|
+
|
|
89
|
+
<details>
|
|
90
|
+
<summary>Using uvx</summary>
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"mcsa": {
|
|
96
|
+
"command": "uvx",
|
|
97
|
+
"args": ["mcp-server-mcsa"]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
</details>
|
|
103
|
+
|
|
104
|
+
<details>
|
|
105
|
+
<summary>Using pip</summary>
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"mcpServers": {
|
|
110
|
+
"mcsa": {
|
|
111
|
+
"command": "python",
|
|
112
|
+
"args": ["-m", "mcp_server_mcsa"]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
</details>
|
|
118
|
+
|
|
119
|
+
### VS Code
|
|
120
|
+
|
|
121
|
+
Add to `.vscode/mcp.json` in your workspace:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"servers": {
|
|
126
|
+
"mcsa": {
|
|
127
|
+
"command": "uvx",
|
|
128
|
+
"args": ["mcp-server-mcsa"]
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Or with pip:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"servers": {
|
|
139
|
+
"mcsa": {
|
|
140
|
+
"command": "python",
|
|
141
|
+
"args": ["-m", "mcp_server_mcsa"]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Usage Examples
|
|
148
|
+
|
|
149
|
+
### Real Signal — One-Shot Diagnosis
|
|
150
|
+
|
|
151
|
+
The fastest way to analyse a measured signal is the `diagnose_from_file`
|
|
152
|
+
tool. Simply provide the file path and motor nameplate data:
|
|
153
|
+
|
|
154
|
+
> "Diagnose the motor from `C:\data\motor_phaseA.csv` — 50 Hz supply,
|
|
155
|
+
> 4 poles, 1470 RPM"
|
|
156
|
+
|
|
157
|
+
The server loads the file, preprocesses the signal, computes the spectrum,
|
|
158
|
+
runs all fault detectors, and returns a complete JSON report with
|
|
159
|
+
severity-classified results.
|
|
160
|
+
|
|
161
|
+
### Step-by-Step Workflow
|
|
162
|
+
|
|
163
|
+
1. **Load a measured signal** (or generate a synthetic one):
|
|
164
|
+
> "Load the signal from `measurement.wav`"
|
|
165
|
+
> or: "Generate a test signal with a broken-rotor-bar fault"
|
|
166
|
+
|
|
167
|
+
2. **Calculate motor parameters**:
|
|
168
|
+
> "Calculate motor parameters for a 4-pole motor, 50 Hz supply, running at 1470 RPM"
|
|
169
|
+
|
|
170
|
+
3. **Compute expected fault frequencies**:
|
|
171
|
+
> "What are the expected fault frequencies for this motor?"
|
|
172
|
+
|
|
173
|
+
4. **Analyse the spectrum**:
|
|
174
|
+
> "Compute the FFT spectrum of this signal"
|
|
175
|
+
|
|
176
|
+
5. **Detect specific faults**:
|
|
177
|
+
> "Check for broken rotor bars in this spectrum"
|
|
178
|
+
|
|
179
|
+
6. **Envelope analysis (optional)**:
|
|
180
|
+
> "Compute the envelope spectrum to check for bearing modulation"
|
|
181
|
+
|
|
182
|
+
### Quick Diagnosis from Signal Array
|
|
183
|
+
|
|
184
|
+
The `run_full_diagnosis` tool runs the entire pipeline on a signal
|
|
185
|
+
already in memory in a single call:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
Input: raw signal array + motor nameplate data
|
|
189
|
+
Output: complete report with fault severities and recommendations
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Bearing Analysis
|
|
193
|
+
|
|
194
|
+
For bearing fault analysis, you need the bearing geometry (number of balls,
|
|
195
|
+
ball diameter, pitch diameter, contact angle). The server will:
|
|
196
|
+
1. Calculate characteristic defect frequencies (BPFO, BPFI, BSF, FTF)
|
|
197
|
+
2. Compute expected current sidebands
|
|
198
|
+
3. Search the spectrum for those sidebands
|
|
199
|
+
|
|
200
|
+
### Supported File Formats
|
|
201
|
+
|
|
202
|
+
| Format | Extensions | Sampling Rate |
|
|
203
|
+
|--------|------------|---------------|
|
|
204
|
+
| CSV / TSV | `.csv`, `.tsv`, `.txt` | From time column or user-supplied |
|
|
205
|
+
| WAV | `.wav` | Embedded in header |
|
|
206
|
+
| NumPy | `.npy` | User-supplied |
|
|
207
|
+
|
|
208
|
+
## Fault Detection Theory
|
|
209
|
+
|
|
210
|
+
### Broken Rotor Bars (BRB)
|
|
211
|
+
Sidebands at $(1 \pm 2s) \cdot f_s$ where $s$ is slip and $f_s$ is supply frequency.
|
|
212
|
+
Severity is classified by the dB ratio of sideband to fundamental amplitude.
|
|
213
|
+
|
|
214
|
+
### Eccentricity
|
|
215
|
+
Sidebands at $f_s \pm k \cdot f_r$ where $f_r$ is the rotor mechanical frequency.
|
|
216
|
+
|
|
217
|
+
### Stator Inter-Turn Faults
|
|
218
|
+
Sidebands at $f_s \pm 2k \cdot f_r$ due to winding asymmetry.
|
|
219
|
+
|
|
220
|
+
### Bearing Defects
|
|
221
|
+
Torque oscillations modulate the stator current, creating sidebands at $f_s \pm k \cdot f_{defect}$.
|
|
222
|
+
Defect frequencies depend on bearing geometry (BPFO, BPFI, BSF, FTF).
|
|
223
|
+
|
|
224
|
+
### Severity Thresholds (dB below fundamental)
|
|
225
|
+
|
|
226
|
+
| Level | Range |
|
|
227
|
+
|-------|-------|
|
|
228
|
+
| Healthy | ≤ −50 dB |
|
|
229
|
+
| Incipient | −50 to −45 dB |
|
|
230
|
+
| Moderate | −45 to −40 dB |
|
|
231
|
+
| Severe | > −35 dB |
|
|
232
|
+
|
|
233
|
+
> **Note**: These are general guidelines. Actual thresholds should be adapted to the specific motor, load, and application based on baseline measurements.
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
### Setup
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
git clone https://github.com/LGDiMaggio/mcp-motor-current-signature-analysis.git
|
|
241
|
+
cd mcp-motor-current-signature-analysis
|
|
242
|
+
uv sync --dev
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Run tests
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
uv run pytest
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Run with MCP Inspector
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
uv run mcp dev src/mcp_server_mcsa/server.py
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Lint and type check
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
uv run ruff check src/ tests/
|
|
261
|
+
uv run pyright src/
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Dependencies
|
|
265
|
+
|
|
266
|
+
- [mcp](https://pypi.org/project/mcp/) — Model Context Protocol SDK
|
|
267
|
+
- [numpy](https://numpy.org/) — numerical computing
|
|
268
|
+
- [scipy](https://scipy.org/) — signal processing (FFT, filtering, Hilbert transform)
|
|
269
|
+
- [pydantic](https://docs.pydantic.dev/) — data validation
|
|
270
|
+
|
|
271
|
+
## Documentation
|
|
272
|
+
|
|
273
|
+
For a detailed reference of every tool, resource, and prompt — including
|
|
274
|
+
parameter tables, diagnostic workflows, integration patterns, and severity
|
|
275
|
+
thresholds — see the **[Usage Guide](USAGE_GUIDE.md)**.
|
|
276
|
+
|
|
277
|
+
## License
|
|
278
|
+
|
|
279
|
+
MIT — see [LICENSE](LICENSE) for details.
|