The server is distributed through PyPI for easy installation via pip
Used for running unit and functional tests of the MCP server
The server is implemented in Python and provides direct Python API access to the nutritional database
Provides SQL query access to the ANSES Ciqual French food composition database stored in SQLite format, enabling nutritional data queries for over 3,000 foods
ANSES Ciqual MCP Server
An MCP (Model Context Protocol) server providing SQL access to the ANSES Ciqual French food composition database. Query nutritional data for over 3,000 foods with full-text search support.
Features
- 🍎 Comprehensive Database: Access nutritional data for 3,185+ French foods
- 🔍 SQL Interface: Query using standard SQL with full flexibility
- 🌍 Bilingual Support: French and English food names
- 🔤 Fuzzy Search: Built-in full-text search with typo tolerance
- 📊 60+ Nutrients: Detailed composition including vitamins, minerals, macros, and more
- 🔄 Auto-Updates: Automatically refreshes data yearly from ANSES (checks on startup)
- 🔒 Read-Only: Safe queries with no risk of data modification
- 💾 Lightweight: ~10MB SQLite database with efficient indexing
Installation
Via pip
Via uvx (recommended)
From source
MCP Client Configuration
Claude Desktop
Add to your Claude Desktop configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Gemini CLI
Add to your Gemini CLI configuration file ~/.gemini/settings.json
:
Codex CLI
Add to your Codex CLI configuration file ~/.codex/config.toml
:
Usage
As an MCP Server
The server implements the Model Context Protocol and exposes a single query
function:
Direct Python Usage
API Documentation
MCP Function: query
The server exposes a single MCP function for executing SQL queries on the Ciqual database.
Function Signature
Parameters
sql
(string, required): The SQL query to execute on the database- Must be a SELECT or WITH query (read-only access)
- Supports all standard SQLite SQL syntax
- Can use JOIN, GROUP BY, ORDER BY, etc.
- Supports full-text search via the
foods_fts
table
Returns
list[dict]
: Array of result rows, where each row is a dictionary with column names as keys- Empty list if no results match the query
- Error dictionary with
"error"
key if query fails
Error Handling
The function returns an error dictionary in these cases:
- Database not initialized:
{"error": "Database not initialized..."}
- Non-SELECT query attempted:
{"error": "Only SELECT queries are allowed for safety."}
- SQL syntax error:
{"error": "SQL error: [details]"}
- Table not found:
{"error": "Table not found. Available tables: foods, nutrients, composition, foods_fts, food_groups"}
Example Usage in MCP Context
Response Example
Database Schema
Tables
foods
- Food items
alim_code
(INTEGER, PK): Unique food identifieralim_nom_fr
(TEXT): French namealim_nom_eng
(TEXT): English namealim_grp_code
(TEXT): Food group code
nutrients
- Nutrient definitions
const_code
(INTEGER, PK): Unique nutrient identifierconst_nom_fr
(TEXT): French nameconst_nom_eng
(TEXT): English nameunit
(TEXT): Measurement unit (g/100g, mg/100g, etc.)
composition
- Nutritional values
alim_code
(INTEGER): Food identifierconst_code
(INTEGER): Nutrient identifierteneur
(REAL): Value per 100gcode_confiance
(TEXT): Confidence level (A/B/C/D)
foods_fts
- Full-text search
Virtual table for fuzzy matching with French/English names
Common Nutrient Codes
Category | Code | Nutrient | Unit |
---|---|---|---|
Energy | 327 | Energy | kJ/100g |
328 | Energy | kcal/100g | |
Macros | 25000 | Protein | g/100g |
31000 | Carbohydrates | g/100g | |
40000 | Fat | g/100g | |
34100 | Fiber | g/100g | |
32000 | Sugars | g/100g | |
Minerals | 10110 | Sodium | mg/100g |
10200 | Calcium | mg/100g | |
10260 | Iron | mg/100g | |
10190 | Potassium | mg/100g | |
Vitamins | 55400 | Vitamin C | mg/100g |
56400 | Vitamin D | µg/100g | |
51330 | Vitamin B12 | µg/100g |
Example Queries
Basic Search
Nutritional Queries
Dietary Restrictions
Data Source
Data is sourced from the official ANSES Ciqual database:
- Website: https://ciqual.anses.fr/
- Data portal: https://www.data.gouv.fr/fr/datasets/table-de-composition-nutritionnelle-des-aliments-ciqual/
The database is automatically updated yearly when the server starts (data hasn't changed since 2020, so yearly updates are sufficient).
Requirements
- Python 3.9 or higher
- 50MB free disk space (for database)
- Internet connection (for initial data download)
License
MIT License - See LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development
Running Tests
Troubleshooting
Database not initializing
- Check internet connection
- Ensure write permissions to
~/.ciqual/
directory - Try manual initialization:
python -m ciqual_mcp.data_loader
XML parsing errors
- The tool handles malformed XML automatically with recovery mode
- If issues persist, delete
~/.ciqual/ciqual.db
and restart
Credits
Developed by Gael Debost as part of GPT Workbench, a multi-LLM interface for medical research developed by Ideagency.
Data provided by ANSES (Agence nationale de sécurité sanitaire de l'alimentation, de l'environnement et du travail).
Citation
If you use this tool in your research, please cite:
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Tools
Provides SQL access to the ANSES Ciqual French food composition database with nutritional data for over 3,000 foods. Supports full-text search and bilingual queries for comprehensive nutrition analysis.