Skip to main content
Glama
caleb-conner

Open Food Facts MCP Server

by caleb-conner

Open Food Facts MCP Server

Test Suite codecov License: MIT

A comprehensive Model Context Protocol (MCP) server that provides AI assistants with access to the Open Food Facts database. Query detailed food product information, nutritional data, and environmental scores to help users make informed food choices.

๐ŸŒŸ Features

  • Product Lookup: Get detailed information by barcode including nutritional facts, ingredients, and scores

  • Smart Search: Find products with advanced filtering by categories, brands, nutrition grades, and more

  • Nutritional Analysis: Interpret Nutri-Score, NOVA processing groups, and Eco-Score ratings

  • Product Comparison: Compare multiple products side-by-side across different criteria

  • Dietary Recommendations: Get suggestions based on dietary preferences and restrictions

  • Rate Limiting: Built-in rate limiting respects Open Food Facts API constraints

  • Docker Ready: Production deployment with Docker and Docker Compose

Related MCP server: Food Data Central MCP Server

๐Ÿš€ Quick Start

# Clone and run
git clone https://github.com/conner/open-food-facts-mcp
cd open-food-facts-mcp
docker-compose up --build

Local Development

# Install dependencies
npm install

# Configure environment
cp .env.example .env

# Build and start
npm run build
npm start

# Development mode
npm run dev

๐Ÿ”ง Configuration

Configure the server via environment variables:

# API Configuration
OPEN_FOOD_FACTS_BASE_URL=https://world.openfoodfacts.net
OPEN_FOOD_FACTS_USER_AGENT=YourApp/1.0 (contact@example.com)

# Rate Limits (requests per minute)
RATE_LIMIT_PRODUCTS=100
RATE_LIMIT_SEARCH=10
RATE_LIMIT_FACETS=2

๐Ÿ›  Available Tools

get_product

Retrieve comprehensive product information by barcode.

{
  "barcode": "3017620422003"
}

Returns: Product name, brand, nutritional scores, ingredients, nutrition facts, and metadata.

search_products

Search products with advanced filtering capabilities.

{
  "search": "organic chocolate",
  "categories": "snacks",
  "nutrition_grades": "a,b,c",
  "page_size": 10
}

Filters: Categories, brands, countries, nutrition grades, NOVA groups, sorting options.

analyze_product

Get detailed nutritional analysis and score interpretations.

{
  "barcode": "3017620422003"
}

Returns: Score explanations, nutritional breakdown with health assessments, and processing level details.

compare_products

Compare multiple products across different aspects.

{
  "barcodes": ["3017620422003", "8712566073219"],
  "focus": "nutrition"
}

Focus Options: nutrition, environmental, processing, ingredients.

get_product_suggestions

Get personalized product recommendations.

{
  "category": "beverages",
  "dietary_preferences": ["vegan", "organic"],
  "min_nutriscore": "b",
  "max_results": 5
}

Dietary Options: vegan, vegetarian, gluten-free, organic, low-fat, low-sugar, high-protein.

๐Ÿค– MCP Integration

Add to your MCP client configuration:

{
  "mcpServers": {
    "open-food-facts": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "open-food-facts-mcp"]
    }
  }
}

Or for local development:

{
  "mcpServers": {
    "open-food-facts": {
      "command": "node",
      "args": ["dist/index.js"],
      "cwd": "/path/to/open-food-facts-mcp"
    }
  }
}

๐Ÿ“Š Data & Scores

Nutri-Score

  • A-E rating indicating overall nutritional quality

  • Green (A/B): Healthier choices

  • Red (D/E): Less healthy options

NOVA Groups

  • Group 1: Unprocessed/minimally processed foods

  • Group 2: Processed culinary ingredients

  • Group 3: Processed foods

  • Group 4: Ultra-processed foods

Eco-Score

  • A-E rating for environmental impact

  • Considers packaging, transportation, and production methods

๐Ÿงช Development

Testing

# Run all tests
npm test

# Watch mode
npm run test:watch

# Coverage report
npm run test:coverage

# Validate code quality
npm run validate

