read_multiple_files
Read and analyze multiple files simultaneously within Obsidian iCloud MCP, returning each file's content with its path. Designed for efficient file comparison and analysis, it handles failed reads for individual files without stopping the operation.
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. Only works within allowed directories.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | Yes |
Implementation Reference
- src/file-system.ts:218-235 (handler)The handler function for 'read_multiple_files' tool. Parses input arguments using the schema, reads contents of multiple files asynchronously, formats each with path and content, joins them with '---' separator, and returns as a single text content block.export async function readMultipleFiles(args?: Record<string, unknown>) { const parsed = ReadMultipleFilesArgsSchema.safeParse(args) if (!parsed.success) { throw new Error( `Invalid arguments for read_multiple_files: ${parsed.error}` ) } const results = await Promise.all( parsed.data.paths.map(async (filePath: string) => { const content = await fs.readFile(filePath, 'utf-8') return `${filePath}:\n${content}\n` }) ) return { content: [{ type: 'text', text: results.join('\n---\n') }] } }
- src/schemas.ts:8-10 (schema)Zod schema defining input for read_multiple_files: an object with 'paths' array of strings.export const ReadMultipleFilesArgsSchema = z.object({ paths: z.array(z.string()) })
- src/index.ts:106-108 (registration)Registration of the 'read_multiple_files' tool in the ListToolsRequestHandler, specifying name, description from prompt, and input schema converted to JSON schema.name: 'read_multiple_files', description: readMultipleFilesPrompt(), inputSchema: zodToJsonSchema(ReadMultipleFilesArgsSchema) as ToolInput
- src/index.ts:175-177 (registration)Dispatch in CallToolRequestHandler switch statement that invokes the readMultipleFiles handler when the tool name matches.case 'read_multiple_files': { return readMultipleFiles(args) }
- src/prompts.ts:8-13 (helper)Prompt string used as the tool description, explaining the purpose and usage of read_multiple_files.export const readMultipleFilesPrompt = () => '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. Only works within allowed directories.'