test_mcp_setup.py•5.15 kB
#!/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()