Skip to main content
Glama
rawr-ai

Filesystem MCP Server

read_multiple_files

Read and process multiple files at once, returning content with file paths for analysis or comparison. Individual read failures do not halt the operation. Requires specified max bytes per file and operates within authorized directories.

Instructions

Read the contents of multiple files simultaneously. This is more efficient than reading files one by one when you need to analyze or compare multiple files. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation. Requires maxBytesPerFile parameter. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxBytesPerFileYesMaximum bytes to read per file. Must be a positive integer. Handler default: 10KB.
pathsYes

Implementation Reference

  • The core handler function for the 'read_multiple_files' tool. Parses arguments, validates paths, checks sizes, reads multiple files concurrently, handles per-file errors, returns combined content.
    export async function handleReadMultipleFiles(
      args: unknown,
      allowedDirectories: string[],
      symlinksMap: Map<string, string>,
      noFollowSymlinks: boolean
    ) {
      const { paths, maxBytesPerFile } = parseArgs(ReadMultipleFilesArgsSchema, args, 'read_multiple_files');
      const effectiveMaxBytes = maxBytesPerFile ?? (10 * 1024); // Default 10KB per file
      
      const results = await Promise.all(
        paths.map(async (filePath: string) => {
          try {
            const validPath = await validatePath(filePath, allowedDirectories, symlinksMap, noFollowSymlinks);
            
            // Check file size before reading
            const stats = await fs.stat(validPath);
            if (stats.size > effectiveMaxBytes) {
              return `${filePath}: Error - File size (${stats.size} bytes) exceeds the maximum allowed size (${effectiveMaxBytes} bytes).`;
            }
            
            const content = await fs.readFile(validPath, "utf-8");
            return `${filePath}:\n${content}\n`;
          } catch (error) {
            const errorMessage = error instanceof Error ? error.message : String(error);
            return `${filePath}: Error - ${errorMessage}`;
          }
        }),
      );
      return {
        content: [{ type: "text", text: results.join("\n---\n") }],
      };
    }
  • Defines the input schema using TypeBox for 'read_multiple_files': array of file paths and optional max bytes per file.
    export const ReadMultipleFilesArgsSchema = Type.Object({
      paths: Type.Array(Type.String()),
      maxBytesPerFile: Type.Integer({
        minimum: 1,
        description: 'Maximum bytes to read per file. Must be a positive integer. Handler default: 10KB.'
      })
    });
    export type ReadMultipleFilesArgs = Static<typeof ReadMultipleFilesArgsSchema>;
  • index.ts:169-175 (registration)
    Binds the handleReadMultipleFiles function to the 'read_multiple_files' tool name in the toolHandlers object, injecting server context parameters.
    read_multiple_files: (a: unknown) =>
      handleReadMultipleFiles(
        a,
        allowedDirectories,
        symlinksMap,
        noFollowSymlinks,
      ),
  • Maps the ReadMultipleFilesArgsSchema to 'read_multiple_files' key in the central toolSchemas export used by the MCP server for parameter validation.
    read_multiple_files: ReadMultipleFilesArgsSchema,
  • index.ts:306-306 (registration)
    Declares the 'read_multiple_files' tool metadata (name and description) in the allTools list, which determines available tools based on permissions.
    { name: "read_multiple_files", description: "Read multiple files" },
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: partial failure tolerance ('failed reads for individual files won't stop the entire operation'), output format ('each file's content is returned with its path as a reference'), and a constraint ('only works within allowed directories'). It lacks details on error handling or performance limits, but covers essential operational behavior.

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 front-loaded with the core purpose, followed by efficiency rationale, output details, failure behavior, and constraints in four concise sentences. Each sentence adds value without redundancy, making it highly efficient and well-structured.

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

Completeness4/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 does a good job covering purpose, usage, behavior, and constraints for a 2-parameter tool. It could be more complete by detailing error responses or exact output structure, but it provides sufficient context for effective tool selection and invocation.

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

Parameters4/5

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

Schema description coverage is 50% (only 'maxBytesPerFile' has a description). The description compensates by explicitly mentioning 'maxBytesPerFile' as required and implying 'paths' through 'multiple files,' though it doesn't fully explain the 'paths' parameter's format or constraints. This adds meaningful context beyond the schema, especially for the undocumented parameter.

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 contents of multiple files simultaneously'), distinguishes it from the sibling 'read_file' tool by emphasizing batch efficiency, and explains the resource scope ('files'). It explicitly contrasts with the one-by-one approach, making the purpose unambiguous and differentiated.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('more efficient than reading files one by one when you need to analyze or compare multiple files') and mentions constraints ('only works within allowed directories'). However, it does not explicitly state when NOT to use it or name specific alternatives among the many sibling tools, which prevents a perfect score.

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/rawr-ai/mcp-filesystem'

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