deleteNote
Remove a specific note by its ID from the Simple TypeScript MCP Server, enabling efficient management of note data within the system.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| noteId | Yes | The ID of the note to delete |
Implementation Reference
- src/server.ts:199-244 (handler)MCP tool handler that executes the deleteNote logic by calling notesStore.deleteNote and returning formatted JSON response.async ({ noteId }) => { try { const deleted = notesStore.deleteNote(noteId); if (!deleted) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Note not found", noteId }, null, 2) } ] }; } return { content: [ { type: "text", text: JSON.stringify({ success: true, message: "Note deleted successfully", noteId }, null, 2) } ] }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Failed to delete note", noteId }, null, 2) } ] }; } },
- src/server.ts:196-198 (schema)Input schema validation using Zod for the noteId parameter.{ noteId: z.string().describe("The ID of the note to delete") },
- src/server.ts:194-245 (registration)Registration of the deleteNote tool with the MCP server, including name, schema, and handler.server.tool( "deleteNote", { noteId: z.string().describe("The ID of the note to delete") }, async ({ noteId }) => { try { const deleted = notesStore.deleteNote(noteId); if (!deleted) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Note not found", noteId }, null, 2) } ] }; } return { content: [ { type: "text", text: JSON.stringify({ success: true, message: "Note deleted successfully", noteId }, null, 2) } ] }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: "Failed to delete note", noteId }, null, 2) } ] }; } }, );
- src/notes-store.ts:69-78 (helper)Core helper method in NotesStore class that deletes a note by ID from the in-memory store.deleteNote(id: string): boolean { const note = this.notes[id]; if (!note) { return false; } delete this.notes[id]; return true; }