Skip to main content
Glama
fastmcp-me

ANSES Ciqual MCP Server

by fastmcp-me

Add to Cursor Add to VS Code Add to Claude Add to ChatGPT Add to Codex Add to Gemini

ANSES Ciqual MCP Server

MCP Badge Tests PyPI version Python 3.10+ License: MIT MCP Protocol

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.

ANSES Ciqual Database

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

Related MCP server: ANSES Ciqual MCP Server

Installation

Via pip

pip install ciqual-mcp
uvx ciqual-mcp

From source

git clone https://github.com/zzgael/ciqual-mcp.git
cd ciqual-mcp
pip install -e .

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

{
  "mcpServers": {
    "ciqual": {
      "command": "uvx",
      "args": ["ciqual-mcp"]
    }
  }
}

Gemini CLI

Add to your Gemini CLI configuration file ~/.gemini/settings.json:

{
  "mcpServers": {
    "ciqual": {
      "command": "uvx",
      "args": ["ciqual-mcp"]
    }
  }
}

Codex CLI

Add to your Codex CLI configuration file ~/.codex/config.toml:

[mcp_servers.ciqual]
command = "uvx"
args = ["ciqual-mcp"]

Usage

As an MCP Server

The server implements the Model Context Protocol and exposes a single query function:

# Start the server standalone (for testing)
ciqual-mcp

Direct Python Usage

from ciqual_mcp.data_loader import initialize_database

# Initialize/update the database
initialize_database()

# Then use SQLite directly
import sqlite3
conn = sqlite3.connect("~/.ciqual/ciqual.db")
cursor = conn.execute("SELECT * FROM foods WHERE alim_nom_eng LIKE '%apple%'")

API Documentation

MCP Function: query

The server exposes a single MCP function for executing SQL queries on the Ciqual database.

Function Signature

async def query(sql: str) -> list[dict]

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

{
  "method": "query",
  "params": {
    "sql": "SELECT f.alim_nom_eng, n.const_nom_eng, c.teneur, n.unit FROM foods f JOIN composition c ON f.alim_code = c.alim_code JOIN nutrients n ON c.const_code = n.const_code WHERE f.alim_nom_eng LIKE '%apple%' AND n.const_code IN (328, 25000, 31000)"
  }
}

Response Example

[
  {
    "alim_nom_eng": "Apple, raw",
    "const_nom_eng": "Energy",
    "teneur": 52.0,
    "unit": "kcal/100g"
  },
  {
    "alim_nom_eng": "Apple, raw",
    "const_nom_eng": "Protein",
    "teneur": 0.3,
    "unit": "g/100g"
  }
]

Database Schema

Tables

foods - Food items

  • alim_code (INTEGER, PK): Unique food identifier

  • alim_nom_fr (TEXT): French name

  • alim_nom_eng (TEXT): English name

  • alim_grp_code (TEXT): Food group code

nutrients - Nutrient definitions

  • const_code (INTEGER, PK): Unique nutrient identifier

  • const_nom_fr (TEXT): French name

  • const_nom_eng (TEXT): English name

  • unit (TEXT): Measurement unit (g/100g, mg/100g, etc.)

composition - Nutritional values

  • alim_code (INTEGER): Food identifier

  • const_code (INTEGER): Nutrient identifier

  • teneur (REAL): Value per 100g

  • code_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

-- Find foods by name
SELECT * FROM foods WHERE alim_nom_eng LIKE '%orange%';

-- Fuzzy search (handles typos)
SELECT * FROM foods_fts WHERE foods_fts MATCH 'orang*';

Nutritional Queries

-- Get vitamin C content for oranges
SELECT f.alim_nom_eng, c.teneur as vitamin_c_mg
FROM foods f
JOIN composition c ON f.alim_code = c.alim_code
WHERE f.alim_nom_eng LIKE '%orange%' 
  AND c.const_code = 55400;

-- Find foods highest in protein
SELECT f.alim_nom_eng, c.teneur as protein_g
FROM foods f
JOIN composition c ON f.alim_code = c.alim_code
WHERE c.const_code = 25000
ORDER BY c.teneur DESC
LIMIT 10;

-- Compare macros for different foods
SELECT 
    f.alim_nom_eng as food,
    MAX(CASE WHEN c.const_code = 25000 THEN c.teneur END) as protein_g,
    MAX(CASE WHEN c.const_code = 31000 THEN c.teneur END) as carbs_g,
    MAX(CASE WHEN c.const_code = 40000 THEN c.teneur END) as fat_g,
    MAX(CASE WHEN c.const_code = 328 THEN c.teneur END) as calories_kcal
FROM foods f
JOIN composition c ON f.alim_code = c.alim_code
WHERE f.alim_nom_eng IN ('Apple, raw', 'Banana, raw', 'Orange, raw')
  AND c.const_code IN (25000, 31000, 40000, 328)
GROUP BY f.alim_code, f.alim_nom_eng;

Dietary Restrictions

-- Find low-sodium foods (<100mg/100g)
SELECT f.alim_nom_eng, c.teneur as sodium_mg
FROM foods f
JOIN composition c ON f.alim_code = c.alim_code
WHERE c.const_code = 10110 
  AND c.teneur < 100
ORDER BY c.teneur ASC;

-- High-fiber foods (>5g/100g)
SELECT f.alim_nom_eng, c.teneur as fiber_g
FROM foods f
JOIN composition c ON f.alim_code = c.alim_code
WHERE c.const_code = 34100 
  AND c.teneur > 5
ORDER BY c.teneur DESC;

Data Source

Data is sourced from the official ANSES Ciqual database:

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

