Skip to main content
Glama

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
NameRequiredDescriptionDefault
aliasYesAlias du serveur cible.
containerYesNom ou ID du container Docker.
linesNoNombre de lignes à récupérer.
sinceNoLogs depuis (ex: '5m', '1h', '2024-01-01').
timestampsNoAfficher les timestamps.

Implementation Reference

  • 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.` }] }; } }
  • 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.` }] }; } } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fkom13/mcp-sftp-orchestrator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server