@cyanheads/openfoodfacts-mcp-server
Click on "Install 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., "@@cyanheads/openfoodfacts-mcp-serverLook up the product with barcode 7622210289281"
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.
Public Hosted Server: https://openfoodfacts.caseyjhand.com/mcp
Tools
Four tools for working with Open Food Facts — a free, crowd-sourced database of 3M+ packaged food products:
Tool | Description |
| Fetch a packaged food product by barcode. Returns name, brand, quantity, ingredients, allergens, additives, Nutri-Score, NOVA group, Green-Score, nutrition per 100g/serving, categories, labels, and data completeness. |
| Search by text query and/or structured tag filters (category, brand, label, allergen, additive, Nutri-Score grade, NOVA group, country). Returns summary rows with barcodes for follow-up lookups. |
| Side-by-side nutrition and scoring comparison for 2–10 products by barcode. Returns a normalized table of energy, macros, salt, Nutri-Score, NOVA, and Green-Score. |
| Resolve a human term to the canonical tag ID (categories, labels, allergens, additives, countries, NOVA groups, Nutri-Score grades) that |
off_get_product
Fetch a packaged food product by barcode (EAN-13 or UPC).
Accepts 8–14 digit barcodes (EAN-13, EAN-8, UPC-A, UPC-E)
Returns ingredients (raw text and parsed list with percent estimates, vegan/vegetarian flags), all 14 major allergens as tag IDs, E-number additives, Nutri-Score a–e, NOVA 1–4, Green-Score/Eco-Score, every nutrient Open Food Facts holds per 100g and per serving, the serving size those per-serving figures are measured against, categories/labels/packaging/origins as canonical tag IDs, front image URL, and data completeness score (0–1)
Optional
fieldsparameter restricts the response to a subset (e.g., scores only, or nutrition only)Open Food Facts is crowd-sourced — a missing field means "not yet entered by contributors," not that the attribute is absent from the actual product
A barcode no contributor has recorded raises the
not_founderror carrying a recovery hint — it is never returned as an empty result
off_search_products
Search Open Food Facts by text and/or structured tag filters.
Full-text search across product names, brands, and ingredients
Structured filters:
categories_tag,brands_tag,labels_tag,allergens_tag,additives_tag,nutrition_grade(a–e),nova_group(1–4),countries_tagText query and tag filters combine — a query with filters returns products that match the text and satisfy every filter (e.g.,
query: "dark chocolate"+labels_tag: en:organic+countries_tag: en:france)All filter values are canonical tag IDs — use
off_browse_taxonomyto resolve human terms (e.g., "organic" →en:organic).brands_tagtakes a brand slug and matches it exactly; open-ended brand wording belongs inqueryadditives_tagfilters only on searches with no text query — the text backend does not index additives, so pairing the two is rejected up front rather than returning an empty result set that looks like "no such product"Pagination via
page(1-based) andpage_size(1–50, default 20)totalis exact on tag-only searches. Text searches stop counting at 10,000 matches, and when that ceiling is hit the response says so withtotal_is_lower_bound: trueand renders the count as10000+— add filters for an exact figureSearches carrying a text query serve only the first 10,000 results — a deeper
page * page_sizeis rejected up front with the highest reachable page, not sent and retried. Tag-only searches publish no window, but deep pages are refused unpredictably, so narrowing the filters beats paging far inReturns summary rows (barcode, name, brand, Nutri-Score, NOVA, categories) — use
off_get_productfor full label dataResult counts reflect contributed products, not total products on the market
Search limited to ~10 requests/min by this server's own client-side budget, kept well inside what Open Food Facts asks of clients
off_compare_products
Side-by-side nutrition and scoring comparison for 2–10 barcodes.
Accepts 2–10 barcodes, compared in the order provided
Returns a normalized comparison table: energy (kcal/100g), fat, saturated fat, sugars, salt, protein, fiber, Nutri-Score, NOVA group, and Green-Score
Missing nutrition data is preserved as
null— comparisons are not imputed or estimatednot_foundlist identifies barcodes with no contributor record (partial results are not an error)failedlist identifies barcodes whose fetch failed, with the per-barcode reason — kept separate fromnot_found, which claims the opposite. A failed barcode never blocks the rows that resolved
off_browse_taxonomy
Resolve a human term to the canonical Open Food Facts tag ID before building off_search_products filters.
Facets:
categories,labels,allergens,additives,countries,nova_groups,nutrition_gradesWith a
searchterm, the five open facets resolve against the live Open Food Facts taxonomy — tens of thousands of category tags, not a fixed local list. Matching is case-insensitive substring against tag ID or display name (e.g.,"gluten"→en:no-gluten,en:gluten-free)Upstream tags are often plural (
"kombucha"→en:kombuchas) — pass the returnedidthrough unchanged rather than constructing onenova_groupsandnutrition_gradesare closed vocabularies answered offline and returned complete. Their IDs are bare (1–4,a–e), matching whatoff_search_productsacceptsLive results are merged behind an in-process sample that also serves offline operation. If Open Food Facts is unreachable or the taxonomy budget is spent, the tool answers from that sample and says so rather than failing — an empty result is never presented as an authoritative "no such tag"
Omitting
searchlists only the offline sample. The upstream taxonomy endpoint suggests against a term and cannot enumerate a facet, so an unfiltered call is not a view of the full vocabulary and reports no facet totallimitcontrols results returned (1–100, default 20). There is no offset or page input — the upstream endpoint offers no cursor, so narrow the term insteadTaxonomy lookups carry their own ~10 requests/min client-side budget, separate from the search budget
Related MCP server: openfoodfacts-mcp
Features
Built on @cyanheads/mcp-ts-core:
Declarative tool definitions — single file per tool, framework handles registration and validation
Unified error handling — handlers throw, framework catches, classifies, and formats
Pluggable auth:
none,jwt,oauthSwappable storage backends:
in-memory,filesystem,Supabase,Cloudflare KV/R2/D1Structured logging with optional OpenTelemetry tracing
STDIO and Streamable HTTP transports
Open Food Facts-specific:
No API key required — the identifying
User-Agentheader (required by OFF terms) is baked into the service layerToken-bucket rate limiting per endpoint class: product reads (~15/min), search (~10/min), taxonomy resolution (~10/min). The product and search defaults are the per-IP ceilings Open Food Facts publishes; lower them on a shared outbound IP. A local refusal says so — it never reports itself as an Open Food Facts rate limit
Automatic retry (3 attempts, 500ms base) for transient failures only — 5xx, timeouts, and 429 (honoring
Retry-After), with HTML error page detection for 503 during high load. A 4xx is never retried; the upstream's own explanation is surfaced insteadNutriments normalized from raw hyphenated keys (
energy-kcal_100g) to underscore form — the_100gand_servingvariants of every nutrient on the record, with the macros as named fields and the rest in an open map that carries each nutrient's own unit (micronutrients are reported in grams, so calcium0.071is 71 mg)Live tag resolution for
off_browse_taxonomyagainst the Open Food Facts taxonomy, merged behind a small in-process sample that covers offline operation and is authoritative for E-number lookups, which the upstream suggester answers poorly
Agent-friendly output:
Per-serving nutrition always carries its denominator —
serving_sizeas printed plus the parsedserving_quantity/serving_quantity_unit, and an explicit note when Open Food Facts has recorded noneMissing fields signal incomplete crowd-sourced data, not product attribute absence — surfaced in descriptions and format output
Computed scores (Nutri-Score, NOVA, Green-Score) returned as-is with regional caveat notes — not interpreted or normalized to health claims
not_foundlist inoff_compare_productsallows partial batch comparisons without request failure — and a barcode whose fetch failed lands infailedinstead, so a transport error is never reported as "no contributor record"Every failure carries a declared
reasonand a recovery hint on both client surfaces — timeouts, upstream outages, upstream rejections, and rate limits each resolve to their own error code and their own next step
Getting started
Public Hosted Instance
A public instance is available at https://openfoodfacts.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"openfoodfacts-mcp-server": {
"type": "streamable-http",
"url": "https://openfoodfacts.caseyjhand.com/mcp"
}
}
}Self-Hosted / Local
No API key is required. Add the following to your MCP client configuration file.
{
"mcpServers": {
"openfoodfacts-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/openfoodfacts-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with npx (no Bun required):
{
"mcpServers": {
"openfoodfacts-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/openfoodfacts-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with Docker:
{
"mcpServers": {
"openfoodfacts-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"ghcr.io/cyanheads/openfoodfacts-mcp-server:latest"
]
}
}
}For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
# Server listens at http://localhost:3010/mcpPrerequisites
Bun v1.3.0 or higher (or Node.js v24+).
No API key needed. The server sends an identifying
User-Agentto comply with Open Food Facts' terms of service — this is baked in and requires no configuration.
Installation
Clone the repository:
git clone https://github.com/cyanheads/openfoodfacts-mcp-server.gitNavigate into the directory:
cd openfoodfacts-mcp-serverInstall dependencies:
bun installConfigure environment:
cp .env.example .env
# edit .env if you need to override rate limits or the base URLConfiguration
All configuration is validated at startup via Zod schemas in src/config/server-config.ts.
Variable | Description | Default |
| Open Food Facts API base URL. Override for local testing against a mock server. |
|
| Product read rate limit (requests/min). Matches the 15 req/min/IP Open Food Facts documents for product reads. |
|
| Search rate limit (requests/min). |
|
| Taxonomy resolution rate limit (requests/min). A spent budget falls back to the offline sample rather than failing. |
|
| Transport: |
|
| HTTP server port. |
|
| Auth mode: |
|
| Log level ( |
|
| Log file directory (Node.js only). |
|
| Enable OpenTelemetry instrumentation. |
|
See .env.example for the full list of optional overrides.
Attribution: Open Food Facts data is released under the Open Database License (ODbL) 1.0. Downstream use must cite Open Food Facts.
Running the server
Local development
Build and run:
# One-time build bun run rebuild # Run the built server bun run start:stdio # or bun run start:httpRun checks and tests:
bun run devcheck # Lint, format, typecheck, security bun run test # Vitest test suite bun run lint:mcp # Validate MCP definitions against spec
Docker
docker build -t openfoodfacts-mcp-server .
docker run --rm -p 3010:3010 openfoodfacts-mcp-serverThe Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/openfoodfacts-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Directory | Purpose |
|
|
| Server-specific environment variable parsing and validation with Zod. |
| Tool definitions ( |
| Open Food Facts API client — HTTP, rate limiting, retry, field normalization. |
| Tag vocabulary service for |
| Unit and integration tests mirroring |
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storageRegister new tools via the barrel in
src/mcp-server/tools/definitions/index.tsWrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues and pull requests are welcome. Run checks and tests before submitting:
bun run devcheck
bun run testLicense
Apache-2.0 — see LICENSE for details.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables 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.Last updated51MIT
- AlicenseAqualityCmaintenanceAn MCP server for the Open Food Facts API that allows users to search, read, and contribute to a global food database. It enables looking up nutrition data by barcode or name and managing product information through natural language.Last updated10803MIT
- AlicenseAqualityDmaintenanceMCP server for Open Food Facts, enabling food product lookup by barcode, search, nutrition facts, allergen checks, and eco-scores without an API key.Last updated8MIT
- FlicenseBqualityCmaintenanceEnables AI assistants to access food product information from Open Food Facts, including nutritional analysis, product comparisons, recipe suggestions, and allergen checks.Last updated21
Related MCP Connectors
Open Beauty Facts MCP — Open Beauty Facts API (free, no auth, keyless).
Nutrition MCP — wraps Open Food Facts API (free, no auth)
Open Food Facts — collaborative food product database
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/cyanheads/openfoodfacts-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server