r006: Add unraid_system_shell tool (direct terminal access)

- New helper runShell(): executes /bin/sh -c, returns {exit_code, stdout, stderr} as JSON
- New tool unraid_system_shell: direct shell access on Unraid host (root)
  - params: command (required), timeout_seconds (1-300, default 60)
  - output size-limited via sanitizeLogOutput
- Version bump r005 -> r006
This commit is contained in:
Mikei386
2026-08-18 20:45:22 +02:00
parent c29fc00886
commit 38463190ee
3 changed files with 58 additions and 5 deletions
+29 -1
View File
@@ -13,7 +13,7 @@ import { createConnection, type Socket } from "net";
// ── Konstanten ──────────────────────────────────────────────────────────
export const MUA_SERVER_NAME = "mua";
export const MUA_VERSION = "2026.08.18.r005";
export const MUA_VERSION = "2026.08.18.r006";
export const MUA_PROTOCOL_VERSION = "2025-03-26";
export const PHP_HELPER = "/usr/local/bin/unraid-docker-mcp-helper.php";
@@ -53,6 +53,34 @@ export async function runLocal(
}
}
/**
* Shell-Befehl ausführen und strukturiertes Ergebnis liefern
* (exit_code + stdout + stderr). Für das unraid_system_shell-Tool.
* Liefert JSON, damit der Agent Exit-Code und beides Streams sieht.
*/
export async function runShell(cmd: string, timeoutSec = 60): Promise<string> {
try {
const proc = spawn(["/bin/sh", "-c", cmd], {
stdout: "pipe",
stderr: "pipe",
});
const timeout = setTimeout(() => proc.kill(), timeoutSec * 1000);
const [stdout, stderr, code] = await Promise.all([
new Response(proc.stdout).text(),
new Response(proc.stderr).text(),
proc.exited,
]);
clearTimeout(timeout);
return JSON.stringify({
exit_code: code,
stdout: sanitizeLogOutput(stdout.trim(), 100000),
stderr: sanitizeLogOutput(stderr.trim(), 20000),
});
} catch (e) {
throw new Error(`run_shell failed: ${String(e)}`);
}
}
/**
* Docker-Befehl ausführen (kompakt).
*/