tail_file
Display the last lines of a remote file via SFTP to monitor logs or check recent changes. Specify server alias, file path, and optional line count.
Instructions
Équivalent de tail -n pour afficher les dernières lignes d'un fichier distant.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alias | Yes | Alias du serveur cible. | |
| filepath | Yes | Chemin absolu du fichier à lire. | |
| lines | No | Nombre de lignes à afficher. |
Implementation Reference
- server.js:779-791 (handler)The asynchronous handler function for the 'tail_file' tool. It constructs a 'tail -n' command, queues an SSH job to execute it on the remote server, waits for completion, and returns the file tail content or a background task message.async (params) => { const cmd = `tail -n ${params.lines} ${params.filepath}`; 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: `📄 Contenu de ${params.filepath} (${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:773-777 (schema)Zod input schema defining parameters for the 'tail_file' tool: server alias, file path, and optional number of lines (default 50).inputSchema: z.object({ alias: z.string().describe("Alias du serveur cible."), filepath: z.string().describe("Chemin absolu du fichier à lire."), lines: z.number().optional().default(50).describe("Nombre de lignes à afficher.") })
- server.js:768-792 (registration)Registration of the 'tail_file' tool using server.registerTool, providing title, description, input schema, and inline handler function.server.registerTool( "tail_file", { title: "Afficher les dernières lignes d'un fichier", description: "Équivalent de tail -n pour afficher les dernières lignes d'un fichier distant.", inputSchema: z.object({ alias: z.string().describe("Alias du serveur cible."), filepath: z.string().describe("Chemin absolu du fichier à lire."), lines: z.number().optional().default(50).describe("Nombre de lignes à afficher.") }) }, async (params) => { const cmd = `tail -n ${params.lines} ${params.filepath}`; 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: `📄 Contenu de ${params.filepath} (${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.` }] }; } } );