Skip to main content
Glama

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
NameRequiredDescriptionDefault
idYesThe ID of the category
nameNo

Implementation Reference

  • 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 }
  • 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>
  • 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 }, } }, )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/108yen/memo-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server