Skip to main content
Glama
mattlemmone

Expo MCP Server

by mattlemmone

listFiles

Retrieve a list of files from a specified directory to manage project files efficiently in Expo-based React Native development environments.

Instructions

List files in a directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryPathYesThe path to the directory to list files from

Implementation Reference

  • The main handler function implementing the listFiles tool. Normalizes the directory path, lists files and directories using fs.promises.readdir, constructs a list with name, isDirectory, and full path for each entry, and returns a JSON-formatted text response. Includes logging and error handling.
    export async function listFiles(args: { directoryPath: string }, { log }: LogContext) {
      try {
        log.info(`Listing files in directory: ${args.directoryPath}`);
    
        const normalizedPath = path.normalize(args.directoryPath);
        const files = await fs.promises.readdir(normalizedPath, { withFileTypes: true });
    
        const fileList = files.map((file) => ({
          name: file.name,
          isDirectory: file.isDirectory(),
          path: path.join(normalizedPath, file.name),
        }));
    
        log.info(
          `Successfully listed ${fileList.length} files in ${normalizedPath}`,
        );
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(fileList, null, 2),
            },
          ],
        };
      } catch (error: any) {
        log.error(`Error listing files: ${error.message}`);
        throw new Error(`Failed to list files: ${error.message}`);
      }
    }
  • src/index.ts:37-46 (registration)
    Registration of the listFiles tool on the FastMCP server using addTool. Includes the tool name, description, Zod input schema for directoryPath parameter, and assignment of the handler function to execute.
    addTool({
      name: "listFiles",
      description: "List files in a directory",
      parameters: z.object({
        directoryPath: z
          .string()
          .describe("The path to the directory to list files from"),
      }),
      execute: listFiles,
    });
  • Zod schema defining the input parameters for the listFiles tool: a single required string parameter directoryPath with description.
    parameters: z.object({
      directoryPath: z
        .string()
        .describe("The path to the directory to list files from"),
    }),
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action but lacks details on permissions needed, whether it's read-only or has side effects, error handling, or output format. This is a significant gap for a tool with no annotation coverage.

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, clear sentence with zero waste. It's appropriately sized and front-loaded, efficiently conveying the core functionality 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 the tool has no annotations, no output schema, and the description lacks behavioral details, it's incomplete. For a file listing tool, the description should address aspects like recursion, filtering, or output structure to be fully helpful to an AI agent.

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%, so the schema already documents the 'directoryPath' parameter. The description adds no additional meaning beyond what the schema provides, such as path format examples or constraints. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the verb ('List') and resource ('files in a directory'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'listTools' or specify what types of files are included (e.g., all files vs. filtered).

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'readFile' or 'tailFile', nor does it mention prerequisites or constraints. It simply states what the tool does without context about appropriate usage scenarios.

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