Skip to main content
Glama
StrawHatAI

Claude Desktop Commander MCP

by StrawHatAI

read_multiple_files

Extract contents from multiple files simultaneously, returning each file's data with its path. Supports partial success by continuing even if some files fail to read. Operates within specified allowed directories.

Instructions

Read the contents of multiple files simultaneously. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsYes

Implementation Reference

  • The core handler function that reads multiple files, validates paths, reads contents or returns errors for each.
    export async function readMultipleFiles(paths: string[]): Promise<string[]> { return Promise.all( paths.map(async (filePath: string) => { try { const validPath = await validatePath(filePath); 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}`; } }), ); }
  • Zod schema for input validation: array of file paths.
    export const ReadMultipleFilesArgsSchema = z.object({ paths: z.array(z.string()), });
  • src/server.ts:134-140 (registration)
    Tool registration in the list of tools, including name, description, and input schema.
    name: "read_multiple_files", description: "Read the contents of multiple files simultaneously. " + "Each file's content is returned with its path as a reference. " + "Failed reads for individual files won't stop the entire operation. " + "Only works within allowed directories.", inputSchema: zodToJsonSchema(ReadMultipleFilesArgsSchema),
  • src/server.ts:273-278 (registration)
    Dispatch handler in the switch statement that parses args, calls the readMultipleFiles function, and formats the response.
    case "read_multiple_files": { const parsed = ReadMultipleFilesArgsSchema.parse(args); const results = await readMultipleFiles(parsed.paths); return { content: [{ type: "text", text: results.join("\n---\n") }], };

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/StrawHatAI/claude-dev-tools'

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