UNPKG

@opra-app/mcp

Version:

MCP server for OPRA's business and discount data

25 lines (24 loc) 842 B
import { z } from "zod"; import { getDiscountDetails } from "../api.js"; export const registerGetDiscountOrCampaignDetailsTool = (server) => { server.tool("get-discount-or-campaign-details", "Gets a discount or campaign by ID", { id: z.string().describe("The ID of the discount or campaign to get"), }, async ({ id }) => { try { const discount = await getDiscountDetails(id); return { content: [{ type: "text", text: JSON.stringify(discount) }], }; } catch (error) { return { content: [ { type: "text", text: `Failed to retrieve discount or campaign with ID ${id}: ${error}`, }, ], }; } }); };