Open Food Facts MCP Server
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 Serversearch for nutella and show me the nutritional info"
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 Walkthrough
I have successfully created a Model Context Protocol (MCP) server that interfaces with the Open Food Facts API. This server allows LLMs (like Claude via Claude Desktop) to search for products and retrieve food product details using barcodes.
Components Created
1. Server Implementation (server.py)
This file uses FastMCP to expose two tools:
get_product_by_barcode(barcode): Retrieves detailed product info (Name, Brand, Nutri-Score, Ingredients).search_products(query): Searches for products by name and returns a list of matches.
2. Validation Script (validate_server.py)
A Python script that simulates an MCP client. It connects to the local server via standard input/output (stdio) and executes both tools to verify functionality.
Related MCP server: Food Data Central MCP Server
How to Run
Prerequisites
Ensure you have the dependencies installed:
pip install -r requirements.txtRunning the Server
You can run the server directly (it listens on stdio):
python server.pyNote: This will not output anything visible to the console unless you speak JSON-RPC to it.
Verifying Functionality
Run the validation script to see the tools in action:
python validate_server.pyYou should see output demonstrating a search for "nutella" and a lookup of a specific barcode.
Integration with Claude Desktop (Example)
To use this with Claude Desktop, add the following to your claude_desktop_config.json:
{
"mcpServers": {
"openfoodfacts": {
"command": "python",
"args": ["C:\\Users\\saipr\\.gemini\\antigravity\\scratch\\openfoodfacts_mcp\\server.py"]
}
}
}
## Frontend (Streamlit)
For a more interactive experience, I have built a local web interface using Streamlit.
### Running the Frontend
```bash
python -m streamlit run app.pyThis will open a browser window where you can interactively search for products and look up barcodes without writing scripts.
This server cannot be deployed
Maintenance
Related MCP Connectors
Unlock the power of food transparency with our Open Food Facts MCP server. Easily look up any food
USDA FoodData Central nutrient lookup, FDA recall watch, EU FMCG labelling via remote MCP
Barcode lookup, nutrition search, and product comparison for 3M+ crowd-sourced food products.
Food and nutrition data: search, macros, and comparisons
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to access the Open Food Facts database to query detailed food product information, nutritional data, and environmental scores. Supports product lookup by barcode, smart search with filtering, nutritional analysis, product comparison, and dietary recommendations to help users make informed food choices.51MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to search the USDA's FoodData Central database and retrieve detailed nutritional information and ingredient lists. It supports comprehensive food data access through keyword searches and structured queries for specific food items.3MIT
- 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-