From 6fcc000c399982fd0ceebb17aca60e886394aacb Mon Sep 17 00:00:00 2001 From: Mikkel Georgsen Date: Mon, 30 Mar 2026 13:01:48 +0000 Subject: [PATCH] feat: health endpoint shows both bot statuses and inbox state Shows MCP bridge status, homelab bot active/inactive, inbox pending lines, and message stats. Co-Authored-By: Claude Opus 4.6 (1M context) --- mcp_bridge/mcp_server.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/mcp_bridge/mcp_server.py b/mcp_bridge/mcp_server.py index c2c667b..c41b879 100644 --- a/mcp_bridge/mcp_server.py +++ b/mcp_bridge/mcp_server.py @@ -199,9 +199,33 @@ async def ingest_message(request: Request) -> JSONResponse: async def health(request: Request) -> JSONResponse: - """Health check endpoint.""" + """Health check endpoint with both bot statuses.""" + from pathlib import Path + import subprocess as sp + status = db.get_status() - return JSONResponse({"status": "ok", **status}) + + # Check homelab bot inbox + inbox_path = Path.home() / "homelab" / "telegram" / "inbox" + inbox_size = inbox_path.stat().st_size if inbox_path.exists() else 0 + inbox_lines = len(inbox_path.read_text().splitlines()) if inbox_size > 0 else 0 + + # Check both services + mcp_active = True # We're running if this responds + try: + result = sp.run(["systemctl", "--user", "is-active", "telegram-bot"], + capture_output=True, text=True, timeout=2) + homelab_bot_active = result.stdout.strip() == "active" + except Exception: + homelab_bot_active = False + + return JSONResponse({ + "status": "ok", + "mcp_bridge": {"active": mcp_active, "telegram_polling": True}, + "homelab_bot": {"active": homelab_bot_active}, + "inbox": {"pending_lines": inbox_lines, "bytes": inbox_size}, + **status, + }) custom_routes = [