Skip to main content
Glama

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
NameRequiredDescriptionDefault
idYesThe ID of the category

Implementation Reference

  • 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 }, } },
  • 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", },
  • 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(), })
  • 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) }

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