Skip to main content
Glama
108yen
by 108yen

deleteCategory

Remove a category from the memo-mcp server by specifying its ID to organize your memo database.

Instructions

Delete a category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the category

Implementation Reference

  • Core handler function for deleting a category by ID. Removes the category from the database, clears the categoryId from associated memos, and persists changes.
    export const deleteCategory = async (
      id: string,
    ): Promise<Category | undefined> => {
      await db.read()
      const index = db.data.categories.findIndex((c) => c.id === id)
      if (index === -1) {
        return undefined
      }
    
      const deletedCategory = db.data.categories.splice(index, 1)[0]
      db.data.memos.forEach((memo) => {
        if (memo.categoryId === id) {
          memo.categoryId = undefined
        }
      })
      await db.write()
    
      return deletedCategory
    }
  • Registers the 'deleteCategory' tool on the MCP server, defining its schema, description, and handler that wraps the repository function.
    server.registerTool(
      "deleteCategory",
      {
        description: "Delete a category",
        inputSchema: {
          id: z.string().describe("The ID of the category"),
        },
        outputSchema: { category: CategorySchema },
        title: "Delete Category",
      },
      async ({ id }) => {
        const deletedCategory = await deleteCategory(id)
        if (!deletedCategory) {
          return {
            content: [{ text: "Category not found", type: "text" }],
            isError: true,
          }
        }
    
        return {
          content: [{ text: JSON.stringify(deletedCategory), type: "text" }],
          structuredContent: { category: deletedCategory },
        }
      },
    )
  • Zod schema for Category type, used in the outputSchema of deleteCategory tool.
    export const CategorySchema = z.object({
      createdAt: z.string().datetime(),
      id: z.string(),
      name: z.string().min(1),
      updatedAt: z.string().datetime(),
    })

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