# Install development dependencies
pip install -e .
pip install pytest pytest-asyncio

# Run unit tests
python -m pytest tests/test_server.py -v

# Run functional tests (requires database)
python -m pytest tests/test_functional.py -v

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:

@software{ciqual_mcp,
  title = {ANSES Ciqual MCP Server},
  author = {Gael Debost},
  year = {2025},
  url = {https://github.com/zzgael/ciqual-mcp}
}

Available Tools

1 tool
queryA

Execute SQL query on ANSES Ciqual French food composition database.

โš ๏ธ EFFICIENCY: Follow this 2-step workflow to minimize queries!

STEP 1 - SEARCH (one query): SELECT alim_code, alim_nom_fr FROM foods_fts WHERE foods_fts MATCH 'steak OR boeuf'; Note: FTS uses OR between words. For "steak sauce poivre", search "steak" first.

STEP 2 - GET ALL NUTRIENTS (one query with JOIN): SELECT f.alim_nom_fr, n.const_nom_fr, c.teneur, n.unit FROM foods f JOIN composition c ON f.alim_code = c.alim_code JOIN nutrients n ON c.const_code = n.const_code WHERE f.alim_code = ;

๐Ÿ›‘ STOP after finding a matching food! Don't keep searching with different terms.

COMPOUND DISHES (steak + sauce):

  • CIQUAL has individual ingredients, not full recipes

  • Search each component: "steak" then "sauce poivre"

  • Sum the calories (typical portions: meat 150g, sauce 30g)

QUICK CALORIE LOOKUP (const_code 328 = kcal/100g): SELECT f.alim_nom_fr, c.teneur as kcal_100g FROM foods f JOIN composition c ON f.alim_code = c.alim_code WHERE f.alim_code = AND c.const_code = 328;

KEY NUTRIENT CODES: Energy: 328 (kcal), 327 (kJ) Macros: 25000 (protein), 31000 (carbs), 40000 (fat), 34100 (fiber), 32000 (sugars) Minerals: 10110 (sodium), 10200 (calcium), 10260 (iron), 10190 (potassium), 10120 (magnesium) Vitamins: 55100 (vit C), 52100 (vit D), 56600 (vit B12), 53100 (vit E), 56700 (folates)

SCHEMA:

  • foods: alim_code (PK), alim_nom_fr, alim_nom_eng, alim_grp_code

  • nutrients: const_code (PK), const_nom_fr, const_nom_eng, unit

  • composition: alim_code, const_code, teneur (value per 100g), code_confiance

  • food_groups: grp_code, grp_nom_fr, grp_nom_eng

  • foods_fts: FTS5 virtual table for full-text search (alim_code, alim_nom_fr, alim_nom_eng)

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains FTS behavior (OR between words), how compound dishes are handled (not available as recipes), and includes a stop condition to avoid excessive searching. However, it does not explicitly state whether the tool is read-only or how errors are handled, but the read-only nature is strongly implied by the focus on SELECT queries.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is lengthy but well-structured with clear headings, emojis, and code blocks. Every section provides practical valueโ€”workflow steps, nutrient codes, schema documentation. While not minimal, the length is justified by the complexity of the domain; however, a few lines could be condensed without losing essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is comprehensive for a SQL query tool: it provides the database schema, key nutrient codes, example queries, and guidance on FTS behavior and compound dishes. With an output schema present, the description does not need to explain return values, but it still gives enough context to use the tool effectively without prior knowledge.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, with only the 'sql' parameter defined as a string. The description compensates by providing a complete schema, example queries, and nutrient codes, effectively explaining exactly what the sql parameter should contain and how to use it. This exceeds the baseline expectation for low schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Execute SQL query on ANSES Ciqual French food composition database.' It specifies the resource (ANSES Ciqual database) and the action (execute SQL query). Even without siblings, the purpose is unambiguous and well-defined.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides a detailed 2-step workflow with example queries, explicitly instructing users to first search, then retrieve nutrients, and to stop after finding a matching food. It also covers compound dishes and quick calorie lookups, giving clear usage context and guidance on how to structure queries efficiently.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 1 tool updatev0.2.0
    • First observedquery

TDQS

A4.6/5.0
Disambiguation5/5

With only one tool, there is no possibility of confusion between tools. The tool's purpose is clearly stated as executing SQL queries on the food composition database.

Naming Consistency5/5

The sole tool is named 'query', a simple and unambiguous name. While there is no pattern to compare, the lack of multiple tools means there is no inconsistency in naming conventions.

Tool Count3/5

The server exposes only one tool, which feels thin for the broad scope of a food composition database. Although the tool is powerful and can execute arbitrary SQL, a single tool places a heavy burden on the agent and lacks dedicated conveniences.

Completeness5/5

The generic SQL query tool can access all tables, perform joins, filters, and full-text searches, covering every potential query needed. The provided schema, examples, and nutrient codes ensure agents have enough information to retrieve any data, making the surface functionally complete.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides access to a comprehensive food database with 300,000+ items, enabling nutritional data lookups, food searches, and barcode scanning with all processing happening locally for privacy and speed.
    205
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    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.
    1
    9
    MIT
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Provides comprehensive food hierarchy and nutrition data through structured tools that enable searching foods, browsing categories, and retrieving detailed nutritional information from a MongoDB Atlas database.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides intelligent access to the USDA nutrition database through AI assistants, enabling users to search foods, compare nutritional content, find foods high in specific nutrients, and query authoritative nutrition data across 7,146+ food items through natural language.
    1
    -

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/fastmcp-me/ciqual-mcp'

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