release r008 add safe read-only shell
This commit is contained in:
1 parent
65922b7f57
commit
6480b9678c
10 files changed
+203
-21
No files matched your search
+44
-2
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* MUA — Mikes Unraid Agent
|
||||
* tools.ts — MCP Tool-Definitionen (22 Tools)
|
||||
* tools.ts — MCP Tool-Definitionen (23 Tools)
|
||||
*
|
||||
* Portiert von mcp/tools.php. Schema: unraid_<kategorie>_<aktion>
|
||||
* Kategorien: docker (14), network (6), system (2).
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
connectionTest,
|
||||
validateName,
|
||||
runShell,
|
||||
runReadOnlyCommand,
|
||||
} from "./helpers";
|
||||
|
||||
export interface ToolDef {
|
||||
@@ -321,7 +322,7 @@ export const TOOLS: ToolDef[] = [
|
||||
},
|
||||
},
|
||||
|
||||
// ── System (2) ────────────────────────────────────────────────────────
|
||||
// ── System (3) ────────────────────────────────────────────────────────
|
||||
{
|
||||
name: "unraid_system_connection_test",
|
||||
description:
|
||||
@@ -329,6 +330,47 @@ export const TOOLS: ToolDef[] = [
|
||||
inputSchema: empty,
|
||||
handler: () => connectionTest(),
|
||||
},
|
||||
{
|
||||
name: "unraid_system_shell_readonly",
|
||||
description:
|
||||
"Run a strictly allowlisted read-only command without a shell interpreter. Supports diagnostics such as ls, tail, head, cat, grep, stat, find, ps, df, du, ss and read-only ip show/list operations. Pipes, redirects, command chaining and mutating options are impossible or rejected.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
program: {
|
||||
type: "string",
|
||||
enum: [
|
||||
"cat", "date", "df", "dmesg", "du", "file", "find", "free", "grep",
|
||||
"head", "hostname", "id", "ip", "lsof", "ls", "lsblk", "lspci", "mount",
|
||||
"ps", "readlink", "realpath", "sha256sum", "ss", "stat", "tail", "uname",
|
||||
"uptime", "wc", "whoami",
|
||||
],
|
||||
description: "Allowlisted read-only program",
|
||||
},
|
||||
args: {
|
||||
type: "array",
|
||||
items: { type: "string", maxLength: 4096 },
|
||||
maxItems: 64,
|
||||
description: "Argument vector; passed directly without /bin/sh",
|
||||
},
|
||||
timeout_seconds: int("Timeout in seconds (1-120, default 30)"),
|
||||
},
|
||||
required: ["program"],
|
||||
additionalProperties: false,
|
||||
},
|
||||
handler: (a) => {
|
||||
const program = (a["program"] as string) ?? "";
|
||||
const rawArgs = a["args"] ?? [];
|
||||
if (!Array.isArray(rawArgs) || rawArgs.some((arg) => typeof arg !== "string")) {
|
||||
throw new Error("args must be an array of strings");
|
||||
}
|
||||
const timeout = Number(a["timeout_seconds"] ?? 30);
|
||||
if (timeout < 1 || timeout > 120) {
|
||||
throw new Error("timeout_seconds must be between 1 and 120");
|
||||
}
|
||||
return runReadOnlyCommand(program, rawArgs as string[], timeout);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "unraid_system_shell",
|
||||
description:
|
||||
|
||||
Reference in new issue
Block a user