read_note
Retrieve content from Obsidian notes by specifying vault and file paths to access stored information directly.
Instructions
Read a note from the vault
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault_path | Yes | Path to the Obsidian vault | |
| note_path | Yes | Path to the note relative to vault root (with or without .md extension) |
Implementation Reference
- src/tools/notes.ts:7-38 (handler)The core handler function for the 'read_note' tool. It validates the vault, reads the note file, parses frontmatter with gray-matter, and returns structured data including content, frontmatter, raw content, and file stats.export async function handleReadNote( vaultManager: VaultManager, vaultPath: string, notePath: string ) { await vaultManager.validateVault(vaultPath); const filePath = vaultManager.getFilePath(vaultPath, notePath); try { const content = await fs.readFile(filePath, 'utf-8'); const parsed = matter(content); const stats = await fs.stat(filePath); return { path: notePath, content: parsed.content, frontmatter: parsed.data, raw: content, stats: { created: stats.birthtime, modified: stats.mtime, size: stats.size, }, }; } catch (error: any) { if (error.code === 'ENOENT') { throw new Error(`Note not found: ${notePath}`); } throw error; } }
- src/index.ts:58-75 (schema)Tool registration entry including name, description, and input schema definition for 'read_note' used in list_tools response.{ name: 'read_note', description: 'Read a note from the vault', inputSchema: { type: 'object', properties: { vault_path: { type: 'string', description: 'Path to the Obsidian vault', }, note_path: { type: 'string', description: 'Path to the note relative to vault root (with or without .md extension)', }, }, required: ['vault_path', 'note_path'], }, },
- src/index.ts:183-188 (registration)Dispatch logic in the CallToolRequestSchema handler that routes 'read_note' calls to the handleReadNote function with input validation.case 'read_note': if (!args || typeof args !== 'object' || !('vault_path' in args) || !('note_path' in args)) { throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters'); } result = await handleReadNote(vaultManager, args.vault_path as string, args.note_path as string); break;