Skip to main content
Glama
JagjeevanAK

OpenFoodFacts-mcp

by JagjeevanAK

getAdditivesInfo

List additives in a food product with E-numbers and NOVA processing level by entering a product name or barcode.

Instructions

List all additives in a product with their E-numbers and NOVA processing level

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameOrBarcodeYesProduct name or barcode (EAN/UPC)

Implementation Reference

  • The actual implementation of getAdditivesInfo. It extracts additives_tags (or additives_original_tags) from a product, maps them to E-number names, and returns an AdditivesResult with barcode, product name, additives list, count, novaGroup, and NOVA explanation.
    export function getAdditivesInfo(product: any): AdditivesResult {
        const additivesTags = product.additives_tags || [];
        const additivesOriginalTags = product.additives_original_tags || [];
        const novaGroup = product.novaGroup || product.nova_group || 0;
    
        const additives = (additivesTags.length > 0 ? additivesTags : additivesOriginalTags).map((tag: string) => {
            const match = tag.match(/en:(e\d+[a-z]?)/i);
            return {
                tag: tag,
                name: match ? match[1].toUpperCase() : tag.replace('en:', '').toUpperCase()
            };
        });
    
        return {
            barcode: product.barcode || product.code,
            productName: product.name || product.product_name || 'Unknown',
            additives,
            count: additives.length,
            novaGroup,
            novaExplanation: NOVA_EXPLANATIONS[novaGroup] || 'NOVA group not available'
        };
    }
  • The AdditivesResult interface defining the return type shape: barcode, productName, additives (array of tag/name), count, novaGroup, and novaExplanation.
    export interface AdditivesResult {
        barcode: string;
        productName: string;
        additives: Array<{
            tag: string;
            name: string;
        }>;
        count: number;
        novaGroup: number;
        novaExplanation: string;
    }
  • Registration of the 'getAdditivesInfo' tool on the MCP server. Defines description, input schema (nameOrBarcode), and the callback handler that calls findProduct then getAdditivesInfo.
    server.registerTool('getAdditivesInfo', {
        description: 'List all additives in a product with their E-numbers and NOVA processing level',
        inputSchema: productIdentifierSchema
    }, async ({ nameOrBarcode }) => {
        try {
            const product = await findProduct(nameOrBarcode);
            if (!product) {
                return { content: [{ type: 'text' as const, text: `Product "${nameOrBarcode}" not found.` }], isError: true };
            }
            const result = getAdditivesInfo(product);
            return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };
        } catch (error: any) {
            return { content: [{ type: 'text' as const, text: `Error: ${error.message}` }], isError: true };
        }
    });
  • NOVA_EXPLANATIONS constant mapping NOVA groups 1-4 to descriptions, used by getAdditivesInfo to populate novaExplanation.
    export const NOVA_EXPLANATIONS: Record<number, string> = {
        1: 'Unprocessed or minimally processed foods',
        2: 'Processed culinary ingredients',
        3: 'Processed foods',
        4: 'Ultra-processed foods - contains industrial additives'
    };
  • Documentation/reference mentioning the getAdditivesInfo tool in the list of available nutrition tools.
    | Check for allergens | \`getAllergenCheck\` - gluten, milk, nuts, etc. |
    | Check multiple allergens | \`checkMultipleAllergens\` - check several at once |
    | See additives | \`getAdditivesInfo\` - E-numbers and processing level |

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

A3.8/5.0
Behavior3/5

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

No annotations are provided, so the description carries the burden. It discloses the return content (E-numbers, NOVA level) but does not explicitly state that the operation is read-only, nor does it mention any dependencies, rate limits, or error conditions. The behavior is implied but not fully transparent.

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 13 words, front-loading the action ('List all additives') and providing key specifics immediately. No extraneous information.

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 the tool's simplicity (one parameter, no nested objects, no output schema), the description adequately conveys the return structure as a list of additives with E-numbers and NOVA level. It is nearly complete for the agent to understand the output, though it could be slightly improved by noting if the list is flat or grouped.

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 description coverage is 100% for the single parameter 'nameOrBarcode'. The tool description restates the parameter's purpose indirectly by saying 'in a product', but adds no new semantic detail beyond the schema's own description. Baseline 3 is appropriate.

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 uses a specific verb 'List' and clearly identifies the resource 'additives in a product' with specific details (E-numbers, NOVA processing level). It distinguishes from sibling tools like getProductByBarcode which returns general product info, and analyzeProduct which provides broader analysis.

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 when to use the tool (when you need additive information) but provides no explicit guidance about when to avoid it or which sibling alternatives might be better. Given many sibling tools, explicit exclusion or alternative suggestions are missing.

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