updateMemo
Modify existing memos by updating their title, content, or category to keep information current and organized.
Instructions
Update a memo
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the memo | |
| categoryId | No | ||
| content | No | ||
| title | No |
Implementation Reference
- src/repository/memos.ts:30-49 (handler)Core implementation of updateMemo: reads DB, finds memo by ID, merges updates, writes back, returns updated memo.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 }
- src/server/tools.ts:89-113 (registration)Registers the 'updateMemo' tool with the MCP server, defines input/output schemas, and provides the tool handler function.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 defining the input shape for updating a memo (optional fields for title, content, categoryId).export const UpdateMemoSchema = z.object({ categoryId: z.string().optional(), content: z.string().optional(), title: z.string().optional(), }) export type UpdateMemo = z.infer<typeof UpdateMemoSchema>