Open Food Facts MCP Server
Uses Codecov for code coverage reporting and tracking test coverage metrics
Supports Docker deployment with containerization and Docker Compose orchestration for production environments
Uses environment variable configuration management for API settings and rate limiting parameters
Integrates with Git version control for development workflow and repository management
Hosted on GitHub with CI/CD workflows, issue tracking, and collaborative development features
Uses npm for package management, dependency installation, and build script execution
Displays project status badges for test results, code coverage, and license information
Implemented in TypeScript with full type safety and comprehensive type definitions for food product data
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Open Food Facts MCP Server look up product with barcode 3017620422003"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Open Food Facts MCP Server
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: Open Food Facts MCP Server
๐ Quick Start
Docker Deployment (Recommended)
# Clone and run
git clone https://github.com/conner/open-food-facts-mcp
cd open-food-facts-mcp
docker-compose up --buildLocal 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 validateCode Quality
# Type checking
npm run typecheck
# Linting
npm run lint
npm run lint:fixProject 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.3gNutritional 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
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Make your changes with tests
Run quality checks (
npm run validate)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
Open Food Facts for providing the comprehensive food database
Model Context Protocol for the MCP specification
The global community of contributors maintaining food data quality
Need help? Open an issue or check the examples for detailed usage patterns.
Available Tools
5 toolsanalyze_productC
Get nutritional analysis and scores for a product by barcode
Inputs: barcode (required).
compare_productsC
Compare nutritional information between multiple products
Inputs: barcodes (required), focus.
get_productB
Retrieve detailed information about a food product by its barcode
Inputs: barcode (required).
get_product_suggestionsC
Get product suggestions based on dietary preferences or restrictions
Inputs: category (required), dietary_preferences, max_results, min_nutriscore.
search_productsC
Search for food products with various filters and criteria
Inputs: search, categories, brands, countries, +5 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 5 tools
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.
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.
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.
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.
Related MCP Connectors
Look up a packaged food by barcode, search and compare products, and check listed allergens.
Nutrition data for AI agents and LLMs, powered by Edamamโs database of 1,000,000 foods, including 680,000+ with UPC codes. Lookup via natural language and barcode at low cost and low latency. Highly accurate, deterministic data covering macro and micronutrients, allergens, and lifestyle diet tags.
Food nutrition lookup via natural language, barcode, and image. Database of 1,000,000+ foods.
Unlock the power of food transparency with our Open Food Facts MCP server. Easily look up any food
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables LLMs to search for food products and retrieve detailed nutritional information from the Open Food Facts database using product names or barcodes.-
- FlicenseBqualityDmaintenanceEnables AI assistants to access food product information, providing nutritional analysis, product comparisons, and recipe suggestions using the Open Food Facts database.21-
- FlicenseBqualityDmaintenanceEnables AI assistants to access food product information from Open Food Facts, including nutritional analysis, product comparisons, recipe suggestions, and allergen checks.21-
- AlicenseAqualityDmaintenanceProvides LLMs with access to food nutrition data from Open Food Facts, enabling barcode lookup, product search, and nutrition score comparisons.5MIT