Skip to main content
Glama
mattlemmone

Expo MCP Server

by mattlemmone

tailFile

Retrieve the last N lines of a file to monitor logs or extract recent data efficiently. Specify the file path and number of lines for quick file analysis and debugging.

Instructions

Read the last N lines from a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesThe path to the file to tail
linesYesNumber of lines to read from the end of the file

Implementation Reference

  • The handler function that reads the last N lines from the specified file and returns them as text content.
    export async function tailFile(args: { filePath: string; lines: number }, { log }: LogContext) {
      try {
        log.info(`Tailing file at path: ${args.filePath} (${args.lines} lines)`);
    
        const normalizedPath = path.normalize(args.filePath);
        
        // Read the entire file content
        const fileContent = await fs.promises.readFile(normalizedPath, "utf8");
        
        // Split by newlines and get the last N lines
        const allLines = fileContent.split('\n');
        const lastLines = allLines.slice(-args.lines).join('\n');
    
        log.info(`Successfully tailed ${args.lines} lines from file: ${normalizedPath}`);
    
        return {
          content: [
            {
              type: "text",
              text: lastLines,
            },
          ],
        };
      } catch (error: any) {
        log.error(`Error tailing file: ${error.message}`);
        throw new Error(`Failed to tail file: ${error.message}`);
      }
    }
  • Zod input schema defining filePath (string) and lines (positive integer).
    parameters: z.object({
      filePath: z.string().describe("The path to the file to tail"),
      lines: z.number().int().positive().describe("Number of lines to read from the end of the file"),
    }),
  • src/index.ts:48-56 (registration)
    Registers the tailFile tool with the FastMCP server, specifying name, description, input schema, and handler.
    addTool({
      name: "tailFile",
      description: "Read the last N lines from a file",
      parameters: z.object({
        filePath: z.string().describe("The path to the file to tail"),
        lines: z.number().int().positive().describe("Number of lines to read from the end of the file"),
      }),
      execute: tailFile,
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. While 'Read' implies a read-only operation, it doesn't disclose behavioral traits like file access permissions, error handling (e.g., if file doesn't exist), encoding considerations, or performance characteristics. The description is minimal and lacks context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it immediately understandable without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a tool with 2 parameters. It doesn't explain what the tool returns (e.g., lines as text, error messages), behavioral aspects like file locking or performance, or how it differs from similar tools. For a file operation tool, this leaves significant gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters (filePath and lines). The description adds minimal value beyond the schema by implying the relationship between 'last N lines' and the lines parameter, but doesn't provide additional syntax, format details, or constraints beyond what's already documented in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Read the last N lines') and resource ('from a file'), distinguishing it from sibling tools like readFile (which presumably reads the entire file) and writeFile (which modifies files). It uses precise terminology ('tail') that implies reading from the end.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for reading recent file content, but provides no explicit guidance on when to use this tool versus alternatives like readFile (for full file reading) or listFiles (for file listing). There's no mention of prerequisites, error conditions, or specific use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/mattlemmone/expo-mcp'

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