#!/usr/bin/env python3
"""Test the actual server execution."""
import asyncio
import sys
import os
import signal
# Add the src directory to the path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from elevenlabs_mcp.server import main
async def test_server_run():
"""Test that the server can run without errors."""
print("Testing server execution...")
try:
# Create a timeout to stop the server after a few seconds
async def run_with_timeout():
await asyncio.sleep(3) # Let the server run for 3 seconds
print("✓ Server ran successfully for 3 seconds")
return True
# Start the server in a separate task
server_task = asyncio.create_task(asyncio.to_thread(main))
timeout_task = asyncio.create_task(run_with_timeout())
# Wait for either the server to complete or the timeout
done, pending = await asyncio.wait(
[server_task, timeout_task],
return_when=asyncio.FIRST_COMPLETED
)
# Cancel any pending tasks
for task in pending:
task.cancel()
try:
await task
except asyncio.CancelledError:
pass
# If the timeout completed first, the server ran successfully
if timeout_task in done:
print("✓ Server execution test passed")
return True
else:
print("✗ Server execution test failed")
return False
except KeyboardInterrupt:
print("✓ Server responds to keyboard interrupt correctly")
return True
except Exception as e:
print(f"✗ Server execution failed: {e}")
return False
if __name__ == "__main__":
print("Testing ElevenLabs MCP Server Execution...")
print("=" * 50)
try:
success = asyncio.run(test_server_run())
print("\n" + "=" * 50)
if success:
print("🎉 Server execution test passed!")
print("\nThe server is ready to use. You can:")
print("1. Add it to Claude Desktop configuration")
print("2. Run it standalone: python -m elevenlabs_mcp.server")
print("3. Deploy it to the cloud using the provided scripts")
else:
print("❌ Server execution test failed.")
sys.exit(1)
except KeyboardInterrupt:
print("\n✓ Server shutdown gracefully")
print("🎉 Server execution test passed!")