Skip to main content
Glama

createCategory

Generate and manage new categories for organizing memos in the memo-mcp server. Specify a category name to streamline storage and retrieval.

Instructions

Create a new category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • The handler function for the 'createCategory' MCP tool. It invokes the repository function and formats the response with content and structuredContent.
    async (category) => { const newCategory = await createCategory(category) return { content: [{ text: JSON.stringify(newCategory), type: "text" }], structuredContent: { category: newCategory }, }
  • Zod schema defining the input structure for creating a category (name field).
    export const CreateCategorySchema = z.object({ name: z.string().min(1), }) export type CreateCategory = z.infer<typeof CreateCategorySchema>
  • Registers the 'createCategory' tool with the MCP server, specifying input/output schemas, description, title, and the handler function.
    server.registerTool( "createCategory", { description: "Create a new category", inputSchema: CreateCategorySchema.shape, outputSchema: { category: CategorySchema }, title: "Create Category", }, async (category) => { const newCategory = await createCategory(category) return { content: [{ text: JSON.stringify(newCategory), type: "text" }], structuredContent: { category: newCategory }, } },
  • Repository helper function that creates a new category object with timestamps and ID, persists it to the database, and returns it.
    export const createCategory = async ( category: CreateCategory, ): Promise<Category> => { const now = new Date().toISOString() const newCategory: Category = { ...category, createdAt: now, id: nanoid(), updatedAt: now, } db.data.categories.push(newCategory) await db.write() return newCategory }
  • Zod schema defining the full category structure used for output validation.
    export const CategorySchema = z.object({ createdAt: z.string().datetime(), id: z.string(), name: z.string().min(1), updatedAt: z.string().datetime(), }) export type Category = z.infer<typeof CategorySchema>

Other Tools

Related 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