updateMemo
Modify existing memos by updating their ID, category, content, or title to ensure accurate and organized information retrieval within the memo-mcp server.
Instructions
Update a memo
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| categoryId | No | ||
| content | No | ||
| id | Yes | The ID of the memo | |
| title | No |
Implementation Reference
- src/server/tools.ts:89-113 (handler)Registration and handler implementation for the 'updateMemo' MCP tool. Defines input/output schemas inline (referencing UpdateMemoSchema), handles input destructuring, calls the repository updateMemo function, manages errors, and returns content in MCP format.server.registerTool( "updateMemo", { description: "Update a memo", inputSchema: { id: z.string().describe("The ID of the memo"), ...UpdateMemoSchema.shape, }, outputSchema: { memo: MemoSchema }, title: "Update Memo", }, async ({ id, ...memo }) => { const updatedMemo = await updateMemo(id, memo) if (!updatedMemo) { return { content: [{ text: "Memo not found", type: "text" }], isError: true, } } return { content: [{ text: JSON.stringify(updatedMemo), type: "text" }], structuredContent: { memo: updatedMemo }, } },
- src/schemas/memos.ts:34-40 (schema)Zod schema and TypeScript type definition for the UpdateMemo input object used in the updateMemo tool.export const UpdateMemoSchema = z.object({ categoryId: z.string().optional(), content: z.string().optional(), title: z.string().optional(), }) export type UpdateMemo = z.infer<typeof UpdateMemoSchema>
- src/repository/memos.ts:30-49 (helper)Repository helper function that performs the actual database update for a memo by ID, merging updates, updating timestamp, and persisting to storage.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]! const newMemo = { ...existingMemo, ...memo, updatedAt: new Date().toISOString(), } db.data.memos[index] = newMemo await db.write() return newMemo }