#!/usr/bin/env python3
"""Simple test script for the ElevenLabs MCP server."""
import asyncio
import json
import sys
import os
# Add the src directory to the path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from elevenlabs_mcp.server import mcp
from elevenlabs_mcp.config import settings
async def test_server_initialization():
"""Test that the server initializes correctly."""
print("Testing ElevenLabs MCP Server...")
# Test configuration
print(f"✓ Server Name: {settings.server_name}")
print(f"✓ Server Version: {settings.server_version}")
print(f"✓ Base URL: {settings.elevenlabs_base_url}")
# Test that the server is properly initialized
print("✓ Server initialized successfully")
# Test that we can import the tools
from elevenlabs_mcp.server import create_agent, list_agents, get_agent
print("✓ Agent management tools imported successfully")
from elevenlabs_mcp.server import create_tool, list_tools, get_tool
print("✓ Tool management tools imported successfully")
from elevenlabs_mcp.server import create_knowledge_base_from_text, list_knowledge_base_documents
print("✓ Knowledge base management tools imported successfully")
# Test that we can call the functions
print("\nTesting tool accessibility...")
try:
# Test that functions are callable
assert callable(create_agent), "create_agent should be callable"
assert callable(list_agents), "list_agents should be callable"
assert callable(get_agent), "get_agent should be callable"
print("✓ All tools are callable")
except Exception as e:
print(f"✗ Tool accessibility test failed: {e}")
return False
print("\n✅ All tests passed! Server is ready to use.")
return True
async def test_mock_tool_execution():
"""Test tool execution with mock data (no actual API calls)."""
print("\nTesting mock tool execution...")
# Mock the ElevenLabs client to avoid actual API calls
from elevenlabs_mcp.client import ElevenLabsClient
from elevenlabs_mcp.server import get_client
class MockClient:
async def list_agents(self, cursor=None, page_size=30):
return {
"agents": [
{
"agent_id": "test-agent-123",
"name": "Test Agent",
"conversation_config": {
"agent": {
"language": "en",
"prompt": {"prompt": "Test prompt"}
}
}
}
],
"next_cursor": None,
"has_more": False
}
async def close(self):
pass
# Replace the client with our mock
import elevenlabs_mcp.server
elevenlabs_mcp.server.elevenlabs_client = MockClient()
# Test the list_agents tool
from elevenlabs_mcp.server import list_agents
result = await list_agents()
# Parse the JSON result
parsed_result = json.loads(result)
if "agents" in parsed_result and len(parsed_result["agents"]) > 0:
print("✓ Mock tool execution successful")
print(f" Result: {parsed_result}")
return True
else:
print("✗ Mock tool execution failed")
return False
if __name__ == "__main__":
async def main():
success = await test_server_initialization()
if success:
success = await test_mock_tool_execution()
if success:
print("\n🎉 All tests passed! The ElevenLabs MCP Server is working correctly.")
else:
print("\n❌ Some tests failed. Please check the configuration.")
sys.exit(1)
asyncio.run(main())