list_notes
Retrieve notes from your Obsidian vault or specific folders to organize and access your knowledge base efficiently.
Instructions
List all notes in the vault or a specific folder
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder | No | Folder to list notes from (omit for entire vault) | |
| limit | No | Maximum number of notes to return |
Implementation Reference
- src/lib/vault.ts:26-58 (handler)The `listNotes` function scans the vault directory recursively for files ending in `.md` and returns a sorted list of their relative paths, excluding specified directories.
export async function listNotes( vaultPath: string, folder?: string, ): Promise<string[]> { const baseDir = folder ? resolveVaultPath(vaultPath, folder) : path.resolve(vaultPath); let entries: string[]; try { entries = await fs.readdir(baseDir, { recursive: true }) as unknown as string[]; } catch (err) { if ((err as NodeJS.ErrnoException).code === "ENOENT") { return []; } throw err; } const notes: string[] = []; for (const entry of entries) { const normalized = entry.replace(/\\/g, "/"); if (!normalized.endsWith(".md")) continue; const relativeFromVault = folder ? `${folder}/${normalized}`.replace(/\\/g, "/") : normalized; if (isExcluded(relativeFromVault)) continue; notes.push(relativeFromVault); } return notes.sort(); }