Skip to main content
Glama
108yen
by 108yen

Update Category

updateCategory

Update an existing category by its ID, with an optional new name.

Instructions

Update a category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the category
nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYes

Implementation Reference

  • The main handler/repository function that updates a category by ID. Reads the DB, finds the category by index, merges the new name (if provided), updates the timestamp, writes to DB, and returns the updated category.
    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
  • The tool handler registered with the MCP server. Receives the id and category fields, calls the repository updateCategory function, and returns success or error content.
    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 },
        }
      },
    )
  • Zod schema defining the input for updateCategory: an optional name field (string, min length 1).
    export const UpdateCategorySchema = z.object({
      name: z.string().min(1).optional(),
    })
    
    export type UpdateCategory = z.infer<typeof UpdateCategorySchema>
  • TypeScript type inferred from the UpdateCategorySchema.
    export type UpdateCategory = z.infer<typeof UpdateCategorySchema>
  • Registration of the 'updateCategory' tool on the MCP server via server.registerTool(), including description, input/output schemas, and the handler callback.
    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 },
        }
      },
    )
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose any behavioral traits. It fails to state whether the tool performs partial or full updates, what happens if the ID does not exist, or any validation rules for the name field.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely short (three words), but it is under-specified rather than concise. It omits critical information that an AI agent would need to use the tool effectively.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has two parameters and an output schema, the description is completely inadequate. It does not cover update behavior, error states, or return values, leaving the agent with insufficient information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is only 50% (only 'id' has a description). The tool description does not add any semantic meaning beyond the parameter names. It does not clarify that 'name' is optional or what constraints apply (e.g., uniqueness, format).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Update a category' is a tautology that restates the tool's name and title. It does not specify what attributes of a category can be updated (e.g., name) or provide any context that distinguishes it from sibling tools like createCategory or getCategory.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidelines are provided regarding when to use this tool versus alternatives. There is no mention of prerequisites, when not to use it, or how it differs from other category management tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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