synology_docker_ps
Retrieve a list of all running Docker containers on your Synology NAS to monitor and manage container status.
Instructions
List all docker containers on the Synology NAS
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:114-121 (registration)Tool 'synology_docker_ps' registered in ListToolsRequestSchema handler with name, description, and empty inputSchema.
{ name: "synology_docker_ps", description: "List all docker containers on the Synology NAS", inputSchema: { type: "object", properties: {}, }, }, - src/index.ts:197-200 (handler)Handler for 'synology_docker_ps' tool: executes 'docker ps -a' via SSH and returns formatted output with container ID, names, status, ports, and image.
if (name === "synology_docker_ps") { const res = await execSshCommand(`docker ps -a --format "table {{.ID}}\\t{{.Names}}\\t{{.Status}}\\t{{.Ports}}\\t{{.Image}}"`); return { content: [{ type: "text", text: res.stdout || res.stderr }] }; } - src/index.ts:117-120 (schema)Input schema for synology_docker_ps: empty object (no parameters required).
inputSchema: { type: "object", properties: {}, }, - src/index.ts:72-109 (helper)execSshCommand helper function used by the handler to run SSH commands on the Synology NAS via sudo.
async function execSshCommand(command: string): Promise<{ stdout: string; stderr: string; code: number }> { return new Promise((resolve, reject) => { const conn = new Client(); conn.on("ready", () => { // Use printf to avoid shell expansion of password contents. const fullCommand = `export PATH=$PATH:/usr/local/bin:/opt/bin:/bin:/usr/bin && printf '%s\\n' ${shQuote(NAS_PASSWORD!)} | sudo -S sh -c ${shQuote(command)}`; conn.exec(fullCommand, (err, stream) => { if (err) { conn.end(); return reject(err); } let stdout = ""; let stderr = ""; stream .on("close", (code: number) => { conn.end(); resolve({ stdout, stderr, code }); }) .on("data", (data: any) => { stdout += data; }) .stderr.on("data", (data: any) => { stderr += data; }); }); }).on("error", (err) => { reject(err); }).connect({ host: NAS_HOST, port: NAS_PORT, username: NAS_USER, password: NAS_PASSWORD, readyTimeout: 30000, }); }); }