Delete Memo
deleteMemoDelete a memo by ID. Removes the memo from the local database.
Instructions
Delete a memo
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the memo |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memo | Yes |
Implementation Reference
- src/repository/memos.ts:51-62 (handler)The repository function that performs the actual deletion of a memo from the database by its ID. It reads the database, finds the memo by index, splices it out, writes back, and returns the deleted memo (or undefined if not found).
export const deleteMemo = async (id: string) => { await db.read() const index = db.data.memos.findIndex((memo) => memo.id === id) if (index == -1) { return undefined } const [deletedMemo] = db.data.memos.splice(index, 1) await db.write() return deletedMemo } - src/schemas/memos.ts:3-22 (schema)The MemoSchema Zod schema used for output validation of the deleteMemo tool's response (outputSchema: { memo: MemoSchema }).
export const MemoSchema = z.object({ categoryId: z.string().optional(), content: z.string(), createdAt: z .string() .datetime() .transform((date) => new Date(date)) .describe( "The date when the memo was created. Display in ISO 8601 format, UTC+0 timezone.", ), id: z.string(), title: z.string(), updatedAt: z .string() .datetime() .transform((date) => new Date(date)) .describe( "The date when the memo was last updated. Display in ISO 8601 format, UTC+0 timezone.", ), }) - src/server/tools.ts:116-140 (registration)The MCP tool registration for 'deleteMemo', defining its description, inputSchema (id: string), outputSchema, and the handler that calls the repository deleteMemo function and handles the not-found case.
server.registerTool( "deleteMemo", { description: "Delete a memo", inputSchema: { id: z.string().describe("The ID of the memo"), }, outputSchema: { memo: MemoSchema }, title: "Delete Memo", }, async ({ id }) => { const deletedMemo = await deleteMemo(id) if (!deletedMemo) { return { content: [{ text: "Memo not found", type: "text" }], isError: true, } } return { content: [{ text: JSON.stringify(deletedMemo), type: "text" }], structuredContent: { memo: deletedMemo }, } }, ) - src/repository/memos.ts:2-39 (helper)The TypeScript types imported from schemas (CreateMemo, UpdateMemo) used by the repository layer — these are shared across memo operations including deleteMemo.
import type { CreateMemo, SearchMemosParams, UpdateMemo } from "../schemas" import { db } from "../db" export const createMemo = async (memo: CreateMemo) => { const now = new Date().toISOString() const newMemo = { ...memo, createdAt: now, id: nanoid(), updatedAt: now, } db.data.memos.push(newMemo) await db.write() return newMemo } export const getMemos = async () => { await db.read() return db.data.memos } export const getMemo = async (id: string) => { await db.read() return db.data.memos.find((memo) => memo.id === id) } export const updateMemo = async (id: string, memo: UpdateMemo) => { await db.read() const index = db.data.memos.findIndex((memo) => memo.id === id) if (index == -1) { return undefined } const existingMemo = db.data.memos[index]!