Skip to main content
Glama

getCategory

Retrieve a specific category using its unique ID from the memo-mcp server, ensuring accurate and targeted data retrieval for memo management.

Instructions

Get a single category by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the category

Implementation Reference

  • The handler function that implements the core logic of the 'getCategory' MCP tool: fetches the category by ID from the repository, handles missing category with error response, and returns formatted content with structured 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' tool on the MCP server, defining its name, description, input schema (id: string), output schema referencing CategorySchema, title, and references the handler 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 }, } }, )
  • Zod schema defining the structure of a Category object, used in the output schema of the getCategory tool.
    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/retrieves 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) }

Other Tools

Related Tools

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