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