get_docker_logs
Retrieve Docker container logs from remote servers via SSH/SFTP to monitor application performance 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-766 (handler)Handler function that builds the 'docker logs' command based on parameters, queues an SSH job to execute it on the remote server, waits for completion, and returns the container logs.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:738-748 (schema)Input schema definition using Zod for validating tool parameters: server alias, container name/ID, optional lines, since, and timestamps.{ 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.") }) },
- server.js:736-766 (registration)Registration of the 'get_docker_logs' tool using McpServer.registerTool, including title, description, inputSchema, 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.` }] }; } } );