createNote
Create and store notes with titles and content using a TypeScript MCP server for note-taking operations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | The title of the note | |
| content | Yes | The content of the note |
Implementation Reference
- src/server.ts:107-136 (handler)The handler function for the 'createNote' MCP tool. It takes title and content, calls notesStore.createNote, and returns a JSON response with the new note or an error.async ({ title, content }) => { try { const newNote = notesStore.createNote(title, content); return { content: [ { type: "text", text: JSON.stringify({ success: true, note: newNote }, null, 2) } ] }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Failed to create note" }, null, 2) } ] }; } }, );
- src/server.ts:103-106 (schema)Input schema for the createNote tool using Zod, defining required string parameters for title and content.{ title: z.string().describe("The title of the note"), content: z.string().describe("The content of the note") },
- src/server.ts:101-136 (registration)Registration of the 'createNote' tool on the MCP server, including name, input schema, and handler function.server.tool( "createNote", { title: z.string().describe("The title of the note"), content: z.string().describe("The content of the note") }, async ({ title, content }) => { try { const newNote = notesStore.createNote(title, content); return { content: [ { type: "text", text: JSON.stringify({ success: true, note: newNote }, null, 2) } ] }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Failed to create note" }, null, 2) } ] }; } }, );
- src/notes-store.ts:38-49 (helper)Helper method in NotesStore class that creates a new Note object with generated ID and stores it in memory.createNote(title: string, content: string): Note { const id = `note${Date.now()}`; const newNote = { id, title, content, createdAt: new Date().toISOString() }; this.notes[id] = newNote; return newNote; }