r024: compact Docker inspect output
This commit is contained in:
1 parent
6876e495d6
commit
8977ced7cf
10 files changed
+84
-31
No files matched your search
+18
-13
@@ -15,7 +15,7 @@ import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync }
|
||||
|
||||
// ── Konstanten ──────────────────────────────────────────────────────────
|
||||
export const MUA_SERVER_NAME = "mua";
|
||||
export const MUA_VERSION = "2026.08.24.r023";
|
||||
export const MUA_VERSION = "2026.08.25.r024";
|
||||
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";
|
||||
@@ -475,7 +475,10 @@ export function sanitizeLogOutput(text: string, maxChars = 50000): string {
|
||||
}
|
||||
|
||||
// ── Compact Container Inspect ───────────────────────────────────────────
|
||||
export async function compactContainerInspect(container: string): Promise<string> {
|
||||
export async function compactContainerInspect(
|
||||
container: string,
|
||||
detail: "summary" | "full" = "summary",
|
||||
): Promise<string> {
|
||||
const raw = await dockerExec(`inspect --type container -- ${container}`);
|
||||
let data: unknown;
|
||||
try {
|
||||
@@ -485,7 +488,7 @@ export async function compactContainerInspect(container: string): Promise<string
|
||||
}
|
||||
if (Array.isArray(data)) data = data[0];
|
||||
const d = data as Record<string, any>;
|
||||
const compact = {
|
||||
const compact: Record<string, unknown> = {
|
||||
Id: (d.Id ?? "").slice(0, 12),
|
||||
Name: d.Name ?? "",
|
||||
State: {
|
||||
@@ -497,19 +500,21 @@ export async function compactContainerInspect(container: string): Promise<string
|
||||
Image: d.Config?.Image ?? "",
|
||||
NetworkMode: d.HostConfig?.NetworkMode ?? "",
|
||||
Ports: d.NetworkSettings?.Ports ?? [],
|
||||
// Environment-Werte enthalten sehr häufig API-Keys, Passwörter und
|
||||
// interne URLs. Für Diagnosezwecke reichen die vorhandenen Variablennamen.
|
||||
EnvNames: (d.Config?.Env ?? []).map((entry: unknown) =>
|
||||
typeof entry === "string" ? entry.split("=", 1)[0] : "",
|
||||
).filter((name: string) => name !== ""),
|
||||
Mounts: (d.Mounts ?? []).map((m: any) => ({
|
||||
Type: m.Type ?? "",
|
||||
Source: m.Source ?? "",
|
||||
Destination: m.Destination ?? "",
|
||||
})),
|
||||
RestartCount: d.RestartCount ?? 0,
|
||||
Created: d.Created ?? "",
|
||||
};
|
||||
if (detail === "full") {
|
||||
// Environment-Werte enthalten sehr häufig API-Keys, Passwörter und
|
||||
// interne URLs. Für Diagnosezwecke reichen die Variablennamen.
|
||||
compact.EnvNames = (d.Config?.Env ?? []).map((entry: unknown) =>
|
||||
typeof entry === "string" ? entry.split("=", 1)[0] : "",
|
||||
).filter((name: string) => name !== "");
|
||||
compact.Mounts = (d.Mounts ?? []).map((m: any) => ({
|
||||
Type: m.Type ?? "",
|
||||
Source: m.Source ?? "",
|
||||
Destination: m.Destination ?? "",
|
||||
}));
|
||||
}
|
||||
return JSON.stringify(compact);
|
||||
}
|
||||
|
||||
|
||||
+14
-3
@@ -107,13 +107,24 @@ export const TOOLS: ToolDef[] = [
|
||||
{
|
||||
name: "unraid_docker_inspect",
|
||||
description:
|
||||
"Inspect a single Docker container in detail (state, image, ports, redacted environment variable names, mounts). Secret values are never returned.",
|
||||
"Inspect one known Docker container directly. Default summary returns state, image, network mode and ports only. Use detail='full' only when redacted environment variable names or mounts are required. Secret values are never returned.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: { container: str("Container name or ID") },
|
||||
properties: {
|
||||
container: str("Container name or ID"),
|
||||
detail: {
|
||||
type: "string",
|
||||
enum: ["summary", "full"],
|
||||
description: "summary is compact; full additionally returns environment variable names and mounts. Default: summary.",
|
||||
},
|
||||
},
|
||||
required: ["container"],
|
||||
additionalProperties: false,
|
||||
},
|
||||
handler: (a) => compactContainerInspect(validateName(a["container"], "container")),
|
||||
handler: (a) => compactContainerInspect(
|
||||
validateName(a["container"], "container"),
|
||||
(a["detail"] as "summary" | "full" | undefined),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "unraid_docker_logs",
|
||||
|
||||
Reference in new issue
Block a user