Skip to main content
Glama
domdomegg

openfoodfacts-mcp

Search products (standard)

search_products_standard
Read-only

Search food products using structured filters for brands, categories, and keywords to find specific items in the Open Food Facts database.

Instructions

Search Open Food Facts with structured filters. Best for simple keyword queries and brand/category filtering. Returns exact result counts and well-populated products. If you have a barcode, use get_product instead.

How search works: strict AND against a keyword index built from product_name, generic_name, brands, categories, origins, labels. One unmatched query word → zero results.

Tips:

  • Prefer 2-3 distinctive words over the full product name

  • Put brand names in brands_tags, not the query text

  • Brand normalization is generous: "sainsburys", "sainsbury's", "sainsbury-s" all match

  • For fresh produce, use brands_tags + categories_tags rather than text search

  • sort_by=popularity works well here (not supported in search_products_lucene)

If you get zero results, try dropping words or using search_products_lucene which has more flexible text matching.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSearch terms. Strict AND: every word must exist in the product's indexed keywords, so prefer 2-3 distinctive words over the full product name. Use words as they appear on the pack (don't strip plurals or possessives — the search normalizes both sides). Put brand names in brands_tags instead of here.
categories_tagsNoFilter by category tag (e.g. "en:breakfast-cereals", "en:tomatoes"). Best way to find fresh produce: text-searching "banana" matches thousands of banana-flavoured products, but categories_tags "en:bananas" finds actual bananas.
brands_tagsNoFilter by brand. Input is normalized, so "sainsburys", "sainsbury's", "sainsbury-s" all match the same brand — no need to know the exact tag slug. More reliable than putting the brand in the query text.
nutrition_grades_tagsNoFilter by Nutri-Score grade (a, b, c, d, e)
sort_byNoSort order
pageNoPage number (default: 1)
page_sizeNoResults per page (default: 24, max: 100)
fieldsNoFields to return per product. Defaults to: code, product_name, brands, categories, nutriscore_grade, nova_group, image_url, quantity