Code Quality

# Type checking
npm run typecheck

# Linting
npm run lint
npm run lint:fix

Project Structure

src/
โ”œโ”€โ”€ client.ts       # HTTP client with rate limiting
โ”œโ”€โ”€ handlers.ts     # MCP tool implementations
โ”œโ”€โ”€ index.ts        # MCP server entry point
โ”œโ”€โ”€ tools.ts        # Tool definitions
โ””โ”€โ”€ types.ts        # TypeScript types and schemas

tests/
โ”œโ”€โ”€ client.test.ts      # Client unit tests
โ”œโ”€โ”€ handlers.test.ts    # Handler unit tests
โ”œโ”€โ”€ server.test.ts      # Integration tests
โ”œโ”€โ”€ validation.test.ts  # Schema validation tests
โ”œโ”€โ”€ rate-limiting.test.ts # Rate limiting tests
โ”œโ”€โ”€ e2e.test.ts        # End-to-end tests
โ”œโ”€โ”€ fixtures/          # Test data
โ””โ”€โ”€ utils/            # Test utilities

๐Ÿ“ˆ Performance

  • Rate Limiting: Automatic enforcement of API limits

  • Efficient Caching: Smart request deduplication

  • Batch Operations: Optimized multi-product comparisons

  • Error Recovery: Graceful handling of API failures

๐Ÿ”’ API Limits

The server respects Open Food Facts API rate limits:

  • Product queries: 100 requests/minute

  • Search queries: 10 requests/minute

  • Facet queries: 2 requests/minute

Rate limits are enforced automatically with proper error messaging.

๐ŸŒ Data Source

All data comes from Open Food Facts, the largest open food database in the world:

  • 900,000+ products from 150+ countries

  • Collaborative data maintained by contributors worldwide

  • Open Database License ensuring free access to food information

  • Real-time updates from the global community

๐Ÿ“ Examples

Basic Product Information

**Nutella**
Brand: Ferrero
Quantity: 400g
Categories: Sweet spreads, Chocolate spreads

Scores:
Nutri-Score: E | NOVA Group: 4 | Eco-Score: D

Ingredients:
Sugar, palm oil, hazelnuts (13%), skimmed milk powder...

Nutrition (per 100g):
Energy: 539 kcal | Fat: 30.9g | Carbs: 57.5g | Sugars: 56.3g

Nutritional Analysis

Nutritional Analysis: Nutella

Scores:
โ€ข Nutri-Score E: Very poor nutritional quality
โ€ข NOVA Group 4: Ultra-processed foods  
โ€ข Eco-Score D: High environmental impact

Nutritional Breakdown:
โ€ข Energy: 539 kcal (high)
โ€ข Fat: 30.9g (high)
โ€ข Sugars: 56.3g (high)
โ€ข Salt: 0.107g (low)

๐Ÿค Contributing

  1. Fork the repository

  2. Create a feature branch (git checkout -b feature/amazing-feature)

  3. Make your changes with tests

  4. Run quality checks (npm run validate)

  5. Commit your changes (git commit -m 'Add amazing feature')

  6. Push to the branch (git push origin feature/amazing-feature)

  7. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments


Need help? Open an issue or check the examples for detailed usage patterns.

Available Tools

5 tools
analyze_productC

Get nutritional analysis and scores for a product by barcode

ParametersJSON Schema
NameRequiredDescriptionDefault
barcodeYesThe barcode/ID of the product to analyze

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves nutritional analysis and scores, implying a read-only operation, but doesn't cover aspects like authentication needs, rate limits, error handling, or what specific data is returned. This leaves significant gaps in understanding the tool's behavior.

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, efficient sentence that directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to parse and understand quickly.

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

Completeness2/5

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

Given the complexity of a tool that analyzes nutritional data, the lack of annotations and output schema means the description is incomplete. It doesn't explain what 'nutritional analysis and scores' entail, the format of the response, or any behavioral traits, leaving the agent with insufficient context for effective use.

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?

