@opra-app/mcp
Version:
MCP server for OPRA's business and discount data
26 lines (25 loc) • 987 B
JavaScript
import { z } from "zod";
import { getDiscountDetails } from "../api.js";
export const registerGetDiscountOrCampaignDetailsTool = (server) => {
server.tool("get-discount-or-campaign-details", "Gets full details for a specific discount or campaign by its ID, including description, terms, and business info.", {
id: z.string().describe("The discount or campaign ID from list-discounts or list-campaigns."),
}, async ({ id }) => {
try {
const discount = await getDiscountDetails(id);
return {
content: [{ type: "text", text: JSON.stringify(discount, null, 2) }],
};
}
catch (error) {
return {
isError: true,
content: [
{
type: "text",
text: `Failed to retrieve discount or campaign with ID ${id}: ${error}`,
},
],
};
}
});
};