#!/usr/bin/env python3
"""Test script to verify Claude Desktop setup requirements."""
import json
import os
import sys
import subprocess
from pathlib import Path
def test_claude_desktop_setup():
"""Test that everything is ready for Claude Desktop integration."""
print("Testing Claude Desktop Setup Requirements...")
print("=" * 60)
success = True
# Test 1: Check if MCP server can be imported
print("\n1. Testing MCP Server Import...")
try:
# Add src to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from elevenlabs_mcp.server import mcp, main
from elevenlabs_mcp.config import settings
print(f"✓ Server imported successfully")
print(f"✓ Server name: {mcp.name}")
print(f"✓ Server version: {settings.server_version}")
except Exception as e:
print(f"✗ Failed to import server: {e}")
success = False
# Test 2: Check if server can be executed as module
print("\n2. Testing Module Execution...")
try:
# Test that the module can be found
result = subprocess.run([
sys.executable, '-c',
'import sys; sys.path.insert(0, "src"); from elevenlabs_mcp.server import main; print("Module executable")'
], capture_output=True, text=True, timeout=5)
if result.returncode == 0:
print("✓ Module can be executed")
else:
print(f"✗ Module execution failed: {result.stderr}")
success = False
except subprocess.TimeoutExpired:
print("✓ Module execution started (timeout after 5s is expected)")
except Exception as e:
print(f"✗ Module execution test failed: {e}")
success = False
# Test 3: Check Python path resolution
print("\n3. Testing Python Path Resolution...")
try:
current_dir = os.path.dirname(os.path.abspath(__file__))
src_dir = os.path.join(current_dir, 'src')
if os.path.exists(src_dir):
print(f"✓ Source directory exists: {src_dir}")
else:
print(f"✗ Source directory missing: {src_dir}")
success = False
module_path = os.path.join(src_dir, 'elevenlabs_mcp', 'server.py')
if os.path.exists(module_path):
print(f"✓ Server module exists: {module_path}")
else:
print(f"✗ Server module missing: {module_path}")
success = False
except Exception as e:
print(f"✗ Path resolution test failed: {e}")
success = False
# Test 4: Generate Claude Desktop configuration
print("\n4. Generating Claude Desktop Configuration...")
try:
current_dir = os.path.dirname(os.path.abspath(__file__))
config = {
"mcpServers": {
"elevenlabs": {
"command": "python",
"args": ["-m", "elevenlabs_mcp.server"],
"cwd": current_dir,
"env": {
"ELEVENLABS_API_KEY": "your-api-key-here",
"PYTHONPATH": os.path.join(current_dir, "src")
}
}
}
}
config_path = os.path.join(current_dir, "claude_desktop_config_ready.json")
with open(config_path, 'w') as f:
json.dump(config, f, indent=2)
print(f"✓ Configuration generated: {config_path}")
print(f"✓ Working directory: {current_dir}")
print(f"✓ Python path: {os.path.join(current_dir, 'src')}")
except Exception as e:
print(f"✗ Configuration generation failed: {e}")
success = False
# Test 5: Check environment variable handling
print("\n5. Testing Environment Variables...")
try:
# Test with mock API key
os.environ['ELEVENLABS_API_KEY'] = 'test-key'
from elevenlabs_mcp.config import Settings
test_settings = Settings()
if test_settings.elevenlabs_api_key == 'test-key':
print("✓ Environment variable handling works")
else:
print(f"✗ Environment variable not read correctly: {test_settings.elevenlabs_api_key}")
success = False
except Exception as e:
print(f"✗ Environment variable test failed: {e}")
success = False
# Test 6: Verify all tools are available
print("\n6. Testing Tool Availability...")
try:
from elevenlabs_mcp.server import (
create_agent, get_agent, list_agents, update_agent, delete_agent,
create_tool, get_tool, list_tools, update_tool, delete_tool,
create_knowledge_base_from_text, create_knowledge_base_from_url,
get_knowledge_base_document, list_knowledge_base_documents,
update_knowledge_base_document, delete_knowledge_base_document,
compute_rag_index, get_document_content
)
tools = [
create_agent, get_agent, list_agents, update_agent, delete_agent,
create_tool, get_tool, list_tools, update_tool, delete_tool,
create_knowledge_base_from_text, create_knowledge_base_from_url,
get_knowledge_base_document, list_knowledge_base_documents,
update_knowledge_base_document, delete_knowledge_base_document,
compute_rag_index, get_document_content
]
for tool in tools:
if not callable(tool):
print(f"✗ Tool {tool.__name__} is not callable")
success = False
print(f"✓ All {len(tools)} tools are available and callable")
except Exception as e:
print(f"✗ Tool availability test failed: {e}")
success = False
# Display final results
print("\n" + "=" * 60)
if success:
print("🎉 Claude Desktop Setup Test PASSED!")
print("\nNext steps:")
print("1. Get your ElevenLabs API key from https://elevenlabs.io/app/settings/api-keys")
print("2. Copy claude_desktop_config_ready.json to your Claude Desktop config directory:")
print(" macOS: ~/Library/Application Support/Claude/claude_desktop_config.json")
print(" Windows: %APPDATA%/Claude/claude_desktop_config.json")
print("3. Replace 'your-api-key-here' with your actual API key")
print("4. Restart Claude Desktop")
print("5. Look for the MCP server connection in Claude Desktop")
print("\nTest commands to try in Claude Desktop:")
print("- 'What MCP tools are available?'")
print("- 'List my ElevenLabs agents'")
print("- 'Show my ElevenLabs knowledge base documents'")
print("- 'Create a simple customer service agent'")
else:
print("❌ Claude Desktop Setup Test FAILED!")
print("\nPlease fix the issues above before configuring Claude Desktop.")
return success
if __name__ == "__main__":
test_claude_desktop_setup()