read_multiple_files
Read content from multiple files by providing their paths in an array.
Instructions
Read multiple files
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | Yes |
Implementation Reference
- src/filesystem_tools.js:103-135 (handler)The readMultipleFiles function that implements the tool logic. It takes an array of file paths and allowed directories, maps each path to readFile(), and returns a combined response with per-file success/error/content results.
/** * Reads multiple files at once * @param {Array<string>} filePaths - List of file paths to read * @param {Array<string>} allowedDirs - List of allowed directories * @returns {object} - Response object with file contents */ function readMultipleFiles(filePaths, allowedDirs) { try { if (!filePaths || !Array.isArray(filePaths) || filePaths.length === 0) { return { success: false, message: 'No file paths provided' }; } const results = filePaths.map(filePath => { const result = readFile(filePath, allowedDirs); return { path: filePath, success: result.success, content: result.success ? result.content : null, mimeType: result.mimeType, isText: result.isText, error: result.success ? null : result.message }; }); return { success: true, results }; } catch (error) { logger.error(`Error reading multiple files: ${error.message}`); return { success: false, message: `Error reading multiple files: ${error.message}` }; } } - src/mcp/server.js:82-82 (schema)MCP tool registration/input schema for read_multiple_files: defines the 'paths' array parameter as required, with items of type string.
{ name:'read_multiple_files', description:'Read multiple files', inputSchema:{ type:'object', properties:{ paths:{ type:'array', items:{type:'string'} } }, required:['paths'] } }, - src/mcp/server.js:209-211 (registration)Handler registration/case branch in the MCP server that dispatches the 'read_multiple_files' tool call to filesystemTools.readMultipleFiles(args.paths, allowedDirectories).
case 'read_multiple_files': data = filesystemTools.readMultipleFiles(args.paths, allowedDirectories); break; - src/filesystem_tools.js:740-742 (helper)Module exports for readMultipleFiles (exported alongside other filesystem tools).
module.exports = { readFile, readMultipleFiles,