get_docker_logs
Retrieve Docker container logs from remote servers via SSH/SFTP to monitor application status and troubleshoot issues.
Instructions
Raccourci pour récupérer les logs d'un container Docker.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alias | Yes | Alias du serveur cible. | |
| container | Yes | Nom ou ID du container Docker. | |
| lines | No | Nombre de lignes à récupérer. | |
| since | No | Logs depuis (ex: '5m', '1h', '2024-01-01'). | |
| timestamps | No | Afficher les timestamps. |
Implementation Reference
- server.js:749-765 (handler)The handler function for get_docker_logs tool. It builds a 'docker logs' command based on input parameters (container, lines, since, timestamps), adds an SSH job to the queue, executes it, waits for completion, and returns the logs or a background task message.async (params) => { let cmd = `docker logs --tail ${params.lines}`; if (params.since) cmd += ` --since ${params.since}`; if (params.timestamps) cmd += ' --timestamps'; cmd += ` ${params.container}`; const job = queue.addJob({ type: 'ssh', alias: params.alias, cmd: cmd, streaming: false }); history.logTask(job); ssh.executeCommand(job.id); const finalJob = await waitForJobCompletion(job.id, config.syncTimeout); if (finalJob) { return { content: [{ type: "text", text: `🐳 Logs Docker (${params.container}) - ${finalJob.lineCount || 0} lignes:\n\n${finalJob.output || '(vide)'}` }] }; } else { return { content: [{ type: "text", text: `Tâche ${job.id} initiée en arrière-plan.` }] }; } }
- server.js:741-747 (schema)Input schema definition for the get_docker_logs tool using Zod, specifying parameters: alias (required), container (required), lines (optional, default 100), since (optional), timestamps (optional, default false).inputSchema: z.object({ alias: z.string().describe("Alias du serveur cible."), container: z.string().describe("Nom ou ID du container Docker."), lines: z.number().optional().default(100).describe("Nombre de lignes à récupérer."), since: z.string().optional().describe("Logs depuis (ex: '5m', '1h', '2024-01-01')."), timestamps: z.boolean().optional().default(false).describe("Afficher les timestamps.") })
- server.js:736-766 (registration)Registration of the get_docker_logs tool using server.registerTool, including title, description, input schema, and inline handler function.server.registerTool( "get_docker_logs", { title: "Récupérer les logs Docker", description: "Raccourci pour récupérer les logs d'un container Docker.", inputSchema: z.object({ alias: z.string().describe("Alias du serveur cible."), container: z.string().describe("Nom ou ID du container Docker."), lines: z.number().optional().default(100).describe("Nombre de lignes à récupérer."), since: z.string().optional().describe("Logs depuis (ex: '5m', '1h', '2024-01-01')."), timestamps: z.boolean().optional().default(false).describe("Afficher les timestamps.") }) }, async (params) => { let cmd = `docker logs --tail ${params.lines}`; if (params.since) cmd += ` --since ${params.since}`; if (params.timestamps) cmd += ' --timestamps'; cmd += ` ${params.container}`; const job = queue.addJob({ type: 'ssh', alias: params.alias, cmd: cmd, streaming: false }); history.logTask(job); ssh.executeCommand(job.id); const finalJob = await waitForJobCompletion(job.id, config.syncTimeout); if (finalJob) { return { content: [{ type: "text", text: `🐳 Logs Docker (${params.container}) - ${finalJob.lineCount || 0} lignes:\n\n${finalJob.output || '(vide)'}` }] }; } else { return { content: [{ type: "text", text: `Tâche ${job.id} initiée en arrière-plan.` }] }; } } );