getCategories
Retrieve all categories from the memo-mcp server to efficiently organize and access stored memos using the LowDB database.
Instructions
Get all categories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server/tools.ts:184-190 (handler)The MCP tool handler function for getCategories, which calls the repository getCategories and formats the response with content and structuredContent.async () => { const categories = await getCategories() return { content: [{ text: JSON.stringify(categories), type: "text" }], structuredContent: { categories }, } },
- src/schemas/categories.ts:3-8 (schema)Zod schema definition for Category, used in the tool's outputSchema as z.array(CategorySchema). Input schema is empty object.export const CategorySchema = z.object({ createdAt: z.string().datetime(), id: z.string(), name: z.string().min(1), updatedAt: z.string().datetime(), })
- src/server/tools.ts:176-191 (registration)Registers the getCategories tool with the MCP server, including description, schemas, title, and handler function.server.registerTool( "getCategories", { description: "Get all categories", inputSchema: {}, outputSchema: { categories: z.array(CategorySchema) }, title: "Get Categories", }, async () => { const categories = await getCategories() return { content: [{ text: JSON.stringify(categories), type: "text" }], structuredContent: { categories }, } }, )
- src/repository/categories.ts:22-25 (helper)Repository helper function that reads the database and returns all categories, called by the tool handler.export const getCategories = async (): Promise<Category[]> => { await db.read() return db.data.categories }