fix recon mcp

This commit is contained in:
larssand
2026-06-30 21:20:59 +02:00
parent 5a9588fe31
commit 81c0ba34a6
4 changed files with 34 additions and 1 deletions

View File

@@ -67,6 +67,7 @@ class GraylogMcpClient:
return f"Basic {credentials}"
def probe(self) -> dict[str, object]:
self.session_id = None
initialized = self._call(
"initialize",
{"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "fgAI", "version": "0.1"}},
@@ -84,4 +85,14 @@ class GraylogMcpClient:
return {"status": "connected", "tools": names, "tool_schemas": schemas, "server_version": version}
def call_tool(self, name: str, arguments: dict[str, object]) -> dict[str, object]:
return self._call("tools/call", {"name": name, "arguments": arguments})
try:
return self._call("tools/call", {"name": name, "arguments": arguments})
except RuntimeError as exc:
if not self._should_reconnect(str(exc)):
raise
self.probe()
return self._call("tools/call", {"name": name, "arguments": arguments})
@staticmethod
def _should_reconnect(error_text: str) -> bool:
return any(token in error_text for token in ("http_400", "http_404", "http_409", "connection_error"))

View File

@@ -310,6 +310,7 @@ def build_status(
summary["aggregate_backed"] = True
status = {
"status_schema": 2,
"stale": False,
"generated_at": int(time.time()),
"log_path": log_path,
"policy_path": policy_path,
@@ -341,6 +342,7 @@ def build_status(
"cross_source_correlations": correlations,
"incidents": incidents,
"data_quality": assess_data_quality(events, mcp_status),
"status_cache": {"served_from_cache": False, "reason": ""},
"anomalies": [
{
"subject": finding.subject,