rts-commander / start_with_mcp.py
Luigi's picture
Initial commit: Complete RTS project with MCP evaluation
551ad28
#!/usr/bin/env python3
"""
Start script for RTS game with MCP server
"""
import asyncio
import subprocess
import sys
import os
import signal
# Add the web directory to the path
sys.path.insert(0, os.path.dirname(__file__))
def start_main_server():
"""Start the main game server."""
print("Starting main game server...")
# Start the main server in a subprocess
main_server = subprocess.Popen(
[sys.executable, "start.py"],
cwd=os.path.dirname(__file__),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
return main_server
async def start_mcp_server():
"""Start the MCP server."""
print("Starting MCP server...")
# Import and start the MCP server
from mcp_server import RTSGameMCP
mcp_server = RTSGameMCP()
await mcp_server.run()
def signal_handler(signum, frame):
"""Handle shutdown signals."""
print("\nShutting down servers...")
sys.exit(0)
def main():
"""Main entry point."""
# Set up signal handlers for graceful shutdown
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
# Start the main server
main_server = start_main_server()
try:
# Start the MCP server
asyncio.run(start_mcp_server())
except KeyboardInterrupt:
print("\nShutting down...")
finally:
# Clean up processes
if main_server.poll() is None:
main_server.terminate()
main_server.wait()
if __name__ == "__main__":
main()