Skip to main content
Glama

createCategory

Organize memos by creating new categories to group related information for easier retrieval and management.

Instructions

Create a new category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • MCP tool handler function for 'createCategory' that calls the repository function and formats the MCP response.
    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 the createCategory tool.
    export const CreateCategorySchema = z.object({ name: z.string().min(1), }) export type CreateCategory = z.infer<typeof CreateCategorySchema>
  • Registration of the 'createCategory' tool with the MCP server, specifying schema, description, and handler.
    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 function that performs the actual category creation logic using the database.
    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 }

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