mcp: health sidecar — port 8091, separate from FastMCP on 8090

This commit is contained in:
2026-05-06 17:04:11 +00:00
parent 4f6dd46580
commit d37ce128cb
+34
View File
@@ -0,0 +1,34 @@
"""
Health sidecar — exposes GET /health on port 8091 for Docker HEALTHCHECK.
Runs in a thread alongside the FastMCP server.
"""
import threading
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
import os
def run_health_server(port: int = 8091):
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == "/health":
body = json.dumps({"status": "ok"}).encode()
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.end_headers()
self.wfile.write(body)
else:
self.send_response(404)
self.end_headers()
def log_message(self, *args):
pass # suppress access logs
server = HTTPServer(("0.0.0.0", port), Handler)
server.serve_forever()
def start_health_thread():
port = int(os.environ.get("HEALTH_PORT", 8091))
t = threading.Thread(target=run_health_server, args=(port,), daemon=True)
t.start()