issues with mcp con

This commit is contained in:
larssand
2026-06-30 12:40:46 +02:00
parent 90076aa95a
commit e781f66003

View File

@@ -561,6 +561,24 @@ def serve_dashboard(host: str, port: int, status_file: str, *, image_dir: str |
image_root = Path(image_dir) if image_dir else None
config_store = ConfigStore(config_file)
def read_status() -> dict[str, object]:
try:
status = json.loads(status_path.read_text(encoding="utf-8")) if status_path.exists() else {}
except json.JSONDecodeError:
status = {}
if not isinstance(status, dict):
status = {}
status.setdefault("status_schema", 2)
for row in status.get("stream_coverage", []) if isinstance(status.get("stream_coverage"), list) else []:
if isinstance(row, dict):
row.setdefault("aggregate_error", "")
row.setdefault("raw_error", "")
if row.get("aggregate_status") == "error" and not row.get("aggregate_error") and row.get("error"):
row["aggregate_error"] = str(row.get("error", ""))
if row.get("partial") and not row.get("raw_error") and row.get("error"):
row["raw_error"] = str(row.get("error", ""))
return status
class Handler(BaseHTTPRequestHandler):
def do_GET(self) -> None:
if self.path == "/":
@@ -618,21 +636,14 @@ def serve_dashboard(host: str, port: int, status_file: str, *, image_dir: str |
self._send(400, "application/json", json.dumps({"error": str(exc)}).encode("utf-8"))
return
if self.path == "/api/status":
if status_path.exists():
body = status_path.read_bytes()
else:
body = json.dumps({"summary": {}, "anomalies": [], "block_candidates": []}).encode("utf-8")
self._send(200, "application/json", body)
self._send(200, "application/json", json.dumps(read_status()).encode("utf-8"))
return
if self.path.startswith("/api/export/incidents"):
parsed = urlparse(self.path)
params = parse_qs(parsed.query)
fmt = params.get("format", ["markdown"])[0]
incident_id = params.get("incident_id", [""])[0] or None
try:
status = json.loads(status_path.read_text(encoding="utf-8")) if status_path.exists() else {}
except json.JSONDecodeError:
status = {}
status = read_status()
report = investigation_report(status, incident_id=incident_id)
if fmt == "json":
self._send(200, "application/json", json.dumps(report, indent=2, sort_keys=True).encode("utf-8"))
@@ -640,10 +651,7 @@ def serve_dashboard(host: str, port: int, status_file: str, *, image_dir: str |
self._send(200, "text/markdown; charset=utf-8", investigation_report_markdown(report).encode("utf-8"))
return
if self.path == "/metrics":
try:
status = json.loads(status_path.read_text(encoding="utf-8")) if status_path.exists() else {}
except json.JSONDecodeError:
status = {}
status = read_status()
self._send(200, "text/plain; version=0.0.4; charset=utf-8", prometheus_metrics(status).encode("utf-8"))
return
if self.path.startswith("/images/") and image_root: