deleteMemo
Remove a specific memo by its ID from the memo-mcp server, which supports recording, searching, and retrieving memos using a LowDB local database.
Instructions
Delete a memo
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the memo |
Implementation Reference
- src/server/tools.ts:126-139 (handler)The MCP tool handler for 'deleteMemo'. It calls the repository's deleteMemo function, handles the case where the memo is not found, and returns structured content with the deleted memo or an error.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/server/tools.ts:116-139 (registration)Registration of the 'deleteMemo' MCP tool, including input/output schemas and the handler function.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/server/tools.ts:118-125 (schema)Inline schema definition for the deleteMemo tool's input (id: string) and output (memo: MemoSchema).{ description: "Delete a memo", inputSchema: { id: z.string().describe("The ID of the memo"), }, outputSchema: { memo: MemoSchema }, title: "Delete Memo", },
- src/repository/memos.ts:51-62 (helper)Repository helper function that performs the actual deletion: reads DB, finds and removes the memo by ID, writes DB, returns the deleted memo.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 }