The input schema has 100% description coverage, with the 'barcode' parameter fully documented in the schema. The description adds no additional meaning beyond implying it's used for product identification, so it meets the baseline score of 3 where the schema does the heavy lifting.

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?

The description clearly states the action ('Get nutritional analysis and scores') and resource ('for a product by barcode'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_product' or 'search_products', which might also retrieve product information, so it falls short of a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get_product' or 'search_products'. It implies usage by specifying the barcode parameter but offers no context, exclusions, or comparisons to sibling tools, leaving the agent to infer usage scenarios.

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

compare_productsC

Compare nutritional information between multiple products

ParametersJSON Schema
NameRequiredDescriptionDefault
barcodesYesArray of product barcodes to compare (max 10)
focusNoFocus comparison on specific aspect

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool compares nutritional information, implying a read-only operation, but doesn't clarify aspects like data sources, rate limits, authentication needs, or what happens if barcodes are invalid. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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, efficient sentence: 'Compare nutritional information between multiple products.' It is front-loaded with the core purpose, has no redundant words, and every part earns its place by clearly stating the tool's function. This is an excellent example of conciseness.

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

Completeness2/5

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

Given the complexity of comparing multiple products and the lack of annotations and output schema, the description is incomplete. It doesn't explain the return format, error handling, or how the comparison is presented (e.g., side-by-side table, summary). For a tool with no structured output documentation, more context is needed to guide the agent effectively.

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?

The schema description coverage is 100%, with clear descriptions for both parameters (e.g., 'Array of product barcodes to compare (max 10)' and 'Focus comparison on specific aspect'). The description adds no additional parameter semantics beyond what the schema provides, such as explaining the 'focus' enum values in context. This meets the baseline for high schema coverage.

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?

The description clearly states the tool's purpose: 'Compare nutritional information between multiple products.' It specifies the verb ('compare') and resource ('nutritional information between multiple products'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'analyze_product' or 'get_product,' which might also involve product data retrieval, so it doesn't reach the highest score.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'analyze_product' or 'search_products,' nor does it specify prerequisites or exclusions. The agent must infer usage from the name and schema alone, which is insufficient for optimal tool selection.

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

get_productB

Retrieve detailed information about a food product by its barcode

ParametersJSON Schema
NameRequiredDescriptionDefault
barcodeYesThe barcode/ID of the product (e.g., '3017620422003')

TDQS

B3.3/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Retrieve' implies a read operation, it doesn't specify whether this requires authentication, rate limits, error conditions (e.g., invalid barcode), or what 'detailed information' includes (e.g., nutritional data, pricing). For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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, efficient sentence with zero waste. It front-loads the core purpose ('Retrieve detailed information') and specifies the key constraint ('by its barcode') without unnecessary elaboration. Every word earns its place.

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

Completeness3/5

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

For a simple read operation with one well-documented parameter and no output schema, the description is minimally adequate. However, it lacks context about the nature of 'detailed information' returned, which could be critical for an agent. Without annotations or output schema, the description should ideally hint at the response structure or data scope to be fully 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?

Schema description coverage is 100%, with the single parameter 'barcode' fully documented in the schema. The description adds no additional parameter semantics beyond implying the barcode identifies a food product, which is already clear from the schema's example. Baseline 3 is appropriate when the schema does the heavy lifting.

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 specific action ('Retrieve detailed information') and target resource ('about a food product by its barcode'), distinguishing it from siblings like 'search_products' (which likely returns multiple results) or 'analyze_product' (which might perform analysis rather than basic retrieval). The verb+resource combination is precise and unambiguous.

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?

The description provides no guidance on when to use this tool versus alternatives like 'search_products' or 'get_product_suggestions'. It doesn't mention prerequisites (e.g., needing a barcode), exclusions, or comparative use cases. The agent must infer usage from the description alone without explicit direction.

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

get_product_suggestionsC

Get product suggestions based on dietary preferences or restrictions

ParametersJSON Schema
NameRequiredDescriptionDefault
categoryYesProduct category to search within
dietary_preferencesNoDietary preferences or restrictions
max_resultsNoMaximum number of suggestions (default: 10)
min_nutriscoreNoMinimum Nutri-Score grade (a, b, c, d, e)

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states what the tool does ('Get product suggestions') without describing how it behavesโ€”such as whether it's a read-only operation, how results are returned, potential rate limits, or authentication needs. This is inadequate for a tool with 4 parameters and no output schema.

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, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given the complexity of 4 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits, result format, and usage context, which are essential for an agent to effectively invoke this tool without structured support.

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?

The description mentions 'dietary preferences or restrictions', which aligns with one parameter, but adds minimal value beyond the input schema, which has 100% coverage and detailed descriptions for all parameters. Since schema coverage is high, the baseline score is 3, as the description doesn't significantly enhance parameter understanding.

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?

The description clearly states the tool's purpose as 'Get product suggestions based on dietary preferences or restrictions', which specifies the verb ('Get'), resource ('product suggestions'), and key input criteria. However, it doesn't explicitly differentiate from sibling tools like 'search_products' or 'get_product', which might have overlapping functionality.

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?

The description provides no guidance on when to use this tool versus alternatives like 'search_products' or 'get_product'. It mentions the input criteria but doesn't specify use cases, prerequisites, or exclusions, leaving the agent to infer usage context.

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

search_productsC

Search for food products with various filters and criteria

ParametersJSON Schema
NameRequiredDescriptionDefault
searchNoSearch terms for product names, brands, or ingredients
categoriesNoFilter by categories (e.g., 'beverages', 'dairy')
brandsNoFilter by brand names
countriesNoFilter by countries (e.g., 'france', 'united-states')
nutrition_gradesNoFilter by Nutri-Score grades (a, b, c, d, e)
nova_groupsNoFilter by NOVA processing groups (1, 2, 3, 4)
sort_byNoSort results by: popularity, product_name, created_datetime, last_modified_datetime
pageNoPage number for pagination (default: 1)
page_sizeNoNumber of results per page (default: 20, max: 100)

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions filtering and sorting capabilities but doesn't address key behavioral aspects like whether this is a read-only operation, expected response format, pagination behavior beyond schema hints, rate limits, or authentication requirements. The description is too minimal for a tool with 9 parameters and no output schema.

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, efficient sentence that gets straight to the point with no wasted words. It's appropriately sized for a search tool and front-loads the core functionality without unnecessary elaboration.

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

Completeness2/5

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

For a tool with 9 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what kind of results to expect, how results are structured, whether there are limitations on search scope, or how to interpret empty results. The agent would need to guess about important behavioral aspects despite the comprehensive parameter schema.

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%, so the schema already documents all 9 parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'various filters and criteria' but doesn't provide additional context about parameter interactions, default behaviors, or usage examples. This meets the baseline for high schema coverage.

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?

The description clearly states the verb ('search') and resource ('food products'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_product_suggestions' or 'analyze_product' which might also involve searching or retrieving product information, so it doesn't achieve full sibling differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get_product' (for single product retrieval) or 'get_product_suggestions' (which might offer recommendations). It mentions 'various filters and criteria' but doesn't specify contexts where this comprehensive search is preferred over simpler sibling tools.

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

TDQS

A3.5/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose with no ambiguity: analyze_product focuses on nutritional analysis, compare_products on comparisons, get_product on retrieval, get_product_suggestions on recommendations, and search_products on filtered searches. The descriptions make it easy for an agent to select the right tool for each specific task.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (e.g., analyze_product, compare_products, get_product, get_product_suggestions, search_products). This predictability enhances usability and reduces cognitive load for agents navigating the toolset.

Tool Count5/5

With 5 tools, the server is well-scoped for its food product domain, covering core operations like retrieval, search, analysis, comparison, and suggestions. Each tool earns its place without feeling excessive or insufficient for the intended functionality.

Completeness4/5

The toolset provides strong coverage for querying and analyzing food products, including CRUD-like retrieval and search, plus value-added features like analysis and suggestions. A minor gap might be the lack of update or creation tools, but this is reasonable for a read-only data source like Open Food Facts.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

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/caleb-conner/open-food-facts-mcp'

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