Skip to main content
Glama
saiprasadthalluri

Open Food Facts MCP Server

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.

How to Run

Prerequisites

Ensure you have the dependencies installed:

pip install -r requirements.txt

Running the Server

You can run the server directly (it listens on stdio):

python server.py

Note: 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.py

You 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.py

This will open a browser window where you can interactively search for products and look up barcodes without writing scripts.

-
security - not tested
F
license - not found
-
quality - not tested

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/saiprasadthalluri/openfoods_mcp'

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