get_daily_note
Retrieve today's daily note or access notes for specific dates in your Obsidian vault. Use this tool to quickly find and open dated notes by providing a date in YYYY-MM-DD format.
Instructions
Get today's daily note or a specific date's daily note
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Date in YYYY-MM-DD format (defaults to today) |
Implementation Reference
- src/tools/read.ts:163-230 (handler)Implementation and registration of the 'get_daily_note' tool, which constructs the daily note path based on configuration and retrieves its content.
server.registerTool( "get_daily_note", { description: "Get today's daily note or a specific date's daily note", inputSchema: { date: z .string() .optional() .describe( "Date in YYYY-MM-DD format (defaults to today)", ), }, }, async ({ date }) => { try { const config = getDailyNoteConfig(vaultPath); const targetDate = date ?? new Date().toISOString().slice(0, 10); // Build the filename from the configured format // Replace common date tokens with actual date parts const [year, month, day] = targetDate.split("-"); let filename = config.format .replace("YYYY", year) .replace("MM", month) .replace("DD", day); if (!filename.endsWith(".md")) { filename += ".md"; } const notePath = config.folder ? `${config.folder}/${filename}` : filename; let content: string; try { content = await readNote(vaultPath, notePath); } catch { return errorResult(`Daily note not found for ${targetDate} (expected at "${notePath}")`); } const { data: dailyFrontmatter, content: dailyBody } = parseFrontmatter(content); const header: string[] = [ `Daily Note: ${targetDate}`, `Path: ${notePath}`, "", ]; if (Object.keys(dailyFrontmatter).length > 0) { header.push("--- Frontmatter ---"); for (const [key, value] of Object.entries(dailyFrontmatter)) { header.push(`${key}: ${JSON.stringify(value)}`); } header.push("--- End Frontmatter ---"); header.push(""); } return { content: [ { type: "text" as const, text: header.join("\n") + dailyBody }, ], }; } catch (err) { console.error("get_daily_note error:", err); return errorResult(`Error reading daily note: ${err instanceof Error ? err.message : String(err)}`); } }, );