Get Category
getCategoryRetrieve a specific category by its ID. Use this to access category details stored in the memo system.
Instructions
Get a single category by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the category |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes |
Implementation Reference
- src/repository/categories.ts:27-32 (handler)Core handler function for getCategory. Looks up a category in the database by its ID using db.data.categories.find(). Returns the Category or undefined if not found.
export const getCategory = async ( id: string, ): Promise<Category | undefined> => { await db.read() return db.data.categories.find((c) => c.id === id) } - src/server/tools.ts:193-217 (registration)Registration of the 'getCategory' tool in the MCP server via server.registerTool(). Defines description, inputSchema (id: string), outputSchema (CategorySchema), and the callback handler that calls the repository function.
server.registerTool( "getCategory", { description: "Get a single category by ID", inputSchema: { id: z.string().describe("The ID of the category"), }, outputSchema: { category: CategorySchema }, title: "Get Category", }, async ({ id }) => { const category = await getCategory(id) if (!category) { return { content: [{ text: "Category not found", type: "text" }], isError: true, } } return { content: [{ text: JSON.stringify(category), type: "text" }], structuredContent: { category }, } }, ) - src/schemas/categories.ts:3-8 (schema)CategorySchema definition used for output validation of the getCategory tool. Defines the shape of a Category object with fields: id, name, createdAt, updatedAt.
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:7-9 (helper)Import of the getCategory handler from the repository layer into the tools registration file.
getCategory, updateCategory, } from "../repository/categories"