Implementation Reference

  • The `registerSearchProductsStandard` function defines the tool "search_products_standard" and contains the handler implementation, which calls the Open Food Facts API (`offGet`) with mapped parameters.
    export function registerSearchProductsStandard(server: McpServer, config: Config): void {
    	server.registerTool(
    		'search_products_standard',
    		{
    			title: 'Search products (standard)',
    			description: `Search Open Food Facts with structured filters. Best for simple keyword queries and brand/category filtering. Returns exact result counts and well-populated products. If you have a barcode, use get_product instead.
    
    How search works: strict AND against a keyword index built from product_name, generic_name, brands, categories, origins, labels. One unmatched query word → zero results.
    
    Tips:
    - Prefer 2-3 distinctive words over the full product name
    - Put brand names in brands_tags, not the query text
    - Brand normalization is generous: "sainsburys", "sainsbury's", "sainsbury-s" all match
    - For fresh produce, use brands_tags + categories_tags rather than text search
    - sort_by=popularity works well here (not supported in search_products_lucene)
    
    If you get zero results, try dropping words or using search_products_lucene which has more flexible text matching.`,
    			inputSchema,
    			annotations: {
    				readOnlyHint: true,
    			},
    		},
    		async (args) => {
    			const params: Record<string, string> = {
    				page: String(args.page),
    				page_size: String(args.page_size),
    				json: '1',
    				search_simple: '1',
    				action: 'process',
    			};
    
    			if (args.query) {
    				params.search_terms = args.query;
    			}
    
    			if (args.categories_tags) {
    				params.categories_tags = args.categories_tags;
    			}
    
    			if (args.brands_tags) {
    				params.brands_tags = args.brands_tags;
    			}
    
    			if (args.nutrition_grades_tags) {
    				params.nutrition_grades_tags = args.nutrition_grades_tags;
    			}
    
    			if (args.sort_by) {
    				params.sort_by = args.sort_by;
    			}
    
    			const fields = args.fields ?? DEFAULT_FIELDS;
    			params.fields = fields.join(',');
    
    			const data = await offGet(config, '/cgi/search.pl', params);
    
    			return jsonResult(data as Record<string, unknown>);
    		},
    	);
    }
  • Zod schema definition for "search_products_standard" inputs, including parameter aliases.
    const inputSchema = strictSchemaWithAliases(
    	{
    		query: z.string().optional().describe('Search terms. Strict AND: every word must exist in the product\'s indexed keywords, so prefer 2-3 distinctive words over the full product name. Use words as they appear on the pack (don\'t strip plurals or possessives — the search normalizes both sides). Put brand names in brands_tags instead of here.'),
    		categories_tags: z.string().optional().describe('Filter by category tag (e.g. "en:breakfast-cereals", "en:tomatoes"). Best way to find fresh produce: text-searching "banana" matches thousands of banana-flavoured products, but categories_tags "en:bananas" finds actual bananas.'),
    		brands_tags: z.string().optional().describe('Filter by brand. Input is normalized, so "sainsburys", "sainsbury\'s", "sainsbury-s" all match the same brand — no need to know the exact tag slug. More reliable than putting the brand in the query text.'),
    		nutrition_grades_tags: z.string().optional().describe('Filter by Nutri-Score grade (a, b, c, d, e)'),
    		sort_by: z.enum([
    			'popularity',
    			'product_name',
    			'created_t',
    			'last_modified_t',
    			'nutriscore_score',
    			'nova_score',
    		]).optional().describe('Sort order'),
    		page: z.number().int().min(1).default(1).describe('Page number (default: 1)'),
    		page_size: z.number().int().min(1).max(100).default(24).describe('Results per page (default: 24, max: 100)'),
    		fields: z.array(z.string()).optional().describe(`Fields to return per product. Defaults to: ${DEFAULT_FIELDS.join(', ')}`),
    	},
    	{
    		q: 'query',
    		search: 'query',
    	},
    );
  • Registration of the "search_products_standard" tool within the main tools index file.
    import {registerSearchProductsStandard} from './search-products-standard.js';
    import {registerSearchProductsLucene} from './search-products-lucene.js';
    import {registerAutocomplete} from './autocomplete.js';
    import {registerAddOrEditProduct} from './add-or-edit-product.js';
    import {registerUploadImage} from './upload-image.js';
    import {registerSelectImage} from './select-image.js';
    import {registerCallApi} from './call-api.js';
    import {registerGetApiDocs} from './get-api-docs.js';
    import {registerGetSkill} from './get-skill.js';
    
    export type {Config} from './types.js';
    
    export function registerAll(server: McpServer, config: Config): void {
    	registerGetProduct(server, config);
    	registerSearchProductsStandard(server, config);
Behavior4/5

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

Annotations establish readOnlyHint=true (safe read operation). Description adds substantial behavioral context not in schema: strict AND logic with 'one unmatched query word → zero results,' brand normalization rules, and sort_by limitations specific to this endpoint vs. siblings.

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

Conciseness4/5

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

Lengthy but well-structured and front-loaded: opens with purpose and sibling alternatives, followed by mechanics explanation and bulleted tips. Every section provides actionable value; no tautology. Could be tighter but complexity justifies the verbosity.

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?

Strong coverage for a complex search tool: describes return characteristics ('exact result counts and well-populated products') despite no output schema, explains pagination via page/page_size parameters, and covers all 8 parameters with 100% schema coverage plus strategic usage context.

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

Parameters4/5

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

Schema coverage is 100%, establishing a baseline of 3. Description adds strategic semantic value beyond schema: clarifies when to use brands_tags vs. query text, recommends categories_tags for fresh produce over text search, and explains sort_by behavior differences with search_products_lucene.

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?

Excellent specificity: 'Search Open Food Facts with structured filters' establishes verb and resource. Explicitly distinguishes from siblings: notes get_product is for barcodes and search_products_lucene has 'more flexible text matching,' giving clear scope boundaries.

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

Usage Guidelines5/5

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

Provides explicit when-to-use alternatives: 'If you have a barcode, use get_product instead' and 'try search_products_lucene' for zero results. Also includes strategic guidance ('Best for simple keyword queries') and detailed tips section covering query construction and brand/category placement.

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