Spaces:
Sleeping
Sleeping
| from fastapi import APIRouter, Header, HTTPException | |
| from api.mcp_clients.web_client import WebClient | |
| router = APIRouter() | |
| web_client = WebClient() | |
| async def web_search( | |
| query: str, | |
| x_tenant_id: str = Header(None) | |
| ): | |
| """ | |
| Perform a live internet search using the Web MCP server. | |
| """ | |
| if not x_tenant_id: | |
| raise HTTPException(status_code=400, detail="Missing tenant ID") | |
| try: | |
| results = await web_client.search(query) | |
| return { | |
| "tenant_id": x_tenant_id, | |
| "query": query, | |
| "results": results | |
| } | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) | |