read_multiple_files
Read multiple files at once to access their contents simultaneously, saving time compared to reading files individually.
Instructions
Read multiple files simultaneously
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | Yes | Array of file paths to read |
Implementation Reference
- src/index.ts:252-278 (handler)The handler function for the 'read_multiple_files' tool. Extracts paths from input, loops through each validating access and reading content or capturing errors, then returns a JSON-formatted array of results with path, content, or error per file.case 'read_multiple_files': { const { paths } = request.params.arguments as { paths: string[] }; const results: { path: string; content?: string; error?: string }[] = []; for (const filePath of paths) { try { validatePath(filePath); const content = await fs.readFile(filePath, 'utf8'); results.push({ path: filePath, content }); } catch (error) { results.push({ path: filePath, error: error instanceof Error ? error.message : String(error) }); } } return { content: [ { type: 'text', text: JSON.stringify(results, null, 2), }, ], }; }
- src/index.ts:109-125 (registration)Registration of the 'read_multiple_files' tool in the ListTools response, specifying name, description, and input schema for an object with required 'paths' array of strings.{ name: 'read_multiple_files', description: 'Read multiple files simultaneously', inputSchema: { type: 'object', properties: { paths: { type: 'array', items: { type: 'string', }, description: 'Array of file paths to read', }, }, required: ['paths'], }, },
- src/index.ts:112-124 (schema)Input schema definition for the 'read_multiple_files' tool, requiring an object with a 'paths' property that is an array of strings.inputSchema: { type: 'object', properties: { paths: { type: 'array', items: { type: 'string', }, description: 'Array of file paths to read', }, }, required: ['paths'], },