getCategory
Retrieve a specific category from the memo-mcp server by providing its unique ID, enabling organized access to stored memo categories.
Instructions
Get a single category by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the category |
Implementation Reference
- src/server/tools.ts:203-216 (handler)The MCP tool handler for 'getCategory'. Fetches the category by ID from the repository, handles 'not found' case with error response, and returns formatted text content and structured category data.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/server/tools.ts:193-202 (registration)Registers the 'getCategory' MCP tool, providing description, input schema (id: string), output schema referencing CategorySchema, and title.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", },
- src/schemas/categories.ts:3-8 (schema)Zod schema definition for Category type, used in tool outputSchema and throughout the codebase for validation and typing.export const CategorySchema = z.object({ createdAt: z.string().datetime(), id: z.string(), name: z.string().min(1), updatedAt: z.string().datetime(), })
- src/repository/categories.ts:27-32 (helper)Repository helper function that reads the database and finds a category by its ID.export const getCategory = async ( id: string, ): Promise<Category | undefined> => { await db.read() return db.data.categories.find((c) => c.id === id) }