synology_docker_manage
Manage Docker container lifecycle on Synology NAS: start, stop, restart, or remove containers via SSH with auto-privilege escalation.
Instructions
Manage container lifecycle (start, stop, restart)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform | |
| container_name | Yes | Name or ID of the container |
Implementation Reference
- src/index.ts:211-218 (handler)Handler for synology_docker_manage tool: validates action and container name, then executes docker start/stop/restart/rm via SSH.
else if (name === "synology_docker_manage") { const { action, container_name } = args as { action: string; container_name: string }; if (!VALID_DOCKER_ACTIONS.has(action)) { throw new Error(`Invalid action: ${action}`); } validateContainerName(container_name); const res = await execSshCommand(`docker ${action} ${shQuote(container_name)}`); return { content: [{ type: "text", text: `Command 'docker ${action} ${container_name}' executed.\nExit Code: ${res.code}\nOutput:\n${res.stdout || res.stderr}` }] }; - src/index.ts:134-145 (schema)Input schema for synology_docker_manage tool: action (enum) and container_name (string), both required.
{ name: "synology_docker_manage", description: "Manage container lifecycle (start, stop, restart)", inputSchema: { type: "object", properties: { action: { type: "string", enum: ["start", "stop", "restart", "rm"], description: "Action to perform" }, container_name: { type: "string", description: "Name or ID of the container" }, }, required: ["action", "container_name"], }, }, - src/index.ts:135-135 (registration)Tool is registered in the ListToolsRequestSchema handler as part of the tools array.
name: "synology_docker_manage", - src/index.ts:33-36 (helper)Helper function that validates container names (alphanumeric, underscore, dot, hyphen) used by the handler.
function validateContainerName(name: string): void { if (!/^[a-zA-Z0-9][a-zA-Z0-9_.\-]*$/.test(name)) { throw new Error(`Invalid container name: ${name}`); } - src/index.ts:28-30 (helper)Shell-quoting helper used by the handler to safely interpolate container names into SSH commands.
function shQuote(s: string): string { return "'" + s.replace(/'/g, "'\\''") + "'"; }