openfoodfacts-mcp-server

noot-app/openfoodfacts-mcp-server

3.3

If you are the rightful owner of openfoodfacts-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The OpenFoodFacts MCP Server provides fast access to the Open Food Facts dataset using DuckDB and parquet, supporting both local and remote deployment.

Tools
2
Resources
0
Prompts
0

OpenFoodFacts MCP Server 🔌

lint test build docker

A MCP (Model Context Protocol) server that provides access to the Open Food Facts dataset using DuckDB and parquet for fast queries. Supports both local Claude Desktop integration and remote deployment with authentication.

logo

Usage 💻

Deploy on Railway

This MCP server can operate in two distinct modes:

1. STDIO Mode (Local Claude Desktop Integration)

  • Use case: Local development and Claude Desktop integration
  • Command: ./openfoodfacts-mcp-server --stdio
  • Transport: stdio pipes
  • Authentication: None required
  • Perfect for: Claude Desktop, local development, testing

2. HTTP Mode (Remote Deployment)

  • Use case: Remote MCP server accessible over the internet
  • Command: ./openfoodfacts-mcp-server (default mode)
  • Transport: HTTP with JSON-RPC 2.0
  • Authentication: Bearer token required (except /health endpoint)
  • Perfect for: Shared deployments, cloud hosting, team access, mcp as a service

Demo 📹

https://github.com/user-attachments/assets/e742c4d3-a36d-46af-97b6-dcd41180b5aa

How It Works 💡

This MCP server downloads and caches the Open Food Facts Parquet dataset locally, then uses DuckDB for fast product searches. It provides two main tools:

  • search_products_by_brand_and_name: Search products by name and brand
  • search_by_barcode: Find product by barcode (UPC/EAN)
  • search_products_by_brand_and_name_simplified: A lighter version of the search that returns fewer fields to save on token usage

The server automatically manages dataset updates, uses file locking for concurrent safety, and provides structured JSON logging.

Local Setup for Claude Desktop (STDIO Mode)

This setup uses STDIO mode for local Claude Desktop integration.

1. Build the Binary

script/build --simple

2. Fetch the Database

openfoodfacts-mcp-server --fetch-db

3. Configure Claude Desktop

Add this to your Claude Desktop MCP settings (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "openfoodfacts": {
      "command": "/path/to/openfoodfacts-mcp-server",
      "args": ["--stdio"],
      "env": {
        "OPENFOODFACTS_MCP_TOKEN": "your-secret-token",
        "DATA_DIR": "/full/path/to/openfoodfacts-mcp-server/data",
        "ENV": "development"
      }
    }
  }
}

3. Try it Out

Restart Claude Desktop. The mcp server will automatically start and be ready for food product queries.

Remote Deployment (HTTP Mode)

This setup uses HTTP mode for remote deployment with authentication.

Environment Variables

For production deployment (HTTP mode), configure these environment variables:

# Required: Authentication
OPENFOODFACTS_MCP_TOKEN=your-production-secret-token

# Optional: Data management
DATA_DIR=./data
PARQUET_URL=https://huggingface.co/datasets/openfoodfacts/product-database/resolve/main/product-database.parquet
REFRESH_INTERVAL_SECONDS=86400

# Optional: Server configuration  
PORT=8080
ENV=production

# Optional: DuckDB Performance Tuning
DUCKDB_MEMORY_LIMIT=4GB                    # Memory limit (e.g. 2GB, 4GB, 8GB, 16GB)
DUCKDB_THREADS=4                           # Number of threads (1-16 typically)
DUCKDB_CHECKPOINT_THRESHOLD=1GB            # When to write to disk (e.g. 512MB, 1GB, 2GB)
DUCKDB_PRESERVE_INSERTION_ORDER=true       # Set to false for large datasets to reduce memory

Running in HTTP Mode

For remote deployment, run without the --stdio flag (HTTP mode is the default):

./openfoodfacts-mcp-server

This will start an HTTP server on the configured port (default 8080) with:

  • /health endpoint (no authentication required)
  • /mcp endpoint (Bearer token authentication required)

Quick Reference

Command Options

ModeCommandUse CaseAuthenticationTransport
STDIO./openfoodfacts-mcp-server --stdioClaude Desktop, local developmentNonestdio pipes
HTTP./openfoodfacts-mcp-serverRemote deployment, shared accessBearer tokenHTTP/JSON-RPC
Fetch DB./openfoodfacts-mcp-server --fetch-dbDownload/update dataset locallyNoneN/A

Environment Variables Reference

VariableRequiredDefaultDescription
OPENFOODFACTS_MCP_TOKENYes (HTTP mode)-Bearer token for authentication
DATA_DIRNo./dataDirectory for dataset storage
PORTNo8080HTTP server port (HTTP mode only)
ENVNoproductionEnvironment (development/production)
DUCKDB_MEMORY_LIMITNo4GBDuckDB memory limit (2GB, 4GB, 8GB, etc.)
DUCKDB_THREADSNo4Number of DuckDB threads (1-16)
DUCKDB_CHECKPOINT_THRESHOLDNo1GBCheckpoint threshold (512MB, 1GB, 2GB)
DUCKDB_PRESERVE_INSERTION_ORDERNotruePreserve insertion order (false for better performance)

HTTP Endpoints (HTTP Mode Only)

EndpointAuthenticationDescription
/healthNoneHealth check endpoint
/mcpBearer tokenMCP JSON-RPC 2.0 endpoint

STDIO Mode (Local Development)

A cool tip for developing locally, you can actually do this and it will return a result from the MCP server:

echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "search_products_by_brand_and_name_simplified", "arguments": {"name": "cream soda", "brand": "olipop", "limit": 1}}}' | go run cmd/openfoodfacts-mcp-server/main.go --stdio