Data source: Open Food Facts
Overview
Nutrition Data wraps Open Food Facts, handling authentication, pagination, and rate limits for you. This tutorial covers all 3 tools with working code examples you can copy and run.
Prerequisites
- Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
- Choose your integration method: MCP protocol or REST API.
Connect via MCP
Add to your MCP client config (Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"gnist-nutrition": {
"url": "https://context.gnist.ai/mcp/nutrition/",
"headers": {
"Gnist-API-Key": "YOUR_API_KEY"
}
}
}
}
Tools (3)
search_foods
Search food products by name, brand, or description and get nutritional information. Args: query: Search terms for food products (e.g. "granola", "orange juice", "Nutella"). limit: Number of results to return (1–50, default 10). Returns: Dictionary with 'count' and 'products' list. Each product has name, barcode, brands, categories, image_url, nutriscore_grade, and nutrients (per 100g: energy_kcal, fat, saturated_fat, carbohydrates, sugars, fiber, proteins, salt, sodium).
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | required | Search terms for food products (e.g. "granola", "orange juice", "Nutella"). Searches product names, brands, and categories. |
limit | integer | optional | Number of results to return (1–50, default 10). (default: 10) |
curl -X POST "https://context.gnist.ai/mcp/nutrition/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_foods", "arguments": {"query": "granola"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/nutrition/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'query': 'granola'}, 'name': 'search_foods'}},
)
print(resp.json())
get_product
Look up a specific food product by its barcode and get full nutritional details. Args: barcode: Product barcode (EAN/UPC, e.g. "3017620422003" for Nutella). Returns: Product record with name, barcode, brands, categories, image_url, nutriscore_grade, and nutrients (per 100g).
| Parameter | Type | Required | Description |
|---|---|---|---|
barcode | string | required | Product barcode (EAN/UPC, e.g. "3017620422003" for Nutella, "5449000000996" for Coca-Cola). |
curl -X POST "https://context.gnist.ai/mcp/nutrition/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_product", "arguments": {"barcode": "3017620422003"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/nutrition/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'barcode': '3017620422003'}, 'name': 'get_product'}},
)
print(resp.json())
report_feedback
Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.
| Parameter | Type | Required | Description |
|---|---|---|---|
feedback | string | required | |
feedback_type | string | optional | (default: general) |
curl -X POST "https://context.gnist.ai/mcp/nutrition/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/nutrition/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())
Common Patterns
Use
search_foods to find items, then get_product to get full details. This two-step pattern is common for exploring data before drilling down.Several tools support
limit, offset, or page parameters. Start with small limits during development, then increase for production queries.FAQ
What data does Nutrition Data provide?
Nutritional information for foods — calories, macros, vitamins. Search by name or barcode. It exposes 3 tools: search_foods, get_product, report_feedback.
What do I need to get started?
A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.
What format does the Nutrition Data API return?
JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.