-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathvalidate_server.py
More file actions
140 lines (123 loc) · 3.64 KB
/
validate_server.py
File metadata and controls
140 lines (123 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env python3
"""
Quick syntax and import validation for machinery diagnostics server.
Run before testing with Claude Desktop.
"""
import sys
from pathlib import Path
print("🔍 Validating machinery diagnostics server...")
print()
# 1. Check Python version
print("1️⃣ Python version:")
print(f" {sys.version}")
if sys.version_info < (3, 11):
print(" ⚠️ Warning: Python 3.11+ recommended")
else:
print(" ✅ OK")
print()
# 2. Check project structure
print("2️⃣ Project structure:")
required_paths = [
"src/machinery_diagnostics_server.py",
"data/signals/real_train",
"data/signals/real_test",
"pyproject.toml"
]
all_exist = True
for path in required_paths:
exists = Path(path).exists()
status = "✅" if exists else "❌"
print(f" {status} {path}")
all_exist = all_exist and exists
if not all_exist:
print("\n❌ Missing required files!")
sys.exit(1)
print()
# 3. Check data files
print("3️⃣ Data files:")
train_files = list(Path("data/signals/real_train").glob("*.csv"))
test_files = list(Path("data/signals/real_test").glob("*.csv"))
print(f" Training signals: {len(train_files)}")
print(f" Test signals: {len(test_files)}")
if len(train_files) + len(test_files) < 20:
print(" ⚠️ Warning: Expected at least 20 signal files")
else:
print(" ✅ OK")
print(f" Supported formats: CSV, MAT, WAV, NPY, Parquet")
print()
# 4. Syntax check
print("4️⃣ Syntax validation:")
import py_compile
try:
py_compile.compile("src/machinery_diagnostics_server.py", doraise=True)
print(" ✅ No syntax errors")
except py_compile.PyCompileError as e:
print(f" ❌ Syntax error: {e}")
sys.exit(1)
print()
# 5. Import check (critical imports only)
print("5️⃣ Critical imports:")
critical_imports = [
("numpy", "np"),
("pandas", "pd"),
("scipy.signal", None),
("scipy.stats", None),
]
all_imports_ok = True
for module, alias in critical_imports:
try:
if alias:
exec(f"import {module} as {alias}")
else:
exec(f"import {module}")
print(f" ✅ {module}")
except ImportError:
print(f" ❌ {module} - NOT INSTALLED")
all_imports_ok = False
if not all_imports_ok:
print("\n❌ Missing required packages!")
print(" Run: uv sync")
sys.exit(1)
print()
# 6. Server file stats
print("6️⃣ Server file stats:")
server_path = Path("src/machinery_diagnostics_server.py")
content = server_path.read_text(encoding='utf-8')
lines = content.split('\n')
print(f" Total lines: {len(lines):,}")
print(f" File size: {server_path.stat().st_size:,} bytes")
# Count tools
tool_count = content.count("@mcp.tool()")
prompt_count = content.count("@mcp.prompt()")
resource_count = content.count("@mcp.resource(")
print(f" MCP Tools: {tool_count}")
print(f" MCP Prompts: {prompt_count}")
print(f" MCP Resources: {resource_count}")
print(" ✅ OK")
print()
# 7. Check for key MCP tools
print("7️⃣ Key MCP tools:")
key_tools = [
"generate_fft_report",
"generate_envelope_report",
"generate_iso_report",
"analyze_fft",
"analyze_envelope",
"evaluate_iso_20816",
"train_anomaly_model",
"predict_anomalies",
]
for tool in key_tools:
found = f"def {tool}(" in content or f"async def {tool}(" in content
status = "✅" if found else "❌"
print(f" {status} {tool}()")
print()
# Summary
print("=" * 60)
print("✅ VALIDATION PASSED - Server ready for testing!")
print()
print("Next steps:")
print("1. Restart Claude Desktop")
print("2. Test with: 'List available signals in machinery diagnostics'")
print("3. Run HTML artifact test from START_HERE.md")
print("=" * 60)