From 1620d7a9b08cc660a78b74c75777a1fa079a55a8 Mon Sep 17 00:00:00 2001 From: saidsurucu Date: Sun, 13 Jul 2025 22:51:35 +0300 Subject: [PATCH] Update mcp_server_main.py --- mcp_server_main.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/mcp_server_main.py b/mcp_server_main.py index 3a1dea8..3678a8b 100644 --- a/mcp_server_main.py +++ b/mcp_server_main.py @@ -2376,7 +2376,6 @@ async def check_government_servers_health() -> Dict[str, Any]: if records_total > 0: health_results["yargitay"] = { "status": "healthy", - "records_total": records_total, "response_time_ms": response.elapsed.total_seconds() * 1000 } else: @@ -2401,10 +2400,16 @@ async def check_government_servers_health() -> Dict[str, Any]: # Check Bedesten API server try: bedesten_payload = { - "phrase": "karar", - "itemTypeList": ["YARGITAYKARARI"], - "pageSize": 5, - "page": 1 + "data": { + "pageSize": 5, + "pageNumber": 1, + "itemTypeList": ["YARGITAYKARARI"], + "phrase": "karar", + "sortFields": ["KARAR_TARIHI"], + "sortDirection": "desc" + }, + "applicationName": "UyapMevzuat", + "paging": True } async with httpx.AsyncClient( @@ -2423,18 +2428,25 @@ async def check_government_servers_health() -> Dict[str, Any]: if response.status_code == 200: response_data = response.json() - total_found = response_data.get("totalFound", 0) + logger.debug(f"Bedesten API response: {response_data}") + if response_data and isinstance(response_data, dict): + data_section = response_data.get("data") + if data_section and isinstance(data_section, dict): + total_found = data_section.get("total", 0) + else: + total_found = 0 + else: + total_found = 0 if total_found > 0: health_results["bedesten"] = { "status": "healthy", - "total_found": total_found, "response_time_ms": response.elapsed.total_seconds() * 1000 } else: health_results["bedesten"] = { "status": "unhealthy", - "reason": "totalFound is 0 or missing", + "reason": "total is 0 or missing in data field", "response_time_ms": response.elapsed.total_seconds() * 1000 } else: