-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_mcp_setup.py
More file actions
161 lines (128 loc) Β· 5.03 KB
/
test_mcp_setup.py
File metadata and controls
161 lines (128 loc) Β· 5.03 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env python3
"""
MCP Server Setup Diagnostic Tool
================================
This script tests if your MCP server setup is working correctly.
"""
import sys
import subprocess
import json
from pathlib import Path
def test_python_environment():
"""Test Python environment"""
print("π Testing Python Environment:")
print(f" Python version: {sys.version}")
print(f" Python executable: {sys.executable}")
print(f" Virtual environment: {'β
' if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix) else 'β'}")
def test_imports():
"""Test required imports"""
print("\nπ¦ Testing Required Imports:")
required_packages = [
'mcp',
'librosa',
'soundfile',
'numpy',
'torch',
'demucs',
'stem_mcp'
]
for package in required_packages:
try:
__import__(package)
print(f" β
{package}")
except ImportError as e:
print(f" β {package} - {e}")
def test_mcp_server():
"""Test MCP server startup"""
print("\nπ₯οΈ Testing MCP Server Startup:")
try:
# Test the server can start
result = subprocess.run([
sys.executable, '-m', 'stem_mcp.server', '--help'
], capture_output=True, text=True, timeout=5)
if result.returncode == 0:
print(" β
Server starts successfully")
print(" β
Help command works")
else:
print(f" β Server failed to start: {result.stderr}")
except Exception as e:
print(f" β Server test failed: {e}")
def test_audio_files():
"""Test audio file access"""
print("\nπ΅ Testing Audio Files:")
test_file = Path("examples/test_sample.wav")
if test_file.exists():
print(f" β
Test audio file exists: {test_file}")
size_mb = test_file.stat().st_size / (1024 * 1024)
print(f" β
File size: {size_mb:.2f} MB")
else:
print(f" β Test audio file not found: {test_file}")
def test_claude_config():
"""Test Claude Desktop configuration"""
print("\nβοΈ Testing Claude Desktop Configuration:")
config_path = Path.home() / "Library/Application Support/Claude/claude_desktop_config.json"
if config_path.exists():
print(f" β
Config file exists: {config_path}")
try:
with open(config_path) as f:
config = json.load(f)
if 'mcpServers' in config and 'stem-processing' in config['mcpServers']:
print(" β
stem-processing server configured")
server_config = config['mcpServers']['stem-processing']
command = server_config.get('command', '')
if Path(command).exists():
print(f" β
Command file exists: {command}")
else:
print(f" β Command file not found: {command}")
else:
print(" β stem-processing server not configured")
except Exception as e:
print(f" β Error reading config: {e}")
else:
print(f" β Config file not found: {config_path}")
def test_wrapper_script():
"""Test the wrapper script"""
print("\nπ Testing Wrapper Script:")
wrapper_path = Path("start_mcp_server.sh")
if wrapper_path.exists():
print(f" β
Wrapper script exists: {wrapper_path}")
# Check if executable
if wrapper_path.stat().st_mode & 0o111:
print(" β
Wrapper script is executable")
else:
print(" β Wrapper script is not executable")
# Test wrapper script
try:
result = subprocess.run([
str(wrapper_path), '--help'
], capture_output=True, text=True, timeout=5)
if result.returncode == 0:
print(" β
Wrapper script works")
else:
print(f" β Wrapper script failed: {result.stderr}")
except Exception as e:
print(f" β Wrapper script test failed: {e}")
else:
print(f" β Wrapper script not found: {wrapper_path}")
def main():
"""Run all diagnostic tests"""
print("π§ MCP Server Setup Diagnostic")
print("=" * 50)
# Change to script directory
script_dir = Path(__file__).parent
import os
os.chdir(script_dir)
# Add src to Python path
sys.path.insert(0, str(script_dir / "src"))
test_python_environment()
test_imports()
test_mcp_server()
test_audio_files()
test_claude_config()
test_wrapper_script()
print("\n" + "=" * 50)
print("π― Diagnostic Complete!")
print("\nIf you see β errors above, those need to be fixed for Claude Desktop to work.")
print("If all tests show β
, restart Claude Desktop and try again!")
if __name__ == "__main__":
main()