@pipeworx/codex-contaminants
Connect: https://gateway.pipeworx.io/codex-contaminants/mcp · Install: one-click buttons
Tools: 2
Codex Alimentarius CXS 193-1995 maximum levels for contaminants and toxins in food — lead, cadmium, arsenic, mercury, methylmercury, tin, aflatoxins, ochratoxin A, patulin, melamine, hydrocyanic acid — by commodity.
59 maximum levels, 2015 edition. Both of those numbers are limitations, and both are stated on every response rather than left in this file.
Read this before using a value
Edition. Codex publishes CXS 193 only as a document, and the current text is
behind an authenticated FAO workspace. This pack carries the newest public
official edition, 2015 (Amended in 2010, 2012, 2013, 2014, 2015). The standard
has been amended in 2016, 2017, 2018, 2019, 2021, 2022, 2023, and at CAC47 (Nov
2024) and CAC48 (Nov 2025). Those amendments added maximum levels — lead in
cinnamon (2.5 mg/kg) and dried culinary herbs (2.0 mg/kg) among them.
Coverage. 59 entries from the Schedule I tables. Rows whose commodity name wraps across table lines were dropped rather than risk labelling a legal limit with a sentence fragment like “exception of berries”.
Together: a miss is not a finding that no limit exists. The not-found path says so in words, because “no maximum level” reads as permission.
Every value carries the source PDF page, so any figure can be checked in one step against https://www.fao.org/input/download/standards/17/CXS_193e_2015.pdf.
Tools
contaminants_max_levels({contaminant, commodity?})— Codex MLs for a contaminant, optionally narrowed to a food.contaminants_for_commodity({commodity})— every contaminant limit that applies to one food.
Extraction, and what went wrong four times
extract.py is the extractor. It is column-band driven for a reason: each of
these was a real, silent failure during the build, and the tests pin all of them.
- Character offsets do not work. The ML column sits at character 36 on one page and 29 on the next, so fixed slicing attaches a real limit to a truncated commodity name.
- Reading any number on the page swept in, under LEAD,
73(a JECFA meeting number),25(the withdrawn PTWI in µg/kg body weight) and3(3 mmHg of blood pressure) as maximum levels. Fixed by taking the ML column’s x-band from each page’s table header and accepting only numbers inside it. - Units differ per contaminant — aflatoxins are µg/kg, metals mg/kg. The unit is read from the header too. Hardcoding mg/kg made aflatoxin M1 in milk read 0.5 mg/kg instead of 0.5 µg/kg: wrong by 1000×.
- Section headings must come from the document, not memory. The standard
says
DEOXYNIVALENOL (DON), and a 3-letter headingTINis easy to filter out by accident — when it was, tin’s canned-meat limits (50 mg/kg) were filed under methylmercury.
To refresh: point extract.py at a newer PDF, re-run, and read the output before
shipping it. The tables are small enough that a human check pass is feasible, and
for legal limits it is not optional.
Tools
- contaminants_max_levels — Codex Alimentarius maximum levels (MLs) for a contaminant in food — lead, cadmium, arsenic, mercury, methylmercury, tin, aflatoxins, ochratoxin A, patulin, melamine, hydrocyanic acid. Returns each com
- contaminants_for_commodity — Every Codex maximum level that applies to one food — “which contaminant limits apply to rice”, “what are the Codex limits for milk”. Returns each contaminant with its maximum level and unit for that c
Tools
-
contaminants_for_commodity— Every Codex maximum level that applies to one food — which contaminant limits apply to rice , what are the Codex limits for milk . Returns each contaminant with its maximum level and unit for that com -
contaminants_max_levels— Codex Alimentarius maximum levels (MLs) for a contaminant in food — lead, cadmium, arsenic, mercury, methylmercury, tin, aflatoxins, ochratoxin A, patulin, melamine, hydrocyanic acid. Returns each com