autocomplete
Get autocomplete suggestions for food taxonomy entries like brands, categories, and labels from the Open Food Facts database to speed up data entry and ensure accuracy.
Instructions
Get autocomplete suggestions for Open Food Facts taxonomy entries (brands, categories, labels, etc.).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tagtype | Yes | Type of taxonomy to search | |
| query | Yes | Search prefix | |
| lc | No | Language code (default: en) | en |
| limit | No | Max results (default: 10, max: 100) |
Implementation Reference
- src/tools/autocomplete.ts:45-56 (handler)The handler function that executes the autocomplete tool logic, calling the Open Food Facts API with the provided parameters.
async (args) => { const params: Record<string, string> = { tagtype: args.tagtype, string: args.query, lc: args.lc, limit: String(args.limit), }; const data = await offGet(config, '/api/v3/taxonomy_suggestions', params); return jsonResult(data as Record<string, unknown>); }, - src/tools/autocomplete.ts:8-32 (schema)The input schema definition using Zod for the autocomplete tool, including tagtype, query, language, and limit.
const inputSchema = strictSchemaWithAliases( { tagtype: z.enum([ 'brands', 'categories', 'labels', 'countries', 'stores', 'packaging', 'ingredients', 'traces', 'allergens', 'additives', 'states', ]).describe('Type of taxonomy to search'), query: z.string().describe('Search prefix'), lc: z.string().default('en').describe('Language code (default: en)'), limit: z.number().int().min(1).max(100).default(10).describe('Max results (default: 10, max: 100)'), }, { type: 'tagtype', term: 'query', q: 'query', }, ); - src/tools/autocomplete.ts:34-58 (registration)The registration function that defines the 'autocomplete' tool with the MCP server.
export function registerAutocomplete(server: McpServer, config: Config): void { server.registerTool( 'autocomplete', { title: 'Autocomplete', description: 'Get autocomplete suggestions for Open Food Facts taxonomy entries (brands, categories, labels, etc.).', inputSchema, annotations: { readOnlyHint: true, }, }, async (args) => { const params: Record<string, string> = { tagtype: args.tagtype, string: args.query, lc: args.lc, limit: String(args.limit), }; const data = await offGet(config, '/api/v3/taxonomy_suggestions', params); return jsonResult(data as Record<string, unknown>); }, ); }