#!/usr/bin/env python
"""Test script to verify MCP server starts correctly"""
import asyncio
import sys
from io import StringIO
from unittest.mock import patch, AsyncMock
from src.server import OpenF1MCPServer
async def test_server_startup():
"""Test that the server can be initialized"""
server = OpenF1MCPServer()
# Verify server is created
assert server.server is not None, "Server object should be created"
# Verify tools are registered
tools = server.get_tools()
assert len(tools) == 12, f"Expected 12 tools, got {len(tools)}"
# Verify all tools have required fields
for tool in tools:
assert tool.name, "Tool should have a name"
assert tool.description, "Tool should have a description"
assert tool.inputSchema, "Tool should have inputSchema"
print("✓ Server initialization successful")
print(f"✓ {len(tools)} tools registered")
print("✓ All tools have required fields")
return True
if __name__ == "__main__":
try:
result = asyncio.run(test_server_startup())
if result:
print("\n✅ Server startup test PASSED")
sys.exit(0)
except Exception as e:
print(f"\n❌ Server startup test FAILED: {e}")
import traceback
traceback.print_exc()
sys.exit(1)