@cyanheads/openfoodfacts-mcp-server 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/AGENTS.md +335 -0
  2. package/CLAUDE.md +335 -0
  3. package/Dockerfile +99 -0
  4. package/LICENSE +201 -0
  5. package/README.md +290 -0
  6. package/changelog/0.1.x/0.1.0.md +15 -0
  7. package/changelog/template.md +127 -0
  8. package/dist/config/server-config.d.ts +15 -0
  9. package/dist/config/server-config.d.ts.map +1 -0
  10. package/dist/config/server-config.js +35 -0
  11. package/dist/config/server-config.js.map +1 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +23 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/mcp-server/tools/definitions/browse-taxonomy.tool.d.ts +27 -0
  17. package/dist/mcp-server/tools/definitions/browse-taxonomy.tool.d.ts.map +1 -0
  18. package/dist/mcp-server/tools/definitions/browse-taxonomy.tool.js +91 -0
  19. package/dist/mcp-server/tools/definitions/browse-taxonomy.tool.js.map +1 -0
  20. package/dist/mcp-server/tools/definitions/compare-products.tool.d.ts +36 -0
  21. package/dist/mcp-server/tools/definitions/compare-products.tool.d.ts.map +1 -0
  22. package/dist/mcp-server/tools/definitions/compare-products.tool.js +228 -0
  23. package/dist/mcp-server/tools/definitions/compare-products.tool.js.map +1 -0
  24. package/dist/mcp-server/tools/definitions/get-product.tool.d.ts +83 -0
  25. package/dist/mcp-server/tools/definitions/get-product.tool.d.ts.map +1 -0
  26. package/dist/mcp-server/tools/definitions/get-product.tool.js +420 -0
  27. package/dist/mcp-server/tools/definitions/get-product.tool.js.map +1 -0
  28. package/dist/mcp-server/tools/definitions/index.d.ts +175 -0
  29. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  30. package/dist/mcp-server/tools/definitions/index.js +15 -0
  31. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  32. package/dist/mcp-server/tools/definitions/search-products.tool.d.ts +54 -0
  33. package/dist/mcp-server/tools/definitions/search-products.tool.d.ts.map +1 -0
  34. package/dist/mcp-server/tools/definitions/search-products.tool.js +219 -0
  35. package/dist/mcp-server/tools/definitions/search-products.tool.js.map +1 -0
  36. package/dist/services/openfoodfacts/openfoodfacts-service.d.ts +54 -0
  37. package/dist/services/openfoodfacts/openfoodfacts-service.d.ts.map +1 -0
  38. package/dist/services/openfoodfacts/openfoodfacts-service.js +308 -0
  39. package/dist/services/openfoodfacts/openfoodfacts-service.js.map +1 -0
  40. package/dist/services/openfoodfacts/types.d.ts +89 -0
  41. package/dist/services/openfoodfacts/types.d.ts.map +1 -0
  42. package/dist/services/openfoodfacts/types.js +7 -0
  43. package/dist/services/openfoodfacts/types.js.map +1 -0
  44. package/dist/services/taxonomy/taxonomy-service.d.ts +24 -0
  45. package/dist/services/taxonomy/taxonomy-service.d.ts.map +1 -0
  46. package/dist/services/taxonomy/taxonomy-service.js +271 -0
  47. package/dist/services/taxonomy/taxonomy-service.js.map +1 -0
  48. package/package.json +102 -0
  49. package/server.json +141 -0
