create_daily_note
Create a daily note in Obsidian for today or a specified date, with optional content and templates to organize your thoughts and tasks.
Instructions
Create today's daily note or a note for a specific date
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Date in YYYY-MM-DD format (defaults to today) | |
| content | No | Initial content for the daily note | |
| templatePath | No | Path to a template note to use (replaces {{date}} placeholder) |
Implementation Reference
- src/tools/write.ts:186-238 (handler)Implementation and registration of the create_daily_note tool.
// 5. create_daily_note server.registerTool( "create_daily_note", { description: "Create today's daily note or a note for a specific date", inputSchema: { date: z .string() .optional() .describe("Date in YYYY-MM-DD format (defaults to today)"), content: z.string().optional().describe("Initial content for the daily note"), templatePath: z .string() .optional() .describe("Path to a template note to use (replaces {{date}} placeholder)"), }, }, async ({ date, content, templatePath }) => { try { const config = getDailyNoteConfig(vaultPath); const targetDate = date ? new Date(date + "T00:00:00") : new Date(); if (isNaN(targetDate.getTime())) { return errorResult("Error: Invalid date format. Use YYYY-MM-DD."); } const dateStr = formatDate(targetDate, config.format); const folder = config.folder ? `${config.folder}/` : ""; const notePath = `${folder}${dateStr}.md`; if (await noteExists(vaultPath, notePath)) { return errorResult(`Error: Daily note already exists at '${notePath}'.`); } let finalContent = content ?? ""; if (templatePath) { try { const templateContent = await readNote(vaultPath, templatePath); finalContent = templateContent.replace(/\{\{date\}\}/g, dateStr); } catch (err) { return errorResult(`Error reading template: ${err instanceof Error ? err.message : String(err)}`); } } await writeNote(vaultPath, notePath, finalContent); return textResult(`Created daily note at '${notePath}'.`); } catch (err) { console.error("create_daily_note error:", err); return errorResult(`Error creating daily note: ${err instanceof Error ? err.message : String(err)}`); } }, );