FoodEx2 Encoder

org.foodnotes由 foodnotes.org 发布官方发布者v1.0.0更新于 Oct 30, 2026

Turn an English food description into an EFSA FoodEx2 code.

已验证Streamable HTTP可网页运行数据与分析AI 与机器学习

概览

AI 生成的概览

远程 MCP 服务器,把英文食品描述转换为 EFSA FoodEx2 编码,并给出基础术语、面描述符和自由文本。

可以做什么
  • 把食品描述编码为 FoodEx2 代码,返回代码、基础术语、面描述符、自由文本、匹配度、方法和简短说明。
  • 通过词法匹配和向量检索查找目录术语,再遍历 MTX 目录选定基础术语。
  • 把代码无法表达的内容(例如目录中拆分为多个术语的组名)记录为带标签的自由文本。
适用场景
当你需要为食品描述取得 FoodEx2 编码时使用,例如准备 EFSA 风格的膳食暴露或食品分类数据。它适合逐条快速编码,而不是批量浏览、解码或校验目录。
运行要求
通过 streamable HTTP 访问的远程端点,需 OAuth 登录;托管版本未声明本地安装或环境变量。自行部署的核心需要 Node.js 20+、用于一次性构建目录的 Python 3,以及带 API 密钥(如 FOODEX2_LLM_API_KEY)的 OpenAI 兼容模型端点。
安装前请注意
编码结果只是近似:README 要求使用前逐一核对,部分描述会被编得比原描述更宽泛,其余部分留在自由文本中。输入仅支持英文。自行部署版本会把描述发送给第三方模型端点,费用与聊天客户端订阅分开计算。

安装

在 SourceWeft 中

  1. 打开 控制台中的 FoodEx2 Encoder,将其添加到工作区。
  2. 连接 所需的 凭据。它们会被私密存储,绝不会在公开页面上展示。
  3. 为需要使用其工具的对话启用该服务。

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/org.foodnotes%2Ffoodex2-encoder/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。 客户端会在首次连接时完成 OAuth 登录。

{
  "mcpServers": {
    "foodex2-encoder": {
      "type": "http",
      "url": "https://foodex2-encoder.foodnotes.org/mcp"
    }
  }
}

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

bash
git clone https://github.com/FoodNotes-org/foodex2-encoder.gitcd foodex2-encodergit submodule update --initnpm installnpm run build:cataloguenpm 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:

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

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)

bash
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)

bash
npm run server

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

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

bash
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 → residualssrc/search/     lexical + embedding retrievalsrc/server.ts   stdio MCPsrc/tools.ts    tool handlers (shared surface for a future Worker wrapper)data/           generated catalogue + embeddings (local)eval/           gold cases + results artifactvendor/         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:

来源:README.md,提交 1bf05fe

工具

0
该服务器需要登录,因此 SourceWeft 无法在没有账号的情况下读取其工具,也未收录。已连接账号所能看到的内容可能因账号及其权限而异。

版本历史

1
  1. v1.0.0最新Oct 16, 2026

评分

已满足适用检查项的 85%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通必需25 分
  • 已声明认证方式必需10 分
  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分