UNPKG

@opra-app/mcp

Version:

MCP server for OPRA's business and discount data

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