UNPKG

@opra-app/mcp

Version:

MCP server for OPRA's business and discount data

27 lines (26 loc) 905 B
import { z } from "zod"; import { listDiscountsInCategory } from "../api.js"; export const registerListDiscountsInCategoryTool = (server) => { server.tool("list-discounts-in-category", "Lists all discounts in a category", { categoryId: z .string() .describe("The ID of the category to list discounts for"), }, async ({ categoryId }) => { try { const discounts = await listDiscountsInCategory(categoryId); return { content: [{ type: "text", text: JSON.stringify(discounts) }], }; } catch (error) { return { content: [ { type: "text", text: `Failed to retrieve discounts in category with id ${categoryId}: ${error}`, }, ], }; } }); };