Skip to main content
Glama
domdomegg

openfoodfacts-mcp

Autocomplete

autocomplete
Read-only

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
NameRequiredDescriptionDefault
tagtypeYesType of taxonomy to search
queryYesSearch prefix
lcNoLanguage code (default: en)en
limitNoMax results (default: 10, max: 100)

Implementation Reference

  • 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>);
    },
  • 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',
    	},
    );
  • 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>);
    		},
    	);
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare readOnlyHint=true covering safety profile. Description adds no behavioral context about return format, rate limits, or result structure, but does not contradict annotations. Minimal disclosure sufficient for a read-only operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single efficient sentence with action front-loaded. No redundant words and examples are parenthetically attached without clutter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 100% schema coverage, present annotations, and simple flat parameter structure, the description is complete enough despite brevity. Lacking output schema means return format is undefined, but 'autocomplete suggestions' is sufficiently conventional.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% description coverage with clear parameter definitions. Description mentions no parameters directly, but with full schema coverage the baseline is 3 as the schema carries the full semantic load.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear verb 'Get' with specific resource 'autocomplete suggestions' and domain 'Open Food Facts taxonomy entries'. Listing examples (brands, categories, labels) helps distinguish from sibling product search tools, though it doesn't explicitly contrast when to use this versus search_products_lucene/standard.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus the search_products tools or get_product. The description states what it does but not when to prefer taxonomy autocomplete over product search.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/domdomegg/openfoodfacts-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server