#!/usr/bin/env python3 """ Test script to verify MCP server connection """ import asyncio import aiohttp import json async def test_mcp_server(): """Test the MCP server on Hugging Face Spaces""" url = "https://galcan-mcp-docs-server.hf.space" print("Testing MCP server connection...") print(f"URL: {url}") try: async with aiohttp.ClientSession() as session: # Test health check async with session.get(f"{url}/") as response: if response.status == 200: data = await response.json() print(f"[OK] Health check passed: {data}") else: print(f"[ERROR] Health check failed: {response.status}") return False # Test search endpoint search_data = { "query": "MCP architecture", "limit": 3 } async with session.post(f"{url}/search", json=search_data) as response: if response.status == 200: data = await response.json() print(f"[OK] Search test passed: Found {data.get('total', 0)} results") else: print(f"[ERROR] Search test failed: {response.status}") return False print("[SUCCESS] MCP server is working correctly!") return True except Exception as e: print(f"[ERROR] Connection failed: {e}") return False if __name__ == "__main__": asyncio.run(test_mcp_server())