package/README.md ADDED
@@ -0,0 +1,290 @@
1
+ <div align="center">
2
+ <h1>@cyanheads/openfoodfacts-mcp-server</h1>
3
+ <p><b>Look up food products by barcode, search by ingredient or nutrition filter, compare products side-by-side, and browse the canonical tag vocabulary via MCP. STDIO or Streamable HTTP.</b>
4
+ <div>4 Tools</div>
5
+ </p>
6
+ </div>
7
+
8
+ <div align="center">
9
+
10
+ [![Version](https://img.shields.io/badge/Version-0.1.0-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/openfoodfacts-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/openfoodfacts-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/openfoodfacts-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^5.9.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0-blueviolet.svg?style=flat-square)](https://bun.sh/)
11
+
12
+ </div>
13
+
14
+ <div align="center">
15
+
16
+ [![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/openfoodfacts-mcp-server/releases/latest/download/openfoodfacts-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=openfoodfacts-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvb3BlbmZvb2RmYWN0cy1tY3Atc2VydmVyIl19) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22openfoodfacts-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fopenfoodfacts-mcp-server%22%5D%7D)
17
+
18
+ [![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
19
+
20
+ </div>
21
+
22
+ ---
23
+
24
+ ## Tools
25
+
26
+ Four tools for working with [Open Food Facts](https://world.openfoodfacts.org/) — a free, crowd-sourced database of 3M+ packaged food products:
27
+
28
+ | Tool | Description |
29
+ |:-----|:------------|
30
+ | `off_get_product` | Fetch a packaged food product by barcode. Returns name, brand, quantity, ingredients, allergens, additives, Nutri-Score, NOVA group, Green-Score, nutrition per 100g/serving, categories, labels, and data completeness. |
31
+ | `off_search_products` | Search by text query and/or structured tag filters (category, brand, label, Nutri-Score grade, NOVA group, country). Returns summary rows with barcodes for follow-up lookups. |
32
+ | `off_compare_products` | Side-by-side nutrition and scoring comparison for 2–10 products by barcode. Returns a normalized table of energy, macros, salt, Nutri-Score, NOVA, and Green-Score. |
33
+ | `off_browse_taxonomy` | Browse and search the canonical tag vocabulary (categories, labels, allergens, additives, countries, NOVA groups, Nutri-Score grades) for use as filter values in `off_search_products`. |
34
+
35
+ ### `off_get_product`
36
+
37
+ Fetch a packaged food product by barcode (EAN-13 or UPC).
38
+
39
+ - Accepts 8–14 digit barcodes (EAN-13, EAN-8, UPC-A, UPC-E)
40
+ - Returns ingredients (raw text and parsed list with percent estimates, vegan/vegetarian flags), all 14 major allergens as tag IDs, E-number additives, Nutri-Score a–e, NOVA 1–4, Green-Score/Eco-Score, full nutriments per 100g and per serving, categories/labels/packaging/origins as canonical tag IDs, front image URL, and data completeness score (0–1)
41
+ - Optional `fields` parameter restricts the response to a subset (e.g., scores only, or nutrition only)
42
+ - Open Food Facts is crowd-sourced — a missing field means "not yet entered by contributors," not that the attribute is absent from the actual product
43
+ - `found: false` means no contributor has recorded this barcode yet — not a product defect
44
+
45
+ ---
46
+
47
+ ### `off_search_products`
48
+
49
+ Search Open Food Facts by text and/or structured tag filters.
50
+
51
+ - Full-text search across product names, brands, and ingredients
52
+ - Structured filters: `categories_tag`, `brands_tag`, `labels_tag`, `nutrition_grade` (a–e), `nova_group` (1–4), `countries_tag`
53
+ - All filter values are canonical tag IDs — use `off_browse_taxonomy` to resolve human terms (e.g., "organic" → `en:organic`)
54
+ - Pagination via `page` (1-based) and `page_size` (1–50, default 20); response includes `total` count for computing total pages
55
+ - Returns summary rows (barcode, name, brand, Nutri-Score, NOVA, categories) — use `off_get_product` for full label data
56
+ - Result counts reflect contributed products, not total products on the market
57
+ - Search rate-limited to ~10 requests/min by the Open Food Facts API
58
+
59
+ ---
60
+
61
+ ### `off_compare_products`
62
+
63
+ Side-by-side nutrition and scoring comparison for 2–10 barcodes.
64
+
65
+ - Fetches all products in parallel
66
+ - Returns a normalized comparison table: energy (kcal/100g), fat, saturated fat, sugars, salt, protein, fiber, Nutri-Score, NOVA group, and Green-Score
67
+ - Missing nutrition data is preserved as `null` — comparisons are not imputed or estimated
68
+ - `not_found` list identifies barcodes with no contributor record (partial results are not an error)
69
+ - For batches of 5+ products, the comparison table is registered as a canvas dataframe for downstream SQL queries (`secedgar_dataframe_query`-style analytics)
70
+
71
+ ---
72
+
73
+ ### `off_browse_taxonomy`
74
+
75
+ Browse the canonical Open Food Facts tag vocabulary before building `off_search_products` filters.
76
+
77
+ - Facets: `categories`, `labels`, `allergens`, `additives`, `countries`, `nova_groups`, `nutrition_grades`
78
+ - Optional `search` parameter: case-insensitive substring match against tag ID or display name (e.g., `"gluten"` → `en:gluten`, `en:no-gluten`, `en:no-added-gluten`)
79
+ - Taxonomy is embedded (not fetched live) because the OFF taxonomy API is unavailable to anonymous bot clients at current traffic levels
80
+ - Categories facet has 200K+ entries — always include a `search` term when browsing categories
81
+ - `limit` controls results returned (1–100, default 20)
82
+
83
+ ---
84
+
85
+ ## Features
86
+
87
+ Built on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):
88
+
89
+ - Declarative tool definitions — single file per tool, framework handles registration and validation
90
+ - Unified error handling — handlers throw, framework catches, classifies, and formats
91
+ - Pluggable auth: `none`, `jwt`, `oauth`
92
+ - Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`
93
+ - Structured logging with optional OpenTelemetry tracing
94
+ - STDIO and Streamable HTTP transports
95
+
96
+ Open Food Facts-specific:
97
+
98
+ - No API key required — the identifying `User-Agent` header (required by OFF terms) is baked into the service layer
99
+ - Token-bucket rate limiting per endpoint class: product reads (~100/min), search (~10/min)
100
+ - Automatic retry (3 attempts, 500ms base) with HTML error page detection for 503 during high load
101
+ - Nutriments normalized from raw hyphenated keys (`energy-kcal_100g`) to underscore form — only the `_100g` and `_serving` variants are returned
102
+ - Embedded tag taxonomy for `off_browse_taxonomy` — curated 200+ category subset, full allergen/label/additive vocabularies
103
+
104
+ Agent-friendly output:
105
+
106
+ - `found` field on every product response — explicit `false` when a barcode has no contributor record, not a thrown error
107
+ - Missing fields signal incomplete crowd-sourced data, not product attribute absence — surfaced in descriptions and format output
108
+ - Computed scores (Nutri-Score, NOVA, Green-Score) returned as-is with regional caveat notes — not interpreted or normalized to health claims
109
+ - `not_found` list in `off_compare_products` allows partial batch comparisons without request failure
110
+
111
+ ## Getting started
112
+
113
+ No API key is required. Add the following to your MCP client configuration file.
114
+
115
+ ```json
116
+ {
117
+ "mcpServers": {
118
+ "openfoodfacts": {
119
+ "type": "stdio",
120
+ "command": "bunx",
121
+ "args": ["@cyanheads/openfoodfacts-mcp-server@latest"],
122
+ "env": {
123
+ "MCP_TRANSPORT_TYPE": "stdio",
124
+ "MCP_LOG_LEVEL": "info"
125
+ }
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ Or with npx (no Bun required):
132
+
133
+ ```json
134
+ {
135
+ "mcpServers": {
136
+ "openfoodfacts": {
137
+ "type": "stdio",
138
+ "command": "npx",
139
+ "args": ["-y", "@cyanheads/openfoodfacts-mcp-server@latest"],
140
+ "env": {
141
+ "MCP_TRANSPORT_TYPE": "stdio",
142
+ "MCP_LOG_LEVEL": "info"
143
+ }
144
+ }
145
+ }
146
+ }
147
+ ```
148
+
149
+ Or with Docker:
150
+
151
+ ```json
152
+ {
153
+ "mcpServers": {
154
+ "openfoodfacts": {
155
+ "type": "stdio",
156
+ "command": "docker",
157
+ "args": [
158
+ "run", "-i", "--rm",
159
+ "-e", "MCP_TRANSPORT_TYPE=stdio",
160
+ "ghcr.io/cyanheads/openfoodfacts-mcp-server:latest"
161
+ ]
162
+ }
163
+ }
164
+ }
165
+ ```
166
+
167
+ For Streamable HTTP, set the transport and start the server:
168
+
169
+ ```sh
170
+ MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
171
+ # Server listens at http://localhost:3010/mcp
172
+ ```
173
+
174
+ ### Prerequisites
175
+
176
+ - [Bun v1.3.0](https://bun.sh/) or higher (or Node.js v24+).
177
+ - No API key needed. The server sends an identifying `User-Agent` to comply with Open Food Facts' terms of service — this is baked in and requires no configuration.
178
+
179
+ ### Installation
180
+
181
+ 1. **Clone the repository:**
182
+
183
+ ```sh
184
+ git clone https://github.com/cyanheads/openfoodfacts-mcp-server.git
185
+ ```
186
+
187
+ 2. **Navigate into the directory:**
188
+
189
+ ```sh
190
+ cd openfoodfacts-mcp-server
191
+ ```
192
+
193
+ 3. **Install dependencies:**
194
+
195
+ ```sh
196
+ bun install
197
+ ```
198
+
199
+ 4. **Configure environment:**
200
+
201
+ ```sh
202
+ cp .env.example .env
203
+ # edit .env if you need to override rate limits or the base URL
204
+ ```
205
+
206
+ ## Configuration
207
+
208
+ All configuration is validated at startup via Zod schemas in `src/config/server-config.ts`.
209
+
210
+ | Variable | Description | Default |
211
+ |:---------|:------------|:--------|
212
+ | `OFF_BASE_URL` | Open Food Facts API base URL. Override for local testing against a mock server. | `https://world.openfoodfacts.org` |
213
+ | `OFF_RATE_LIMIT_PRODUCT` | Product read rate limit (requests/min). | `100` |
214
+ | `OFF_RATE_LIMIT_SEARCH` | Search rate limit (requests/min). | `10` |
215
+ | `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
216
+ | `MCP_HTTP_PORT` | HTTP server port. | `3010` |
217
+ | `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |
218
+ | `MCP_LOG_LEVEL` | Log level (`debug`, `info`, `warning`, `error`). | `info` |
219
+ | `LOGS_DIR` | Log file directory (Node.js only). | `<project-root>/logs` |
220
+ | `OTEL_ENABLED` | Enable [OpenTelemetry instrumentation](https://github.com/cyanheads/mcp-ts-core/tree/main/docs/telemetry). | `false` |
221
+
222
+ See [`.env.example`](./.env.example) for the full list of optional overrides.
223
+
224
+ > **Attribution:** Open Food Facts data is released under the [Open Database License (ODbL) 1.0](https://opendatacommons.org/licenses/odbl/1.0/). Downstream use must cite [Open Food Facts](https://world.openfoodfacts.org/).
225
+
226
+ ## Running the server
227
+
228
+ ### Local development
229
+
230
+ - **Build and run:**
231
+
232
+ ```sh
233
+ # One-time build
234
+ bun run rebuild
235
+
236
+ # Run the built server
237
+ bun run start:stdio
238
+ # or
239
+ bun run start:http
240
+ ```
241
+
242
+ - **Run checks and tests:**
243
+
244
+ ```sh
245
+ bun run devcheck # Lint, format, typecheck, security
246
+ bun run test # Vitest test suite
247
+ bun run lint:mcp # Validate MCP definitions against spec
248
+ ```
249
+
250
+ ### Docker
251
+
252
+ ```sh
253
+ docker build -t openfoodfacts-mcp-server .
254
+ docker run --rm -p 3010:3010 openfoodfacts-mcp-server
255
+ ```
256
+
257
+ The Dockerfile defaults to HTTP transport, stateless session mode, and logs to `/var/log/openfoodfacts-mcp-server`. OpenTelemetry peer dependencies are installed by default — build with `--build-arg OTEL_ENABLED=false` to omit them.
258
+
259
+ ## Project structure
260
+
261
+ | Directory | Purpose |
262
+ |:----------|:--------|
263
+ | `src/index.ts` | `createApp()` entry point — registers tools and inits services. |
264
+ | `src/config` | Server-specific environment variable parsing and validation with Zod. |
265
+ | `src/mcp-server/tools` | Tool definitions (`*.tool.ts`). |
266
+ | `src/services/openfoodfacts` | Open Food Facts API client — HTTP, rate limiting, retry, field normalization. |
267
+ | `src/services/taxonomy` | Embedded tag vocabulary service for `off_browse_taxonomy`. |
268
+ | `tests/` | Unit and integration tests mirroring `src/`. |
269
+
270
+ ## Development guide
271
+
272
+ See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:
273
+
274
+ - Handlers throw, framework catches — no `try/catch` in tool logic
275
+ - Use `ctx.log` for request-scoped logging, `ctx.state` for tenant-scoped storage
276
+ - Register new tools via the barrel in `src/mcp-server/tools/definitions/index.ts`
277
+ - Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
278
+
279
+ ## Contributing
280
+
281
+ Issues and pull requests are welcome. Run checks and tests before submitting:
282
+
283
+ ```sh
284
+ bun run devcheck
285
+ bun run test
286
+ ```
287
+
288
+ ## License
289
+
290
+ Apache-2.0 — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,15 @@
1
+ ---
2
+ summary: "Initial release — 4 tools for barcode lookup, product search, side-by-side comparison, and taxonomy browsing across the Open Food Facts database (3M+ products, keyless, ODbL 1.0)."
3
+ breaking: false
4
+ ---
5
+
6
+ # 0.1.0 — 2026-05-30
7
+
8
+ ## Added
9
+
10
+ - **`off_get_product`** — fetch a product by EAN-13 or UPC barcode; returns name, brand, quantity, ingredients (raw text + parsed list with vegan/vegetarian flags), allergen and additive tags, Nutri-Score (a–e), NOVA group (1–4), Green-Score, normalized nutrition per 100g and per serving, category/label/packaging/origins tags, image URL, and data-completeness score. Inline sparsity caveats clarify crowd-sourced absence vs. attribute absence. Optional `fields` parameter scopes the API request to a subset of fields.
11
+ - **`off_search_products`** — search by free-text query or structured tag filters (category, brand, label, Nutri-Score grade, NOVA group, country). Text and filter paths are mutually exclusive (documented in description). Returns paginated summary rows (barcode, name, brand, scores, categories) for triage; full detail via `off_get_product`. Empty-result enrichment notice guides query broadening.
12
+ - **`off_compare_products`** — parallel side-by-side comparison of 2–10 products by barcode; returns a normalized table of energy, fat, saturated fat, sugars, salt, protein, fiber, Nutri-Score, NOVA, and Green-Score. Missing values preserved as absent; low-completeness products flagged in `format()` output.
13
+ - **`off_browse_taxonomy`** — search the embedded canonical tag vocabulary across 7 facets (categories, labels, allergens, additives, countries, nova_groups, nutrition_grades). Returns `id` + display name + approximate product count. Taxonomy is embedded because the OFF taxonomy API is unavailable to anonymous bot clients.
14
+ - **Open Food Facts v2 HTTP client** — keyless access via identifying User-Agent (`openfoodfacts-mcp-server/0.1.0`); per-endpoint rate limiting (100 req/min for product reads, 10 req/min for search); retry with exponential back-off on 5xx; field-scoped requests to minimize payload size.
15
+ - **ODbL 1.0 attribution** embedded in every `format()` output surface and tool descriptions.
@@ -0,0 +1,127 @@
1
+ ---
2
+ # FORMAT REFERENCE — do not edit. Copy this file to
3
+ # `changelog/<major.minor>.x/<version>.md` (e.g. `changelog/0.8.x/0.8.6.md`)
4
+ # to author a new release. Set that file's H1 to `# <version> — YYYY-MM-DD`
5
+ # with a concrete date.
6
+
7
+ # Required. One-line GitHub Release-style headline. 350 character cap.
8
+ # Default short and scannable. Don't pad, don't stitch unrelated changes with
9
+ # semicolons — pick the headline. Quotes required: unquoted YAML treats `: `
10
+ # inside the value as a key separator and fails GitHub's strict parser.
11
+ summary: ""
12
+
13
+ # Set `true` when consumers must change code to upgrade: API removals,
14
+ # signature changes, config renames, behavior changes that break existing
15
+ # usage. Flagged as `Breaking` in the rollup.
16
+ breaking: false
17
+
18
+ # Set `true` if this release contains any security fix. Pairs with the
19
+ # `## Security` section below. Flagged as `Security` in the rollup so
20
+ # users can triage upgrade urgency at a glance.
21
+ security: false
22
+
23
+ # Optional free-form notes for maintenance agents processing this release.
24
+ # Not rendered in CHANGELOG — consumed by agents running `maintenance` on
25
+ # downstream servers. Use for adoption instructions that don't fit the
26
+ # human-facing sections: new files to create, fields to populate, one-time
27
+ # migration steps. Omit the field entirely when there's nothing to say.
28
+ # agent-notes: |
29
+ # <instructions for downstream maintenance agents>
30
+ ---
31
+
32
+ # <version> — YYYY-MM-DD
33
+
34
+ <!--
35
+ AUTHORING GUIDE — applies to the new per-version file you create from this
36
+ template.
37
+
38
+ Audience: someone scanning release notes to decide what affects them. Lead
39
+ each bullet with the symbol or concept name in **bold** so they can skip
40
+ what's irrelevant and zoom in on what's not.
41
+
42
+ Tone: terse, fact-dense, not verbose. Default to one sentence per bullet —
43
+ name the symbol, state what changed, stop. Use a second sentence only when
44
+ it carries weight. If a bullet feels long, it is.
45
+
46
+ Cut: mechanism walkthroughs (those belong in JSDoc, CLAUDE.md/AGENTS.md, or the
47
+ relevant skill), ceremonial framings ("This release introduces…",
48
+ backwards-compat paragraphs), file-by-file test enumerations, internal
49
+ implementation notes. Prefer code/symbol names over English re-explanations.
50
+
51
+ Narrative intro: skip by default. Add one short sentence only when the
52
+ release theme genuinely needs framing the bullets can't carry.
53
+
54
+ Sections: Keep a Changelog order — Added, Changed, Deprecated, Removed,
55
+ Fixed, Security. Include only sections with entries; delete the rest
56
+ (including the commented-out scaffolding below). Don't ship empty headers.
57
+
58
+ Include: every distinct fact a reader needs to adopt or audit the release —
59
+ new exports, signatures, lint rule IDs, env vars, breaking changes, version
60
+ bumps on shipped skills. Nothing more.
61
+
62
+ Links: link issues, PRs, docs, or skills where they help a reader jump to
63
+ context. Once per item per entry — don't re-link the same issue in summary,
64
+ narrative, and bullet. Skip links for inline symbol names; code spans speak
65
+ for themselves.
66
+
67
+ Issue/PR URLs: use full URLs. GitHub's bare `#NN` auto-link only resolves
68
+ inside its own UI, not in npm reads or local editors.
69
+
70
+ [#38](https://github.com/cyanheads/mcp-ts-core/issues/38) ← issue
71
+ [#42](https://github.com/cyanheads/mcp-ts-core/pull/42) ← PR
72
+
73
+ Verify numbers exist before linking (`gh issue view NN`, `gh pr view NN`).
74
+ Never speculate on a future number — `#42` for an upcoming PR silently
75
+ resolves to whatever real item already owns 42, and timeline previews pull
76
+ in that unrelated item's metadata.
77
+
78
+ TAG ANNOTATIONS — the annotated tag body renders as the GitHub Release body
79
+ via `gh release create --notes-from-tag`. The tag is a derivative of this
80
+ changelog entry — a condensed, scannable version, not a copy. Format:
81
+
82
+ <theme — omit version number, GitHub prepends it>
83
+ ← blank line
84
+ <1-2 sentence context: what this release does>
85
+ ← blank line
86
+ Dependency bumps: ← section header
87
+ ← blank line
88
+ - `@cyanheads/mcp-ts-core` ^0.9.1 → ^0.9.6 ← bullet
89
+ ← blank line
90
+ Changed: ← only sections with entries
91
+ ← blank line
92
+ - `format()` output includes `query` in text mode
93
+ ← blank line
94
+ Added:
95
+ ← blank line
96
+ - `manifest.json` scaffolded for MCPB bundle support
97
+ - Install badges (Claude Desktop, Cursor, VS Code)
98
+ ← blank line
99
+ <N> tests pass; `bun run devcheck` clean. ← footer
100
+
101
+ Never a flat comma-separated string. Always structured markdown with
102
+ sections. The tag must scan well as a rendered GitHub Release page.
103
+ -->
104
+
105
+ ## Added
106
+
107
+ -
108
+
109
+ ## Changed
110
+
111
+ -
112
+
113
+ <!-- ## Deprecated
114
+
115
+ - -->
116
+
117
+ <!-- ## Removed
118
+
119
+ - -->
120
+
121
+ ## Fixed
122
+
123
+ -
124
+
125
+ <!-- ## Security
126
+
127
+ - -->
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @fileoverview Server-specific configuration for the Open Food Facts MCP server.
3
+ * @module config/server-config
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ declare const ServerConfigSchema: z.ZodObject<{
7
+ baseUrl: z.ZodDefault<z.ZodString>;
8
+ rateLimitProduct: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
9
+ rateLimitSearch: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
10
+ }, z.core.$strip>;
11
+ export type ServerConfig = z.infer<typeof ServerConfigSchema>;
12
+ /** Lazy-parsed server config from environment variables. */
13
+ export declare function getServerConfig(): ServerConfig;
14
+ export {};
15
+ //# sourceMappingURL=server-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C,QAAA,MAAM,kBAAkB;;;;iBAiBtB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D,4DAA4D;AAC5D,wBAAgB,eAAe,IAAI,YAAY,CAO9C"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @fileoverview Server-specific configuration for the Open Food Facts MCP server.
3
+ * @module config/server-config
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
7
+ const ServerConfigSchema = z.object({
8
+ baseUrl: z
9
+ .string()
10
+ .default('https://world.openfoodfacts.org')
11
+ .describe('Open Food Facts API base URL'),
12
+ rateLimitProduct: z.coerce
13
+ .number()
14
+ .int()
15
+ .min(1)
16
+ .default(100)
17
+ .describe('Product read rate limit (requests/min)'),
18
+ rateLimitSearch: z.coerce
19
+ .number()
20
+ .int()
21
+ .min(1)
22
+ .default(10)
23
+ .describe('Search rate limit (requests/min)'),
24
+ });
25
+ let _config;
26
+ /** Lazy-parsed server config from environment variables. */
27
+ export function getServerConfig() {
28
+ _config ??= parseEnvConfig(ServerConfigSchema, {
29
+ baseUrl: 'OFF_BASE_URL',
30
+ rateLimitProduct: 'OFF_RATE_LIMIT_PRODUCT',
31
+ rateLimitSearch: 'OFF_RATE_LIMIT_SEARCH',
32
+ });
33
+ return _config;
34
+ }
35
+ //# sourceMappingURL=server-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.js","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,OAAO,CAAC,iCAAiC,CAAC;SAC1C,QAAQ,CAAC,8BAA8B,CAAC;IAC3C,gBAAgB,EAAE,CAAC,CAAC,MAAM;SACvB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,OAAO,CAAC,GAAG,CAAC;SACZ,QAAQ,CAAC,wCAAwC,CAAC;IACrD,eAAe,EAAE,CAAC,CAAC,MAAM;SACtB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,OAAO,CAAC,EAAE,CAAC;SACX,QAAQ,CAAC,kCAAkC,CAAC;CAChD,CAAC,CAAC;AAIH,IAAI,OAAiC,CAAC;AAEtC,4DAA4D;AAC5D,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,cAAc,CAAC,kBAAkB,EAAE;QAC7C,OAAO,EAAE,cAAc;QACvB,gBAAgB,EAAE,wBAAwB;QAC1C,eAAe,EAAE,uBAAuB;KACzC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview openfoodfacts-mcp-server MCP server entry point.
4
+ * @module index
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG"}
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview openfoodfacts-mcp-server MCP server entry point.
4
+ * @module index
5
+ */
6
+ import { createApp } from '@cyanheads/mcp-ts-core';
7
+ import { allToolDefinitions } from './mcp-server/tools/definitions/index.js';
8
+ import { initOpenFoodFactsService } from './services/openfoodfacts/openfoodfacts-service.js';
9
+ import { initTaxonomyService } from './services/taxonomy/taxonomy-service.js';
10
+ await createApp({
11
+ tools: allToolDefinitions,
12
+ instructions: 'Use the off_* tools to query Open Food Facts — a free, crowd-sourced global food product database covering 3M+ products. ' +
13
+ 'Primary workflow: off_get_product for barcode lookup (EAN-13/UPC), off_search_products to find products by text or tags, ' +
14
+ 'off_compare_products for side-by-side nutrition comparison, off_browse_taxonomy to resolve human terms to canonical tag IDs. ' +
15
+ 'Data is crowd-sourced — missing fields mean "not yet entered," not that the attribute is absent. ' +
16
+ 'Computed scores (Nutri-Score, NOVA, Green-Score) carry regional caveats. ' +
17
+ 'No API key required. Data under ODbL 1.0 — cite Open Food Facts in downstream use.',
18
+ setup() {
19
+ initOpenFoodFactsService();
20
+ initTaxonomyService();
21
+ },
22
+ });
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,MAAM,SAAS,CAAC;IACd,KAAK,EAAE,kBAAkB;IACzB,YAAY,EACV,2HAA2H;QAC3H,2HAA2H;QAC3H,+HAA+H;QAC/H,mGAAmG;QACnG,2EAA2E;QAC3E,oFAAoF;IACtF,KAAK;QACH,wBAAwB,EAAE,CAAC;QAC3B,mBAAmB,EAAE,CAAC;IACxB,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview Tool definition for browsing Open Food Facts canonical tag vocabularies.
3
+ * @module mcp-server/tools/definitions/browse-taxonomy
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ export declare const offBrowseTaxonomyTool: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
7
+ facet: z.ZodEnum<{
8
+ categories: "categories";
9
+ labels: "labels";
10
+ allergens: "allergens";
11
+ additives: "additives";
12
+ countries: "countries";
13
+ nova_groups: "nova_groups";
14
+ nutrition_grades: "nutrition_grades";
15
+ }>;
16
+ search: z.ZodOptional<z.ZodString>;
17
+ limit: z.ZodDefault<z.ZodNumber>;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ facet: z.ZodString;
20
+ tags: z.ZodArray<z.ZodObject<{
21
+ id: z.ZodString;
22
+ name: z.ZodString;
23
+ products: z.ZodOptional<z.ZodNumber>;
24
+ }, z.core.$strip>>;
25
+ total_in_facet: z.ZodOptional<z.ZodNumber>;
26
+ }, z.core.$strip>, undefined, undefined>;
27
+ //# sourceMappingURL=browse-taxonomy.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browse-taxonomy.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/browse-taxonomy.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAGjD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;wCAiHhC,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @fileoverview Tool definition for browsing Open Food Facts canonical tag vocabularies.
3
+ * @module mcp-server/tools/definitions/browse-taxonomy
4
+ */
5
+ import { tool, z } from '@cyanheads/mcp-ts-core';
6
+ import { getTaxonomyService } from '../../../services/taxonomy/taxonomy-service.js';
7
+ export const offBrowseTaxonomyTool = tool('off_browse_taxonomy', {
8
+ title: 'Browse Food Facts Taxonomy',
9
+ description: 'Browse and search the canonical tag vocabulary for Open Food Facts filter facets. Returns tag IDs and display names for use as filter values in off_search_products. Covers categories, labels/certifications, allergens, additives, countries, NOVA groups, and Nutri-Score grades. The taxonomy is embedded — not fetched live — because the OFF taxonomy API is unavailable to anonymous bot clients. Tag IDs use the "en:" prefix convention (e.g. "en:organic", "en:gluten-free", "en:milk"). Always use these tag IDs as filter values, not plain English terms.',
10
+ annotations: {
11
+ readOnlyHint: true,
12
+ idempotentHint: true,
13
+ openWorldHint: false,
14
+ },
15
+ input: z.object({
16
+ facet: z
17
+ .enum([
18
+ 'categories',
19
+ 'labels',
20
+ 'allergens',
21
+ 'additives',
22
+ 'countries',
23
+ 'nova_groups',
24
+ 'nutrition_grades',
25
+ ])
26
+ .describe('"categories" covers food categories (en:cheeses, en:breakfast-cereals). "labels" covers certifications (en:organic, en:fair-trade). "allergens" covers declared allergens (en:milk, en:gluten). "additives" covers E-numbers (en:e322). "countries" covers country-of-sale tags (en:france). "nova_groups" and "nutrition_grades" return the complete fixed vocabularies.'),
27
+ search: z
28
+ .string()
29
+ .optional()
30
+ .describe('Case-insensitive substring filter against tag ID or display name. Example: "gluten" returns en:gluten, en:no-gluten. Omit to list all entries for the facet (may be large for categories).'),
31
+ limit: z
32
+ .number()
33
+ .int()
34
+ .min(1)
35
+ .max(100)
36
+ .default(20)
37
+ .describe('Maximum entries to return (1–100, default 20). Categories has many entries — always provide a search term when browsing categories.'),
38
+ }),
39
+ output: z.object({
40
+ facet: z.string().describe('The facet name that was queried (echoes the input).'),
41
+ tags: z
42
+ .array(z
43
+ .object({
44
+ id: z
45
+ .string()
46
+ .describe('Canonical tag ID (e.g. "en:organic"). Use this value in off_search_products filter parameters.'),
47
+ name: z.string().describe('Human-readable display name (e.g. "Organic").'),
48
+ products: z
49
+ .number()
50
+ .optional()
51
+ .describe('Approximate count of products with this tag. Not available for all facets.'),
52
+ })
53
+ .describe('A single taxonomy tag entry with its canonical ID and display name.'))
54
+ .describe('Matching tag entries.'),
55
+ total_in_facet: z
56
+ .number()
57
+ .optional()
58
+ .describe('Total entries in this facet before search filtering. Large for categories.'),
59
+ }),
60
+ handler(input, ctx) {
61
+ const svc = getTaxonomyService();
62
+ const result = svc.search(input.facet, input.search && input.search.trim().length > 0 ? input.search.trim() : undefined, input.limit);
63
+ ctx.log.info('Taxonomy browsed', {
64
+ facet: input.facet,
65
+ search: input.search,
66
+ returned: result.tags.length,
67
+ total: result.total_in_facet,
68
+ });
69
+ return {
70
+ facet: result.facet,
71
+ tags: result.tags,
72
+ total_in_facet: result.total_in_facet,
73
+ };
74
+ },
75
+ format: (result) => {
76
+ const lines = [
77
+ `## ${result.facet} (${result.tags.length} entries${result.total_in_facet !== undefined ? ` of ${result.total_in_facet} total` : ''})\n`,
78
+ ];
79
+ if (result.tags.length === 0) {
80
+ lines.push('No matching tags found. Try a different search term.');
81
+ return [{ type: 'text', text: lines.join('\n') }];
82
+ }
83
+ for (const tag of result.tags) {
84
+ const products = tag.products !== undefined ? ` (~${tag.products.toLocaleString()} products)` : '';
85
+ lines.push(`- \`${tag.id}\` — ${tag.name}${products}`);
86
+ }
87
+ lines.push('\n*Use the `id` values (e.g. "en:organic") as filter parameters in off_search_products.*');
88
+ return [{ type: 'text', text: lines.join('\n') }];
89
+ },
90
+ });
91
+ //# sourceMappingURL=browse-taxonomy.tool.js.map