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:
+28
-3
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* MUA — Mikes Unraid Agent
|
||||
* tools.ts — MCP Tool-Definitionen (21 Tools)
|
||||
* tools.ts — MCP Tool-Definitionen (22 Tools)
|
||||
*
|
||||
* Portiert von mcp/tools.php. Schema: unraid_<kategorie>_<aktion>
|
||||
* Kategorien: docker (14), network (6), system (1).
|
||||
* Kategorien: docker (14), network (6), system (2).
|
||||
*/
|
||||
|
||||
import {
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
probeDualstack,
|
||||
connectionTest,
|
||||
validateName,
|
||||
runShell,
|
||||
} from "./helpers";
|
||||
|
||||
export interface ToolDef {
|
||||
@@ -294,7 +295,7 @@ export const TOOLS: ToolDef[] = [
|
||||
},
|
||||
},
|
||||
|
||||
// ── System (1) ────────────────────────────────────────────────────────
|
||||
// ── System (2) ────────────────────────────────────────────────────────
|
||||
{
|
||||
name: "unraid_system_connection_test",
|
||||
description:
|
||||
@@ -302,6 +303,30 @@ export const TOOLS: ToolDef[] = [
|
||||
inputSchema: empty,
|
||||
handler: () => connectionTest(),
|
||||
},
|
||||
{
|
||||
name: "unraid_system_shell",
|
||||
description:
|
||||
"Execute a shell command on the Unraid host (as root, via /bin/sh -c) and return exit code, stdout, and stderr. Use for direct terminal access: file inspection, system commands, package info, log reading, etc. Commands run with a timeout and output is size-limited.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
command: str(
|
||||
"Shell command to execute on the Unraid host (run via /bin/sh -c)",
|
||||
),
|
||||
timeout_seconds: int("Timeout in seconds (1-300, default 60)"),
|
||||
},
|
||||
required: ["command"],
|
||||
},
|
||||
handler: (a) => {
|
||||
const command = (a["command"] as string) ?? "";
|
||||
if (command.trim() === "") throw new Error("command is required");
|
||||
const timeout = Number(a["timeout_seconds"] ?? 60);
|
||||
if (timeout < 1 || timeout > 300) {
|
||||
throw new Error("timeout_seconds must be between 1 and 300");
|
||||
}
|
||||
return runShell(command, timeout);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export function toolByName(name: string): ToolDef | undefined {
|
||||
|
||||
Reference in New Issue
Block a user