#!/usr/bin/env python3
"""Test the fixed Claude Desktop configuration."""
import subprocess
import time
import json
import os
from pathlib import Path
def test_with_fixed_config():
"""Test the MCP server with the fixed configuration."""
print("๐ Testing Fixed Configuration")
print("=" * 50)
# Test the exact command that Claude Desktop will run
python_path = "/Users/alex/claude/11-mcp/venv/bin/python"
args = ["-m", "elevenlabs_mcp.server"]
cwd = "/Users/alex/claude/11-mcp"
env = {
"ELEVENLABS_API_KEY": "sk_ed46dad18de349f00aa80a7d4605e66a7556818f724da8c2",
"PYTHONPATH": "/Users/alex/claude/11-mcp/src",
"LOG_LEVEL": "DEBUG"
}
print(f"Command: {python_path} {' '.join(args)}")
print(f"Working directory: {cwd}")
print(f"Environment: {env}")
try:
# Start the process
full_env = os.environ.copy()
full_env.update(env)
process = subprocess.Popen(
[python_path] + args,
cwd=cwd,
env=full_env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
print("\n๐ Starting MCP server...")
# Wait for startup
time.sleep(3)
# Check if still running
if process.poll() is None:
print("โ
Server is running!")
# Test communication with a simple initialize message
init_message = {
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {
"roots": {"listChanged": True},
"sampling": {}
},
"clientInfo": {
"name": "TestClient",
"version": "1.0.0"
}
}
}
try:
# Send initialize message
message = json.dumps(init_message) + "\n"
stdout, stderr = process.communicate(input=message, timeout=5)
print("โ
Server responded to initialize message!")
if stdout:
print(f"๐ค Server response: {stdout[:300]}...")
return True
except subprocess.TimeoutExpired:
print("โ
Server is running (timeout on response is normal)")
process.terminate()
try:
process.wait(timeout=3)
except subprocess.TimeoutExpired:
process.kill()
process.wait()
return True
else:
stdout, stderr = process.communicate()
print(f"โ Server exited with code: {process.returncode}")
if stderr:
print(f"โ Error output: {stderr}")
return False
except Exception as e:
print(f"โ Error testing server: {e}")
return False
def verify_claude_desktop_config():
"""Verify the Claude Desktop configuration is correct."""
print("\n๐ Verifying Claude Desktop Configuration")
print("=" * 50)
config_path = Path.home() / "Library/Application Support/Claude/claude_desktop_config.json"
try:
with open(config_path, 'r') as f:
config = json.load(f)
if "mcpServers" in config and "elevenlabs" in config["mcpServers"]:
elevenlabs_config = config["mcpServers"]["elevenlabs"]
print(f"โ
Command: {elevenlabs_config['command']}")
print(f"โ
Args: {elevenlabs_config['args']}")
print(f"โ
Working directory: {elevenlabs_config['cwd']}")
print(f"โ
Environment variables: {list(elevenlabs_config['env'].keys())}")
# Check if the Python path exists
python_path = elevenlabs_config['command']
if os.path.exists(python_path):
print(f"โ
Python executable exists: {python_path}")
# Test the Python executable
try:
result = subprocess.run([python_path, "--version"], capture_output=True, text=True)
if result.returncode == 0:
print(f"โ
Python version: {result.stdout.strip()}")
else:
print(f"โ Python executable failed: {result.stderr}")
return False
except Exception as e:
print(f"โ Error testing Python: {e}")
return False
else:
print(f"โ Python executable not found: {python_path}")
return False
return True
else:
print("โ ElevenLabs configuration not found")
return False
except Exception as e:
print(f"โ Error reading configuration: {e}")
return False
def main():
"""Main test function."""
print("๐งช Testing Fixed Claude Desktop Configuration")
print("=" * 60)
# Verify configuration
config_ok = verify_claude_desktop_config()
if config_ok:
# Test server execution
server_ok = test_with_fixed_config()
print("\n" + "=" * 60)
if server_ok:
print("๐ SUCCESS! The fixed configuration works!")
print("\n๐ Next steps:")
print("1. ๐ Restart Claude Desktop completely (Quit and reopen)")
print("2. โณ Wait 30 seconds for MCP server to initialize")
print("3. ๐ Look for MCP connection indicator in Claude Desktop")
print("4. ๐งช Test with: 'What MCP tools are available?'")
print("\n๐ If still not working:")
print("- Check Claude Desktop logs for new errors")
print("- Try creating a simple wrapper script")
print("- Ensure Claude Desktop has latest version")
else:
print("โ Server configuration has issues")
print("๐ง Fix the server before testing with Claude Desktop")
else:
print("โ Configuration has issues")
print("๐ง Fix the configuration before testing")
if __name__ == "__main__":
main()