lookup_product
Retrieve product details including name, brand, quantity, and image by scanning or entering a barcode (EAN/UPC).
Instructions
Look up a product by barcode (EAN/UPC). Returns product name, brand, quantity, and image from Open Food Facts.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"barcode": "<barcode>"
},
"name": "lookup_product"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| barcode | Yes | Product barcode (8-14 digits) |
Implementation Reference
- src/index.ts:44-51 (handler)The handler function for 'lookup_product', which fetches product data by calling the /api/product/${barcode} endpoint.
async ({ barcode }) => { try { const product = await api(`/api/product/${barcode}`); return text(product); } catch (e) { return errorResult(`Product lookup failed: ${(e as Error).message}`); } }, - src/index.ts:40-52 (registration)Registration of the 'lookup_product' tool using server.tool.
server.tool( 'lookup_product', 'Look up a product by barcode (EAN/UPC). Returns product name, brand, quantity, and image from Open Food Facts.', { barcode: z.string().describe('Product barcode (8-14 digits)') }, async ({ barcode }) => { try { const product = await api(`/api/product/${barcode}`); return text(product); } catch (e) { return errorResult(`Product lookup failed: ${(e as Error).message}`); } }, );