#!/usr/bin/env python3
"""Test script to check MCP backend directly."""
import asyncio
import sys
import os
# Add server to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'server'))
from backends.comfyui import ComfyUIBackend
async def test_mcp_backend():
"""Test MCP backend directly."""
backend = ComfyUIBackend(host="127.0.0.1", port=8188)
print("Testing backend health check...")
healthy = await backend.health_check()
print(f"Backend healthy: {healthy}")
if not healthy:
print("Backend not healthy, exiting")
return
print("\nTesting simple generation...")
try:
image_bytes = await backend.generate_image(
prompt="red cube",
width=64,
height=64,
steps=4
)
print(f"Generation successful! Got {len(image_bytes)} bytes")
# Save test image
with open("test_output.png", "wb") as f:
f.write(image_bytes)
print("Saved test_output.png")
except Exception as e:
print(f"Generation failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(test_mcp_backend())