create_daily_note
Create a daily note in NotePlan with specified date and initial content to organize daily tasks and thoughts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | The date for the daily note (YYYY-MM-DD format) | |
| content | No | Initial content for the daily note |
Implementation Reference
- src/services/noteService.ts:239-296 (handler)The core handler function that implements the logic for creating a daily note. It generates a filename based on the date, checks for existence, uses a default template if no content provided, writes to the NotePlan Calendar directory or falls back to mock database, and returns the created note object.function createDailyNote(options: CreateDailyNoteParams = {}): Note { const noteDate = options.date ? new Date(options.date) : new Date(); const dateStr = noteDate.toISOString().split('T')[0].replace(/-/g, ''); // YYYYMMDD format const noteId = `calendar-${dateStr}`; // Check if daily note already exists const existingNote = getNoteById(noteId); if (existingNote) { throw new Error(`Daily note for ${dateStr} already exists`); } const defaultTemplate = `# ${dateStr} ## Today's Plan - [ ] ## Notes ## Reflection --- Created: ${noteDate.toISOString()}`; const content = options.content || defaultTemplate; if (isNotePlanAvailable()) { // Write to actual NotePlan directory const filePath = path.join(CALENDAR_PATH, `${dateStr}.md`); try { fs.writeFileSync(filePath, content, 'utf8'); // Clear cache to force refresh notesCache = []; lastCacheUpdate = 0; // Return the newly created note return parseMarkdownFile(filePath, 'Calendar')!; } catch (error) { throw new Error(`Failed to create daily note: ${(error as Error).message}`); } } else { // Fallback to mock database const newNote: Note = { id: noteId, title: `Daily Note - ${dateStr}`, content, created: noteDate.toISOString(), modified: noteDate.toISOString(), folder: 'Calendar', type: 'daily' }; notesDb.push(newNote); return newNote; } }
- src/services/noteService.ts:27-30 (schema)TypeScript interface defining the input parameters for the createDailyNote function: optional date (string) and content (string).interface CreateDailyNoteParams { date?: string; content?: string; }
- src/index.ts:113-130 (registration)MCP tool registration for 'create_daily_note', including Zod input schema validation and a thin handler that delegates to noteService.createDailyNote and formats the response.server.tool( 'create_daily_note', { date: z.string().optional().describe('The date for the daily note (YYYY-MM-DD format)'), content: z.string().optional().describe('Initial content for the daily note'), }, async ({ date, content }) => { const dailyNote = noteService.createDailyNote({ date, content }); return { content: [ { type: 'text', text: JSON.stringify(dailyNote, null, 2), }, ], }; } );
- src/services/noteService.ts:437-444 (helper)Export of the noteService object, making createDailyNote available for import and use in the MCP server.export const noteService = { getAllNotes, getNoteById, searchNotes, getNotesByFolder, createDailyNote, createNote, updateNote