@opra-app/mcp
Version:
MCP server for OPRA's business and discount data
25 lines (24 loc) • 827 B
JavaScript
import { z } from "zod";
import { getDiscountsByCity } from "../api.js";
export const registerGetDiscountsInCityTool = (server) => {
server.tool("get-discount-by-city", "Gets all local discounts by city ID", {
cityId: z.string().describe("The ID of the city to get discounts for"),
}, async ({ cityId }) => {
try {
const discounts = await getDiscountsByCity(cityId);
return {
content: [{ type: "text", text: JSON.stringify(discounts) }],
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Failed to retrieve discounts in city ${cityId}: ${error}`,
},
],
};
}
});
};