updateCategory
Modify existing categories by updating their names or other properties using the category ID. This tool helps maintain organized memo structures in the memo-mcp server.
Instructions
Update a category
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the category | |
| name | No |
Implementation Reference
- src/repository/categories.ts:34-58 (handler)Core handler function implementing the logic to update a category by ID: finds the category in the database, updates the name if provided, sets updatedAt, writes to DB, returns the updated category or undefined if not found.export const updateCategory = async ( id: string, { name }: UpdateCategory, ): Promise<Category | undefined> => { await db.read() const index = db.data.categories.findIndex((c) => c.id === id) if (index === -1) { return undefined } const existingCategory = db.data.categories[index] if (!existingCategory) { return undefined } const newCategory: Category = { ...existingCategory, ...(name ? { name } : {}), updatedAt: new Date().toISOString(), } db.data.categories[index] = newCategory await db.write() return newCategory }
- src/schemas/categories.ts:18-22 (schema)Zod schema definition for UpdateCategory input (optional name field) and corresponding TypeScript type.export const UpdateCategorySchema = z.object({ name: z.string().min(1).optional(), }) export type UpdateCategory = z.infer<typeof UpdateCategorySchema>
- src/server/tools.ts:219-244 (registration)MCP tool registration for "updateCategory": defines input schema (id + UpdateCategory fields), output schema, description, and the handler function that calls the repository updateCategory and formats the response.server.registerTool( "updateCategory", { description: "Update a category", inputSchema: { id: z.string().describe("The ID of the category"), ...UpdateCategorySchema.shape, }, outputSchema: { category: CategorySchema }, title: "Update Category", }, async ({ id, ...category }) => { const updatedCategory = await updateCategory(id, category) if (!updatedCategory) { return { content: [{ text: "Category not found", type: "text" }], isError: true, } } return { content: [{ text: JSON.stringify(updatedCategory), type: "text" }], structuredContent: { category: updatedCategory }, } }, )