Skip to main content
Glama
JagjeevanAK

OpenFoodFacts-mcp

by JagjeevanAK

autocomplete

Find matching entries from food taxonomies: categories, brands, labels, ingredients, allergens, or additives based on a partial query.

Instructions

Get autocomplete suggestions for categories, brands, labels, ingredients, allergens, or additives

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesAutocomplete query
taxonomyTypeYesType of taxonomy to search
langNoLanguage codeen
limitNoMaximum number of suggestions

Implementation Reference

  • The actual implementation of autocomplete logic: calls the Search-a-licious API with query, taxonomyType, lang, and limit parameters and returns the JSON response.
    export async function getAutocomplete(query: string, taxonomyType: string, lang: string, limit: number) {
        const url = new URL(`${SEARCH_API_URL}/autocomplete`);
        url.searchParams.set('q', query);
        url.searchParams.set('taxonomy_names', taxonomyType);
        url.searchParams.set('lang', lang);
        url.searchParams.set('size', limit.toString());
    
        const response = await fetch(url.toString());
        if (!response.ok) {
            throw new Error(`Autocomplete failed: ${response.status}`);
        }
    
        return await response.json();
    }
  • The Zod schema defining input validation for the autocomplete tool: query (string), taxonomyType (enum), lang (string, default 'en'), limit (number, default 10).
    const autocompleteSchema = {
        query: z.string().describe('Autocomplete query'),
        taxonomyType: z.enum(['categories', 'brands', 'labels', 'countries', 'ingredients', 'allergens', 'additives'])
            .describe('Type of taxonomy to search'),
        lang: z.string().default('en').describe('Language code'),
        limit: z.number().default(10).describe('Maximum number of suggestions')
    };
  • Registration of the 'autocomplete' tool via server.registerTool, with its description and the async handler that calls getAutocomplete helper.
    server.registerTool('autocomplete', {
        description: 'Get autocomplete suggestions for categories, brands, labels, ingredients, allergens, or additives',
        inputSchema: autocompleteSchema
    }, async ({ query, taxonomyType, lang, limit }) => {
        try {
            const suggestions = await getAutocomplete(query, taxonomyType, lang ?? 'en', limit ?? 10);
            return { content: [{ type: 'text' as const, text: JSON.stringify(suggestions, null, 2) }] };
        } catch (error: any) {
            return { content: [{ type: 'text' as const, text: `Error: ${error.message}` }], isError: true };
        }
    });
  • The main tools index calls registerCategoryTools(server) which registers the autocomplete tool among others.
      registerCategoryTools(server);
    
      registerNutritionTools(server);
    
      registerInsightsTools(server);
    
      registerPriceTools(server);
    
      logger.info("All OpenFoodFacts MCP tools registered successfully");
    }
Behavior3/5

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

No annotations are present, so the description must disclose behavior. It states the function but does not mention side effects, authentication requirements, or rate limits. For a simple read-only operation, the transparency is adequate but lacks depth.

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?

The description is a single sentence of 12 words that efficiently conveys the tool's purpose and scope. Every part is necessary, and there is no redundancy.

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?

For a simple autocomplete tool with 4 parameters and no output schema, the description covers the essential information. It could mention the return format or typical use case, but it is largely complete.

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?

With 100% schema description coverage, the baseline is 3. The description does not add meaningful context beyond what the schema already provides; it merely repeats the taxonomy types. No additional parameter usage guidance is given.

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

Purpose5/5

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

The description clearly states the tool provides autocomplete suggestions for specific taxonomy types (categories, brands, labels, ingredients, allergens, additives). The verb 'Get autocomplete suggestions' and the listed resources make the purpose distinct from sibling tools like searchProducts or searchByBrand.

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

Usage Guidelines3/5

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

The description implies usage for autocomplete input scenarios but does not explicitly state when to use this tool over alternatives like searchProducts or advancedSearch. No guidance on when not to use or prerequisites is provided.

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/JagjeevanAK/OpenFoodFacts-MCP'

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