create_note
Create a new note in NotePlan with a title, content, and optional folder location to organize your thoughts and information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | The title of the note | |
| content | No | The content of the note | |
| folder | No | The folder to create the note in |
Implementation Reference
- src/services/noteService.ts:301-365 (handler)Core implementation of note creation logic: sanitizes title for filename, writes Markdown file to NotePlan directory (or mock DB), parses and returns the new note object.function createNote(noteData: CreateNoteParams): Note { if (!noteData.title) { throw new Error('Note title is required'); } const now = new Date(); const timestamp = now.toISOString(); // Generate filename from title (sanitize for filesystem) const sanitizedTitle = noteData.title .replace(/[^a-zA-Z0-9\s-_]/g, '') .replace(/\s+/g, '-') .substring(0, 50); const filename = `${sanitizedTitle}-${Date.now()}`; const noteId = `note-${filename}`; // Prepare content with title as markdown header const content = noteData.content ? `# ${noteData.title}\n\n${noteData.content}` : `# ${noteData.title}\n\n`; if (isNotePlanAvailable()) { // Determine target directory const targetFolder = noteData.folder || 'Notes'; let targetPath = NOTES_PATH; if (targetFolder !== 'Notes' && targetFolder !== 'Calendar') { targetPath = path.join(NOTES_PATH, targetFolder); // Create subfolder if it doesn't exist if (!fs.existsSync(targetPath)) { fs.mkdirSync(targetPath, { recursive: true }); } } const filePath = path.join(targetPath, `${filename}.md`); try { fs.writeFileSync(filePath, content, 'utf8'); // Clear cache to force refresh notesCache = []; lastCacheUpdate = 0; // Return the newly created note return parseMarkdownFile(filePath, targetFolder)!; } catch (error) { throw new Error(`Failed to create note: ${(error as Error).message}`); } } else { // Fallback to mock database const newNote: Note = { id: noteId, title: noteData.title, content, created: timestamp, modified: timestamp, folder: noteData.folder || 'Notes' }; notesDb.push(newNote); return newNote; } }
- src/services/noteService.ts:21-25 (schema)TypeScript interface defining the input parameters for the createNote function.interface CreateNoteParams { title: string; content?: string; folder?: string; }
- src/index.ts:92-110 (registration)MCP tool registration for 'create_note': defines Zod input schema matching CreateNoteParams and thin handler wrapper that calls noteService.createNote and returns JSON stringified response.server.tool( 'create_note', { title: z.string().describe('The title of the note'), content: z.string().optional().describe('The content of the note'), folder: z.string().optional().describe('The folder to create the note in'), }, async ({ title, content, folder }) => { const newNote = noteService.createNote({ title, content, folder }); return { content: [ { type: 'text', text: JSON.stringify(newNote, null, 2), }, ], }; } );