ChunDe's picture
fix: Remove duplicate simple API that was overwriting comprehensive API
ba74669
raw
history blame
1.78 kB
"""Test MCP endpoints with proper timeouts for Playwright"""
import requests
import json
BASE_URL = "https://chunte-thumbnail-crafter-mini-mcp-experiment.hf.space"
print("\n" + "="*60)
print(" MCP Endpoint Test (with patience for browser startup)")
print("="*60 + "\n")
print("TEST: layout_list (this takes 30-90 seconds on first call)")
print("-" * 60)
print("Waiting for Playwright to launch browser...")
try:
# First call takes longest - browser startup
r = requests.post(
f"{BASE_URL}/tools",
json={"name": "layout_list", "arguments": {}},
timeout=120 # 2 minutes
)
print(f"\nStatus Code: {r.status_code}")
if r.status_code == 200:
data = r.json()
print("\nResponse:")
print(json.dumps(data, indent=2))
if data.get('success'):
print("\n" + "="*60)
print("SUCCESS! MCP server is fully functional!")
print("="*60)
print(f"\nFound {len(data.get('layouts', []))} layouts:")
for layout in data.get('layouts', []):
print(f" - {layout['id']}: {layout['name']}")
print("\nYou can now use this Space with HuggingChat or other AI agents!")
else:
print(f"\nERROR: {data.get('error')}")
else:
print(f"\nFailed with status {r.status_code}")
print(f"Response: {r.text[:500]}")
except requests.exceptions.Timeout:
print("\nTIMEOUT: Request took longer than 2 minutes")
print("This might happen if:")
print(" 1. Server is under heavy load")
print(" 2. Docker container is restarting")
print(" 3. Playwright is having issues")
print("\nTry again in a few minutes.")
except Exception as e:
print(f"\nERROR: {e}")
print("\n" + "="*60 + "\n")