rts-commander / tests /test_mcp_server.py
Luigi's picture
Initial commit: Complete RTS project with MCP evaluation
551ad28
raw
history blame
1.96 kB
#!/usr/bin/env python3
"""
Test script for the MCP server
"""
import asyncio
import sys
import os
import time
import signal
# Add the web directory to the path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
def test_mcp_server_import():
"""Test that we can import the MCP server module."""
try:
from mcp_server import RTSGameMCP
print("โœ“ Successfully imported RTSGameMCP")
return True
except Exception as e:
print(f"โœ— Failed to import RTSGameMCP: {e}")
return False
def test_mcp_server_creation():
"""Test that we can create an MCP server instance."""
try:
from mcp_server import RTSGameMCP
server = RTSGameMCP()
print("โœ“ Successfully created RTSGameMCP instance")
return True
except Exception as e:
print(f"โœ— Failed to create RTSGameMCP instance: {e}")
return False
async def test_mcp_server_startup():
"""Test that we can start the MCP server."""
try:
from mcp_server import RTSGameMCP
server = RTSGameMCP()
# This would normally start the server, but we'll just test initialization
print("โœ“ MCP server initialization successful")
return True
except Exception as e:
print(f"โœ— Failed to initialize MCP server: {e}")
return False
def main():
"""Run all tests."""
print("Testing MCP server...")
tests = [
test_mcp_server_import,
test_mcp_server_creation,
test_mcp_server_startup,
]
results = []
for test in tests:
if asyncio.iscoroutinefunction(test):
results.append(asyncio.run(test()))
else:
results.append(test())
if all(results):
print("\nโœ“ All MCP server tests passed!")
return 0
else:
print("\nโœ— Some MCP server tests failed!")
return 1
if __name__ == "__main__":
sys.exit(main())