UNPKG

@opra-app/mcp

Version:

MCP server for OPRA's business and discount data

27 lines (26 loc) 873 B
import { z } from "zod"; import { getDiscountCode } from "../api.js"; export const registerGetDiscountCodeTool = (server) => { server.tool("get-discount-code", "Gets a discount code for a given discount by its ID", { id: z .string() .describe("The ID of the discount to get a discount code for"), }, async ({ id }) => { try { const discountCode = await getDiscountCode(id); return { content: [{ type: "text", text: JSON.stringify(discountCode) }], }; } catch (error) { return { content: [ { type: "text", text: `Failed to retrieve discount code for discountwith ID ${id}: ${error}`, }, ], }; } }); };