#!/usr/bin/env python3
"""Final verification that Claude Desktop integration is ready."""
import json
import os
import sys
import subprocess
from pathlib import Path
def get_claude_desktop_config_path():
"""Get the Claude Desktop configuration file path for the current OS."""
if sys.platform == "darwin": # macOS
return Path.home() / "Library/Application Support/Claude/claude_desktop_config.json"
elif sys.platform == "win32": # Windows
return Path.home() / "AppData/Roaming/Claude/claude_desktop_config.json"
else: # Linux
return Path.home() / ".config/Claude/claude_desktop_config.json"
def test_claude_desktop_integration():
"""Test that Claude Desktop integration is ready."""
print("๐ Claude Desktop Integration - Final Verification")
print("=" * 60)
success = True
# Test 1: Check Claude Desktop config exists
print("\n1. Checking Claude Desktop Configuration...")
claude_config_path = get_claude_desktop_config_path()
if not claude_config_path.exists():
print(f"โ Config file not found: {claude_config_path}")
success = False
else:
print(f"โ Config file exists: {claude_config_path}")
# Test 2: Validate configuration content
print("\n2. Validating Configuration Content...")
try:
with open(claude_config_path, 'r') as f:
config = json.load(f)
if "mcpServers" not in config:
print("โ No mcpServers section found")
success = False
elif "elevenlabs" not in config["mcpServers"]:
print("โ ElevenLabs server not configured")
success = False
else:
server_config = config["mcpServers"]["elevenlabs"]
# Check required fields
required_fields = ["command", "args", "cwd", "env"]
for field in required_fields:
if field not in server_config:
print(f"โ Missing required field: {field}")
success = False
else:
print(f"โ {field}: {server_config[field]}")
# Check environment variables
if "env" in server_config:
env = server_config["env"]
if "ELEVENLABS_API_KEY" not in env:
print("โ Missing ELEVENLABS_API_KEY")
success = False
elif "your-elevenlabs-api-key-here" in env["ELEVENLABS_API_KEY"]:
print("โ ๏ธ API key is placeholder - needs to be updated")
else:
print("โ API key is set")
if "PYTHONPATH" not in env:
print("โ Missing PYTHONPATH")
success = False
else:
print(f"โ PYTHONPATH: {env['PYTHONPATH']}")
except json.JSONDecodeError as e:
print(f"โ Invalid JSON in config file: {e}")
success = False
except Exception as e:
print(f"โ Error reading config: {e}")
success = False
# Test 3: Verify working directory and files
print("\n3. Verifying Working Directory and Files...")
try:
if "mcpServers" in config and "elevenlabs" in config["mcpServers"]:
cwd = config["mcpServers"]["elevenlabs"]["cwd"]
if not os.path.exists(cwd):
print(f"โ Working directory not found: {cwd}")
success = False
else:
print(f"โ Working directory exists: {cwd}")
# Check for key files
key_files = [
"src/elevenlabs_mcp/__init__.py",
"src/elevenlabs_mcp/server.py",
"src/elevenlabs_mcp/client.py",
"src/elevenlabs_mcp/config.py"
]
for file in key_files:
file_path = os.path.join(cwd, file)
if not os.path.exists(file_path):
print(f"โ Missing file: {file_path}")
success = False
else:
print(f"โ File exists: {file}")
except Exception as e:
print(f"โ Error verifying files: {e}")
success = False
# Test 4: Test module import
print("\n4. Testing Module Import...")
try:
# Add the source directory to path
if "mcpServers" in config and "elevenlabs" in config["mcpServers"]:
pythonpath = config["mcpServers"]["elevenlabs"]["env"]["PYTHONPATH"]
sys.path.insert(0, pythonpath)
# Try to import the module
from elevenlabs_mcp.server import mcp, main
from elevenlabs_mcp.config import settings
print("โ Module imports successful")
print(f"โ Server name: {mcp.name}")
print(f"โ Server version: {settings.server_version}")
except Exception as e:
print(f"โ Module import failed: {e}")
success = False
# Test 5: Test command execution (dry run)
print("\n5. Testing Command Execution (Dry Run)...")
try:
if "mcpServers" in config and "elevenlabs" in config["mcpServers"]:
server_config = config["mcpServers"]["elevenlabs"]
command = server_config["command"]
args = server_config["args"]
cwd = server_config["cwd"]
# Test that we can find the python executable
python_path = subprocess.run(["which", command], capture_output=True, text=True)
if python_path.returncode == 0:
print(f"โ Python executable found: {python_path.stdout.strip()}")
else:
print(f"โ ๏ธ Python executable not found in PATH")
# Test that we can resolve the module (without running it)
test_cmd = [command, "-c", f"import sys; sys.path.insert(0, '{server_config['env']['PYTHONPATH']}'); import elevenlabs_mcp.server; print('Module found')"]
result = subprocess.run(test_cmd, capture_output=True, text=True, cwd=cwd, timeout=10)
if result.returncode == 0:
print("โ Module can be executed")
else:
print(f"โ ๏ธ Module execution test failed: {result.stderr}")
except subprocess.TimeoutExpired:
print("โ Command execution started (timeout is expected)")
except Exception as e:
print(f"โ ๏ธ Command execution test failed: {e}")
# Display results
print("\n" + "=" * 60)
if success:
print("๐ Claude Desktop Integration is READY!")
print("\nNext steps:")
print("1. ๐ Update your API key in the config file:")
print(f" {claude_config_path}")
print("2. ๐ Restart Claude Desktop completely")
print("3. ๐งช Test the integration with these commands:")
print(" - 'What MCP tools are available?'")
print(" - 'List my ElevenLabs agents'")
print(" - 'Show my knowledge base documents'")
print(" - 'Create a simple customer service agent'")
print("\n๐ Configuration Summary:")
if "mcpServers" in config and "elevenlabs" in config["mcpServers"]:
server_config = config["mcpServers"]["elevenlabs"]
print(f" Command: {server_config['command']} {' '.join(server_config['args'])}")
print(f" Working Dir: {server_config['cwd']}")
print(f" Python Path: {server_config['env']['PYTHONPATH']}")
else:
print("โ Claude Desktop Integration has issues!")
print("\nPlease fix the issues above before using with Claude Desktop.")
return False
return success
if __name__ == "__main__":
test_claude_desktop_integration()