@tomaspavlin/rohlik-mcp
Version:
MCP server for controlling Rohlik.cz grocery shopping website
54 lines (53 loc) • 1.95 kB
JavaScript
import { z } from "zod";
export function createShoppingListsTool(createRohlikAPI) {
return {
name: "get_shopping_list",
definition: {
title: "Get Shopping List",
description: "Get a shopping list by ID",
inputSchema: {
shopping_list_id: z.string().min(1, "Shopping list ID is required").describe("The ID of the shopping list to retrieve")
}
},
handler: async ({ shopping_list_id }) => {
try {
const api = createRohlikAPI();
const shoppingList = await api.getShoppingList(shopping_list_id);
if (!shoppingList.products || shoppingList.products.length === 0) {
return {
content: [
{
type: "text",
text: `Shopping list "${shoppingList.name}" is empty.`
}
]
};
}
const output = `Shopping List: ${shoppingList.name}
Total products: ${shoppingList.products.length}
Products:
${shoppingList.products.map((product, index) => `${index + 1}. ${product.name || 'Unknown product'}`).join('\n')}`;
return {
content: [
{
type: "text",
text: output
}
]
};
}
catch (error) {
return {
content: [
{
type: "text",
text: error instanceof Error ? error.message : String(error)
}
],
isError: true
};
}
}
};
}
//# sourceMappingURL=shopping-lists.js.map