createNote
Create and store notes with structured title and content using the MCP server. Manage note-taking operations efficiently with JSON-based CRUD functionality.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The content of the note | |
| title | Yes | The title of the note |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"content": {
"description": "The content of the note",
"type": "string"
},
"title": {
"description": "The title of the note",
"type": "string"
}
},
"required": [
"title",
"content"
],
"type": "object"
}
Implementation Reference
- src/server.ts:107-135 (handler)The main handler function for the MCP 'createNote' tool. It invokes notesStore.createNote and returns a standardized JSON response with success/error status.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)Zod input schema defining required string parameters 'title' and 'content' for the createNote tool.{ title: z.string().describe("The title of the note"), content: z.string().describe("The content of the note") },
- src/server.ts:101-136 (registration)Full registration of the 'createNote' MCP tool using server.tool(), including name, input schema, and inline 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 generates a unique ID, creates a new Note object, stores it in memory, and returns it. Called by the MCP handler.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; }
- src/notes-store.ts:2-7 (schema)TypeScript interface defining the structure of a Note object returned by createNote.export interface Note { id: string; title: string; content: string; createdAt: string; }