release: r018 focused log analysis

This commit is contained in:
Mikei386
2026-08-24 10:42:43 +02:00
parent 02deec8dc9
commit 47c27b06c4
7 changed files with 48 additions and 13 deletions
+13 -1
View File
@@ -14,7 +14,7 @@ import { createHash, randomUUID } from "node:crypto";
// ── Konstanten ──────────────────────────────────────────────────────────
export const MUA_SERVER_NAME = "mua";
export const MUA_VERSION = "2026.08.24.r017";
export const MUA_VERSION = "2026.08.24.r018";
export const MUA_PROTOCOL_VERSION = "2025-03-26";
export const PHP_HELPER = "/usr/local/bin/unraid-docker-mcp-helper.php";
export const STATUS_HELPER = "/usr/local/bin/unraid-mcp-status-helper.php";
@@ -545,6 +545,7 @@ export async function analyzeContainerLogs(
since: string,
scanTail: number,
maxResults: number,
focusTerms: string[] = [],
): Promise<string> {
const severityLevels: Record<string, string[]> = {
error: ["error", "fatal", "panic", "exception", "traceback", "critical"],
@@ -553,6 +554,10 @@ export async function analyzeContainerLogs(
};
const patterns = severityLevels[severity] ?? severityLevels["error"];
const regex = new RegExp(`(${patterns.join("|")})`, "i");
const normalisedFocusTerms = focusTerms
.map((term) => term.trim().toLowerCase())
.filter((term) => term.length > 0)
.slice(0, 12);
// Ziel-Container: einzelner Container oder alle laufenden
let targets: string[];
@@ -575,6 +580,12 @@ export async function analyzeContainerLogs(
const raw = await dockerExec(logCmd, 120);
let containerMatches = 0;
for (const line of raw.split("\n")) {
if (
normalisedFocusTerms.length > 0
&& !normalisedFocusTerms.some((term) => line.toLowerCase().includes(term))
) {
continue;
}
const m = line.match(regex);
if (m) {
const key = m[1].toLowerCase();
@@ -594,6 +605,7 @@ export async function analyzeContainerLogs(
container,
since,
scan_tail: scanTail,
focus_terms: normalisedFocusTerms,
total_matches: Object.values(counts).reduce((a, b) => a + b, 0),
pattern_counts: counts,
containers_with_matches: containersWithMatches,
+21 -2
View File
@@ -131,7 +131,7 @@ export const TOOLS: ToolDef[] = [
{
name: "unraid_docker_analyze_logs",
description:
"Analyze container logs server-side for errors/warnings. Returns pattern counts and sample matches.",
"Analyze container logs server-side for errors/warnings in one bounded call. Use optional focus_terms to restrict results to components such as hass_mcp, yaml or zigbee instead of issuing multiple grep/shell calls. Returns pattern counts and sample matches.",
inputSchema: {
type: "object",
properties: {
@@ -144,6 +144,13 @@ export const TOOLS: ToolDef[] = [
since: str("Time filter (default 24h)"),
scan_tail: int("Max lines to scan (default 1000)"),
max_results: int("Max sample matches (default 50)"),
focus_terms: {
type: "array",
items: { type: "string", minLength: 1, maxLength: 80 },
maxItems: 12,
description:
"Optional literal component/topic terms. A log line must contain at least one term, case-insensitively. Bundle related terms in one call.",
},
},
required: ["severity"],
},
@@ -156,7 +163,19 @@ export const TOOLS: ToolDef[] = [
const since = (a["since"] as string) ?? "24h";
const scanTail = Number(a["scan_tail"] ?? 1000);
const maxResults = Number(a["max_results"] ?? 50);
return analyzeContainerLogs(severity, container ?? null, since, scanTail, maxResults);
const focusTerms = Array.isArray(a["focus_terms"])
? (a["focus_terms"] as unknown[]).filter(
(item): item is string => typeof item === "string",
)
: [];
return analyzeContainerLogs(
severity,
container ?? null,
since,
scanTail,
maxResults,
focusTerms,
);
},
},
{