search_products
Find food products by name using Open Food Facts data to support price tracking and comparison across international supermarket chains.
Instructions
Search for products by name. Returns matching products 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": {
"query": "<query>"
},
"name": "search_products"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (min 2 characters) | |
| limit | No | Max results (1-20, default 10) |
Implementation Reference
- src/index.ts:54-69 (handler)Implementation of the search_products MCP tool, including registration, input schema, and handler logic.
server.tool( 'search_products', 'Search for products by name. Returns matching products from Open Food Facts.', { query: z.string().describe('Search query (min 2 characters)'), limit: z.number().min(1).max(20).default(10).describe('Max results (1-20, default 10)'), }, async ({ query, limit }) => { try { const results = await api(`/api/search?q=${encodeURIComponent(query)}&limit=${limit}`); return text(results); } catch (e) { return errorResult(`Search failed: ${(e as Error).message}`); } }, );