read_multiple_notes
Retrieve content from multiple Obsidian notes at once to efficiently access and compare information across your knowledge base.
Instructions
Read content from multiple notes simultaneously
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | Yes | Array of note paths to read |
Implementation Reference
- src/index.ts:1669-1698 (handler)Main handler function for the 'read_multiple_notes' tool. Reads contents of multiple notes in parallel using Promise.all and this.readNote, concatenates results with note paths and separators, handles errors per note.private async handleReadMultipleNotes(args: any) { if (!args?.paths) { throw new Error('Paths are required'); } if (!Array.isArray(args.paths)) { throw new Error('Paths must be an array'); } const results = await Promise.all( args.paths.map(async (notePath: string) => { try { const content = await this.readNote(notePath); return `${notePath}:\n${content}\n`; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return `${notePath}: Error - ${errorMessage}`; } }) ); return { content: [ { type: 'text', text: results.join('\n---\n'), }, ], }; }
- src/index.ts:1293-1308 (schema)Input schema definition for the read_multiple_notes tool, defining the expected input as an object with a required 'paths' array of strings.name: 'read_multiple_notes', description: 'Read content from multiple notes simultaneously', inputSchema: { type: 'object', properties: { paths: { type: 'array', description: 'Array of note paths to read', items: { type: 'string' } } }, required: ['paths'], }, },
- src/index.ts:1405-1406 (registration)Registration of the tool handler in the CallToolRequestSchema switch statement, mapping the tool name to its handler function.return await this.handleReadMultipleNotes(request.params.arguments); case 'auto_backlink_vault':
- src/index.ts:2202-2219 (helper)Helper method used by the handler to read a single note's content, preferring Obsidian API and falling back to filesystem.try { // First try using the Obsidian API const response = await this.api.get(`/vault/${encodeURIComponent(notePath)}`); // API returns the content directly, not wrapped in {content: ...} return response.data || ''; } catch (error) { console.warn('API request failed, falling back to file system:', error); // Fallback to file system if API fails const fullPath = path.join(VAULT_PATH, notePath); if (fs.existsSync(fullPath)) { return fs.readFileSync(fullPath, 'utf-8'); } else { return ''; } } }