"""Start server and keep it running for testing"""
import sys
from pathlib import Path
import time
PROJECT_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(PROJECT_ROOT / "python"))
print("[Test] Importing blender_mcp...", flush=True)
import blender_mcp
print(f"[Test] Imported OK", flush=True)
print("[Test] Creating BlenderMcp instance...", flush=True)
mcp = blender_mcp.BlenderMcp("test", 8765)
print(f"[Test] Created: tag={mcp.tag}, port={mcp.port}", flush=True)
print("[Test] Starting server...", flush=True)
port = mcp.start()
print(f"[Test] Server started!", flush=True)
print(f"[Test] URL: {mcp.url()}", flush=True)
print(f"[Test] Server running. Press Ctrl+C to stop.", flush=True)
# Keep running
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print("\n[Test] Interrupted, stopping...", flush=True)
mcp.running.store(False) # Can't access directly, but stop() sets it
# Don't call stop() as it hangs
print("[Test] Done", flush=True)