Skip to main content
Glama

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
NameRequiredDescriptionDefault
aliasYesAlias du serveur cible.
filepathYesChemin absolu du fichier à lire.
linesNoNombre de lignes à afficher.

Implementation Reference

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

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