mcpField
F
FoodEx2 Encoder

FoodEx2 Encoder

Remote
foodex2-encoder.foodnotes.orgHealth0Updated today

About FoodEx2 Encoder

FoodEx2 Encoder is a library and stdio MCP server that converts English food descriptions into EFSA FoodEx2 codes, including base terms, facets, and labelled free text. It is for workflows that need FoodEx2 coding; results should be checked, especially where catalogue terms are broader than the description.

Key features

  1. 01Encode English food descriptions as FoodEx2 codes
  2. 02Return base term, facets, and labelled free text
  3. 03Use catalogue search and model-assisted selection
  4. 04Apply EFSA coding rules and facet checks
  5. 05Offer CLI encoding and traversal commands

Use cases

  1. 01Assign FoodEx2 codes to food descriptions
  2. 02Represent details not captured by a code as free text
  3. 03Inspect catalogue traversal while debugging
  4. 04Run encoding evaluations against a gold set

MCP support

The stdio MCP server exposes an `encode` tool that returns the FoodEx2 code, base term, facets, free text, fit, method, and explanation. Catalogue lookup, decoding, validation, and EFSA guidance are handled by the separate FoodEx2 Atlas MCP.

Configuration

Remote servers need no local install. Pick your client, then copy the config or install in one click.

Endpointhttps://foodex2-encoder.foodnotes.org/mcp
Copy install command
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

Run commands in a terminal; paste JSON into the client’s MCP config and restart. Servers that need sign-in will prompt on first connect.

Tools

Details

From the project README

foodex2-encoder

Library and stdio MCP server that turns an English food description into an EFSA FoodEx2 code (MTX catalogue): base term, facet descriptors, and labelled free text for what the code cannot express.

This repository is the core. A hosted version is available at https://foodex2-encoder.foodnotes.org/ .

Limitations

Check every code before you use it. In particular:

  • English input only, including foreign food names commonly used in English.
  • Group names the catalogue splits are kept as free text. When a description uses a name that the catalogue only has as several separate terms, that part goes to free text instead of the code. For example, canned shellfish is coded as Canned seafood with source-commodity=shellfish in free text, rather than Canned seafood made from crustaceans and molluscs. The code is not wrong, but it is broader than the description: Canned seafood also covers other marine animals, such as sea urchins.

What you need

  • Node.js 20+
  • Python 3 (one-time catalogue build from the vendored EFSA .ecf)
  • An OpenAI-compatible model endpoint and API key (OpenRouter is the default)

Install

git clone https://github.com/FoodNotes-org/foodex2-encoder.git
cd foodex2-encoder
git submodule update --init
npm install
npm run build:catalogue
npm run build:embeddings

data/ is generated locally (~25 MB) and is gitignored. Rebuild after updating the vendor/efsa-catalogues submodule.

The coding rules in src/rules/ (EFSA business rules, facet cardinality, our own checks) are shared with the FoodEx2 Atlas validator. Their data comes from rules/cardinality.yaml, rules/conflicts.yaml and vendor/efsa-business-rules/; after editing those, regenerate the committed src/rules/rules-data.json with npm run build:rules. Sources, licence and limits are in rules/efsa-business-rules.md.

Model endpoint

Copy .env (or export the same variables). OpenRouter needs only a key:

FOODEX2_LLM_API_KEY=sk-or-…          # or OPENROUTER_API_KEY
# optional:
# FOODEX2_LLM_BASE_URL=https://openrouter.ai/api/v1
# FOODEX2_MODEL=openai/gpt-5.4

Any other OpenAI-compatible endpoint works the same way (FOODEX2_LLM_BASE_URL, FOODEX2_LLM_API_KEY, FOODEX2_MODEL). The server calls that endpoint for classify / select / residual steps; your chat client’s subscription is separate.

Try it (CLI)

npm run cli -- encode "orange juice"
npm run cli -- encode "fried rice with chicken"
npm run cli -- traverse "eggplant"    # walk only (debug)

Lexical hits return in about a second. Descriptions that need a catalogue walk typically take 15–25 seconds.

Try it (MCP stdio)

npm run server

Point a client at that process. Cursor example (mcp.json):

{
  "mcpServers": {
    "foodex2-encoder": {
      "command": "npx",
      "args": ["tsx", "/ABS/PATH/TO/foodex2-encoder/src/server.ts"],
      "env": {
        "FOODEX2_LLM_API_KEY": "sk-or-…"
      }
    }
  }
}

Tool: encode. It returns the code, base term, facets, free text, fit, method, and a short explanation. Catalogue lookups, decoding, validation and EFSA guidance are in the free FoodEx2 Atlas MCP.

Tests and eval

npm test                 # unit tests (no model)
npm run lexical-eval     # lexical base-term cases (no model)
npm run encode-eval      # end-to-end gold set (needs a model key)

eval/encode-base-term.yaml is a small, focused regression set: one realistic case per capability (catalogue synonym, model synonym, named dish, restraint, and so on). Gold rules can require or forbid facets and free-text fragments; expected may list several acceptable base codes (any-of).

npm run encode-eval records the model and MTX version, and on a complete run writes eval/results/encode-base-term.json for publishing or sharing with the public core repo. Always cite the model named in that file’s _provenance.

Layout

src/encode/     lexical → traverse → select → residuals
src/search/     lexical + embedding retrieval
src/server.ts   stdio MCP
src/tools.ts    tool handlers (shared surface for a future Worker wrapper)
data/           generated catalogue + embeddings (local)
eval/           gold cases + results artifact
vendor/         EFSA catalogues (submodule)

Licence

MIT — see LICENSE. Copyright (c) 2026 e-accent BV.

That grant covers this software. EFSA catalogue files under vendor/efsa-catalogues/ (and generated data/ derived from them) remain subject to EFSA’s terms.

Attribution (eval inputs)

Some food names used as evaluation cases under eval/ were drawn from national food composition databases. We use food names only (not nutrient values). Those databases remain under their publishers’ terms:

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.