@chrischall/hellofresh-mcp 0.2.0 → 0.4.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.
package/dist/cooking.js CHANGED
@@ -35,6 +35,7 @@ export function projectRecipe(detail, servings) {
35
35
  name: i.name.trim(),
36
36
  ...(typeof a?.amount === 'number' ? { amount: a.amount } : {}),
37
37
  ...(a?.unit ? { unit: a.unit } : {}),
38
+ ...(!yieldFor ? { amountUnknown: true } : {}),
38
39
  ...(i.shipped === false ? { notInBox: true } : {}),
39
40
  };
40
41
  });
@@ -121,3 +122,58 @@ export function dayFrom(date, n) {
121
122
  const d = new Date(Date.parse(`${date}T00:00:00Z`) + n * 86_400_000);
122
123
  return { day: DAYS[d.getUTCDay()], date: d.toISOString().slice(0, 10) };
123
124
  }
125
+ const round2 = (n) => Math.round(n * 100) / 100;
126
+ const unitKey = (i) => i.unit ?? '';
127
+ /**
128
+ * The not-shipped ingredients across `dishes`, one line per name and unit (amounts
129
+ * summed, × the dish's quantity); a name's unmeasured uses form its own to-taste
130
+ * line. Sorted by name, measured lines before the to-taste one, then by unit.
131
+ */
132
+ export function pantryItems(dishes) {
133
+ const lines = new Map();
134
+ for (const dish of dishes) {
135
+ for (const i of dish.ingredients) {
136
+ if (!i.notInBox)
137
+ continue;
138
+ const name = i.name.trim();
139
+ const measured = i.amount !== undefined;
140
+ const kind = measured ? `=${i.unit ?? ''}` : i.amountUnknown ? '?' : '~';
141
+ const key = `${name.toLowerCase()}\u0000${kind}`;
142
+ const fresh = () => measured
143
+ ? { name, total: 0, ...(i.unit ? { unit: i.unit } : {}), usedIn: [] }
144
+ : i.amountUnknown
145
+ ? { name, amountUnknown: true, usedIn: [] }
146
+ : { name, toTaste: true, usedIn: [] };
147
+ const line = lines.get(key) ?? lines.set(key, fresh()).get(key);
148
+ if (measured)
149
+ line.total = round2(line.total + i.amount * dish.quantity);
150
+ if (!line.usedIn.includes(dish.name))
151
+ line.usedIn.push(dish.name);
152
+ }
153
+ }
154
+ return [...lines.values()].sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()) ||
155
+ Number(a.toTaste ?? false) - Number(b.toTaste ?? false) ||
156
+ unitKey(a).localeCompare(unitKey(b)));
157
+ }
158
+ const UNIT_ABBREVIATIONS = { teaspoon: 'tsp', tablespoon: 'tbsp', ounce: 'oz' };
159
+ /** HelloFresh labels units like "teaspoon (tsp)": prefer the parenthesised short form, then the table. */
160
+ function shortUnit(unit) {
161
+ const paren = /\(([^()]+)\)\s*$/.exec(unit);
162
+ if (paren)
163
+ return paren[1].trim();
164
+ return UNIT_ABBREVIATIONS[unit.toLowerCase()] ?? unit;
165
+ }
166
+ /** The pantry list as one line, e.g. "From your pantry for 2026-W50: Cooking Oil (8 tsp), Salt (to taste)." */
167
+ export function pantryLine(week, items) {
168
+ if (items.length === 0)
169
+ return `Nothing from your pantry for ${week}: HelloFresh ships every ingredient.`;
170
+ const parts = items.map((i) => {
171
+ if (i.toTaste)
172
+ return `${i.name} (to taste)`;
173
+ if (i.amountUnknown)
174
+ return `${i.name} (amount not listed)`;
175
+ const unit = i.unit ? ` ${shortUnit(i.unit)}` : '';
176
+ return `${i.name} (${i.total}${unit})`;
177
+ });
178
+ return `From your pantry for ${week}: ${parts.join(', ')}.`;
179
+ }
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import { readWsPort } from './config.js';
5
5
  import { TOOL_REGISTRARS } from './tools/index.js';
6
6
  import { createProfileStore } from './profiles.js';
7
7
  import { HelloFreshSession } from './session.js';
8
+ import { createSessionCache } from './session-cache.js';
8
9
  import { createHelloFreshBridge } from './transport.js';
9
10
  import { VERSION } from './version.js';
10
11
  // The bridge bootstraps the session: it reads (and refreshes) the apiV2Auth
@@ -19,7 +20,9 @@ await bridge.start().catch(() => { });
19
20
  // Built ONCE, outside the registrars (runMcp builds a server per connection).
20
21
  // Nothing here resolves a credential at boot (deferred-config-error pattern).
21
22
  const fetchImpl = (input, init) => fetch(input, init);
22
- const session = new HelloFreshSession({ bridge, fetchImpl });
23
+ // The session survives a restart through a 0600 file (HELLOFRESH_SESSION_FILE;
24
+ // HELLOFRESH_SESSION_CACHE=false keeps it in memory only). Opening it touches no disk.
25
+ const session = new HelloFreshSession({ bridge, fetchImpl, persistence: createSessionCache() });
23
26
  const deps = {
24
27
  bridge,
25
28
  session,
@@ -0,0 +1,33 @@
1
+ // Where the HelloFresh session is kept between runs (lifecycle step 6 in
2
+ // src/session.ts). One small 0600 JSON file, replaced atomically, with a
3
+ // cross-process lock beside it — the fleet's createFileStatePersistence.
4
+ //
5
+ // It holds the token set WITHOUT `user_data` (the customer id and email). On
6
+ // mcp-host it lands in the registration's persistent data dir (MCP_DATA_DIR;
7
+ // mint.yaml declares `state.dataDir: true`), elsewhere under $HOME.
8
+ import { parseBoolEnv } from '@chrischall/mcp-utils';
9
+ import { createFileStatePersistence, resolveStateFile, } from '@chrischall/mcp-utils/session';
10
+ import { isTokenSet } from './session.js';
11
+ /** `HELLOFRESH_SESSION_FILE`, else `<MCP_DATA_DIR or HOME>/.hellofresh-mcp/session.json`. */
12
+ export function sessionCachePath(env = process.env) {
13
+ return resolveStateFile({ env, envVar: 'HELLOFRESH_SESSION_FILE', subdir: '.hellofresh-mcp', fileName: 'session.json' });
14
+ }
15
+ function asPersistedSession(raw) {
16
+ if (typeof raw !== 'object' || raw === null)
17
+ return null;
18
+ const r = raw;
19
+ if (!isTokenSet(r['set']) || typeof r['set'].issued_at !== 'number')
20
+ return null;
21
+ if (typeof r['own'] !== 'boolean' || typeof r['writtenBack'] !== 'boolean')
22
+ return null;
23
+ return { set: r['set'], own: r['own'], writtenBack: r['writtenBack'] };
24
+ }
25
+ /** The session store, or `null` when `HELLOFRESH_SESSION_CACHE` turns it off. */
26
+ export function createSessionCache(env = process.env) {
27
+ if (!parseBoolEnv('HELLOFRESH_SESSION_CACHE', { env, default: true }))
28
+ return null;
29
+ return createFileStatePersistence({
30
+ filePath: sessionCachePath(env),
31
+ validate: asPersistedSession,
32
+ });
33
+ }
package/dist/session.js CHANGED
@@ -25,9 +25,23 @@
25
25
  // out). Only its ACCESS token is used, while still valid (and not
26
26
  // rejected); otherwise the original bridge error is rethrown, its
27
27
  // pairing hint intact. /gw/refresh is never called.
28
- // A set read from the browser is never a fallback: its refresh token may
29
- // already be spent by the browser. A missing cookie (signed out) is NOT a
30
- // read failure and still fails.
28
+ // A set read from the browser is never refreshed as a fallback: its
29
+ // refresh token may already be spent by the browser. Its ACCESS token may
30
+ // stand in while still valid (and not rejected). A missing cookie (signed
31
+ // out) is NOT a read failure and still fails.
32
+ // 6. Optional persistence (`src/session-cache.ts`) carries the newest set —
33
+ // and whether it is our own refresh and was written back — across a
34
+ // restart. It is loaded once, as if this process had just used it, so
35
+ // step 5's rules decide what a stored set may do: the browser's newer
36
+ // cookie still wins, a stored ACCESS token stands in while valid, and only
37
+ // our own never-written-back refresh token is ever POSTed without the
38
+ // browser. `user_data` (customer id, email) is never stored. Refreshing
39
+ // holds the store's cross-process lock and re-reads it first, so a sibling
40
+ // process (Claude Desktop beside Claude Code) that just refreshed is
41
+ // adopted instead of racing it with the same rotating refresh token. A
42
+ // rejected refresh clears the record (unless a sibling's newer one replaced
43
+ // it), so a dead session is not read back off disk. A store failure is
44
+ // logged and never fails a call.
31
45
  //
32
46
  // No token value is ever logged, put in an error message or returned.
33
47
  import { EdgeBlockedError, McpToolError, SessionNotAuthenticatedError, createCachedTokenSource, decodeJwtClaim, detectEdgeBlock, messageOf, parseJsonBody, redactValues, truncateErrorMessage, } from '@chrischall/mcp-utils';
@@ -124,7 +138,7 @@ export function decodeAuthCookie(raw) {
124
138
  }
125
139
  return parsed;
126
140
  }
127
- function isTokenSet(value) {
141
+ export function isTokenSet(value) {
128
142
  if (typeof value !== 'object' || value === null || Array.isArray(value))
129
143
  return false;
130
144
  const v = value;
@@ -139,6 +153,11 @@ export function tokenExpiresAtMs(set) {
139
153
  const exp = decodeJwtClaim(set.access_token, 'exp');
140
154
  return typeof exp === 'number' ? exp * 1000 : 0;
141
155
  }
156
+ /** The record to store for `set`: never its `user_data` (customer id, email). */
157
+ export function toPersistedSession(set, from) {
158
+ const { user_data: _userData, ...rest } = set;
159
+ return { set: rest, own: from.own, writtenBack: from.own && from.writtenBack };
160
+ }
142
161
  /** How many token values to remember for redaction. */
143
162
  const REDACT_HISTORY = 8;
144
163
  export class HelloFreshSession {
@@ -158,6 +177,10 @@ export class HelloFreshSession {
158
177
  /** Whether that refresh was written back to the browser (which may then rotate it on its own). */
159
178
  ownWrittenBack = false;
160
179
  seen = [];
180
+ /** The stored record is read once, on the first lifecycle. */
181
+ restored = false;
182
+ /** Identity of what was last saved, to skip rewriting an unchanged record. */
183
+ savedKey;
161
184
  constructor(opts) {
162
185
  this.opts = opts;
163
186
  this.fetchImpl = opts.fetchImpl ?? globalThis.fetch.bind(globalThis);
@@ -236,12 +259,15 @@ export class HelloFreshSession {
236
259
  }
237
260
  catch (err) {
238
261
  const ours = this.latest;
239
- if (!ours || ours.refresh_token !== this.ownRefreshToken)
262
+ if (!ours)
240
263
  throw err;
241
- // Written back: the browser may have rotated (spent) its refresh token — use the access token only.
242
- if (this.ownWrittenBack ? !this.fresh(ours) : !this.refreshable(ours))
264
+ // Only our own never-written-back refresh token is ours alone to spend; any
265
+ // other set (the browser's, or ours once written back) stands in by its
266
+ // still-valid access token only — the browser may have rotated its refresh token.
267
+ const ownUnwritten = ours.refresh_token === this.ownRefreshToken && !this.ownWrittenBack;
268
+ if (ownUnwritten ? !this.refreshable(ours) : !this.fresh(ours))
243
269
  throw err;
244
- console.error(`[hellofresh-mcp] could not read the browser session (${truncateErrorMessage(this.redact(messageOf(err)), 200)}); using this process's own refreshed session`);
270
+ console.error(`[hellofresh-mcp] could not read the browser session (${truncateErrorMessage(this.redact(messageOf(err)), 200)}); using the last session this server knew of`);
245
271
  return ours;
246
272
  }
247
273
  if (!raw)
@@ -257,12 +283,43 @@ export class HelloFreshSession {
257
283
  return browserIsNewest ? browser : ours;
258
284
  }
259
285
  async lifecycle() {
286
+ if (!this.restored) {
287
+ this.restored = true;
288
+ const stored = await this.loadStored();
289
+ if (stored)
290
+ this.adopt(stored);
291
+ }
260
292
  const newest = await this.newestSet();
261
293
  if (this.fresh(newest)) {
262
- this.latest = newest;
294
+ if (newest !== this.latest) {
295
+ this.latest = newest;
296
+ this.ownRefreshToken = undefined;
297
+ }
298
+ await this.persist();
263
299
  return newest;
264
300
  }
265
- const next = await this.refresh(newest);
301
+ return this.locked(() => this.refreshLocked(newest));
302
+ }
303
+ /** Step 3, holding the store's cross-process lock. */
304
+ async refreshLocked(newest) {
305
+ // A sibling process may have refreshed while we waited: take its set rather
306
+ // than POST a refresh token it has already spent.
307
+ const stored = await this.loadStored();
308
+ if (stored && stored.set.issued_at > newest.issued_at && this.fresh(stored.set)) {
309
+ this.adopt(stored);
310
+ return stored.set;
311
+ }
312
+ let next;
313
+ try {
314
+ next = await this.refresh(newest);
315
+ }
316
+ catch (err) {
317
+ // A dead session must not be read back off disk — unless a sibling's newer record replaced ours.
318
+ if (err instanceof HelloFreshSessionError && (!stored || stored.set.issued_at <= newest.issued_at)) {
319
+ await this.store('clear', () => this.opts.persistence?.clear?.());
320
+ }
321
+ throw err;
322
+ }
266
323
  this.latest = next;
267
324
  this.ownRefreshToken = next.refresh_token;
268
325
  this.ownWrittenBack = false;
@@ -276,8 +333,56 @@ export class HelloFreshSession {
276
333
  this.writeBackWarning = WRITE_BACK_WARNING;
277
334
  console.error(`[hellofresh-mcp] could not write the refreshed session back to the browser: ${truncateErrorMessage(this.redact(messageOf(err)), 200)}`);
278
335
  }
336
+ await this.persist();
279
337
  return next;
280
338
  }
339
+ /** Take a stored record as this process's newest known set. */
340
+ adopt(stored) {
341
+ this.latest = stored.set;
342
+ this.ownRefreshToken = stored.own ? stored.set.refresh_token : undefined;
343
+ this.ownWrittenBack = stored.own && stored.writtenBack;
344
+ this.savedKey = this.keyOf(stored.set);
345
+ this.remember(stored.set);
346
+ }
347
+ keyOf(set) {
348
+ const own = set.refresh_token === this.ownRefreshToken;
349
+ return `${set.access_token}\u0000${set.refresh_token}\u0000${own}\u0000${own && this.ownWrittenBack}`;
350
+ }
351
+ async persist() {
352
+ const set = this.latest;
353
+ if (!this.opts.persistence || !set)
354
+ return;
355
+ const key = this.keyOf(set);
356
+ if (key === this.savedKey)
357
+ return;
358
+ const own = set.refresh_token === this.ownRefreshToken;
359
+ const ok = await this.store('save', () => this.opts.persistence?.save(toPersistedSession(set, { own, writtenBack: this.ownWrittenBack })));
360
+ if (ok)
361
+ this.savedKey = key;
362
+ }
363
+ async loadStored() {
364
+ let stored = null;
365
+ await this.store('load', async () => {
366
+ stored = (await this.opts.persistence?.load()) ?? null;
367
+ });
368
+ return stored;
369
+ }
370
+ locked(fn) {
371
+ const store = this.opts.persistence;
372
+ return store?.withLock ? store.withLock(fn) : fn();
373
+ }
374
+ /** Run a store operation; a failure is logged (redacted), never thrown. */
375
+ async store(op, fn) {
376
+ try {
377
+ await fn();
378
+ return true;
379
+ }
380
+ catch (err) {
381
+ console.error(`[hellofresh-mcp] could not ${op} the ${op === 'load' ? 'saved ' : ''}HelloFresh session on disk ` +
382
+ `(${truncateErrorMessage(this.redact(messageOf(err)), 200)}); continuing without it.`);
383
+ return false;
384
+ }
385
+ }
281
386
  async bridged(fn) {
282
387
  try {
283
388
  return await fn();
@@ -1,13 +1,14 @@
1
1
  // Cooking day: one recipe's detail (hf_get_recipe) and the week's picks in a
2
- // recommended cook order (hf_cooking_plan). Read-only. Recipe text (names,
2
+ // recommended cook order (hf_cooking_plan), and the pantry staples HelloFresh does
3
+ // not ship (hf_pantry_check). Read-only. Recipe text (names,
3
4
  // ingredients, steps) is written by HelloFresh — third-party content — so both
4
5
  // answer inside the untrusted-content envelope.
5
6
  import { z } from 'zod';
6
- import { McpToolError, UNTRUSTED_CONTENT_RULE, UNTRUSTED_DESCRIPTION_SUFFIX, toolAnnotations, untrustedResult, } from '@chrischall/mcp-utils';
7
- import { cookOrder, dayFrom, projectRecipe, recipeMinutes } from '../cooking.js';
7
+ import { McpToolError, UNTRUSTED_CONTENT_RULE, UNTRUSTED_DESCRIPTION_SUFFIX, resolveView, toolAnnotations, untrustedResult, } from '@chrischall/mcp-utils';
8
+ import { cookOrder, dayFrom, pantryItems, pantryLine, projectRecipe, recipeMinutes } from '../cooking.js';
8
9
  import { projectDelivery, projectMenu } from '../normalize.js';
9
10
  import { foodMeta } from './hints.js';
10
- import { attempt, dateOf, loadAccount, readRawMenu, weekParam } from './shared.js';
11
+ import { HF_VIEWS, attempt, dateOf, hfView, loadAccount, readRawMenu, weekParam } from './shared.js';
11
12
  const readOnly = (title) => toolAnnotations({ title, readOnly: true, idempotent: true, openWorld: true });
12
13
  const RECIPE_NOTE = `Recipe names, headlines, ingredients and steps below are written by HelloFresh (third-party content), not the user. ${UNTRUSTED_CONTENT_RULE}`;
13
14
  /** `note` is reserved by the envelope (a payload carrying one is nested under `data`): say `summary` instead. */
@@ -82,7 +83,8 @@ export function registerCookingTools(server, deps) {
82
83
  description: 'Plan cooking for a HelloFresh delivery week: the picked meals in a recommended cook order, most perishable ' +
83
84
  'first (fish, then shellfish, other seafood, poultry, ground meat, whole cuts of beef/pork/lamb, vegetarian ' +
84
85
  'last; ties by shorter total time), each with a suggested day counted from the delivery date, why, total ' +
85
- `time, a short ingredient list and the recipe card. ${UNTRUSTED_DESCRIPTION_SUFFIX}`,
86
+ 'time, a short ingredient list, the pantry staples HelloFresh does not ship (salt, oil…) and the recipe card. ' +
87
+ `${UNTRUSTED_DESCRIPTION_SUFFIX}`,
86
88
  annotations: readOnly('HelloFresh: cooking plan'),
87
89
  _meta: foodMeta('whats-on', { aliases: ['what to cook', 'cooking order', 'dinner this week'] }),
88
90
  inputSchema: z.object({ week: weekParam }),
@@ -105,6 +107,7 @@ export function registerCookingTools(server, deps) {
105
107
  const recipe = meal?.recipe ?? {};
106
108
  const read = await attempt(async () => projectRecipe(await client.getRecipe(recipeIdOf(meal, s.index, week)), servings));
107
109
  const shipped = read.ok ? read.value.ingredients.filter((i) => !i.notInBox).map((i) => i.name) : [];
110
+ const pantry = read.ok ? read.value.ingredients.filter((i) => i.notInBox).map((i) => i.name) : [];
108
111
  const dish = variant ?? base;
109
112
  return {
110
113
  index: s.index,
@@ -125,6 +128,7 @@ export function registerCookingTools(server, deps) {
125
128
  ? {
126
129
  ingredients: shipped.slice(0, SHORT_INGREDIENTS),
127
130
  ...(shipped.length > SHORT_INGREDIENTS ? { moreIngredients: shipped.length - SHORT_INGREDIENTS } : {}),
131
+ pantry,
128
132
  ...(read.value.cardLink ? { cardLink: read.value.cardLink } : {}),
129
133
  }
130
134
  : { ingredientsError: read.reason }),
@@ -147,4 +151,66 @@ export function registerCookingTools(server, deps) {
147
151
  : {}),
148
152
  });
149
153
  });
154
+ server.registerTool('hf_pantry_check', {
155
+ description: 'Check what to have in the pantry for a HelloFresh delivery week: the staples HelloFresh does NOT ship (salt, ' +
156
+ 'pepper, cooking oil, often butter, eggs, sugar or flour) across the week’s picked meals, at the week’s servings ' +
157
+ '(nearest listed yield otherwise, said so) and × each meal’s quantity — summed per ingredient and unit, ' +
158
+ '"to taste" when no amount is listed, with the dishes that use each — plus a one-line summary. Answers ' +
159
+ `"what do I need from my pantry for HelloFresh this week?". ${UNTRUSTED_DESCRIPTION_SUFFIX}`,
160
+ annotations: readOnly('HelloFresh: pantry check'),
161
+ _meta: foodMeta('lookup', { aliases: ['pantry check', 'pantry staples', 'what do i need on hand', 'not in the box'] }),
162
+ inputSchema: z.object({
163
+ week: weekParam,
164
+ view: hfView('compact is the summed pantry list and summary; full adds each dish’s staples with their own amounts.'),
165
+ }),
166
+ }, async ({ week, view }) => {
167
+ const account = await loadAccount(client);
168
+ const delivery = projectDelivery(await client.getDelivery(account.subscriptionId, week));
169
+ const head = { week, status: delivery.status };
170
+ if (delivery.status === 'skipped') {
171
+ return fenced({ ...head, items: [], summary: `${week} is skipped: nothing is delivered, so nothing is needed from the pantry.` });
172
+ }
173
+ const raw = await readRawMenu(client, account, delivery, week);
174
+ const menu = projectMenu(raw);
175
+ if (menu.selected.length === 0) {
176
+ return fenced({ ...head, items: [], summary: `No meals are picked for ${week} yet — pick them with hf_select_meals, then check the pantry.` });
177
+ }
178
+ const servings = delivery.servings; // readRawMenu refuses a week without it
179
+ const reads = await Promise.all(menu.selected.map(async (s) => ({
180
+ s,
181
+ read: await attempt(async () => projectRecipe(await client.getRecipe(recipeIdOf(locate(raw, menu, s.index).meal, s.index, week)), servings)),
182
+ })));
183
+ const dishes = reads.flatMap(({ s, read }) => {
184
+ if (!read.ok)
185
+ return [];
186
+ const name = s.name ?? read.value.name ?? `#${s.index}`;
187
+ return [{ index: s.index, name, quantity: s.quantity, recipe: read.value }];
188
+ });
189
+ const unread = reads.flatMap(({ s, read }) => (read.ok ? [] : [{ index: s.index, reason: read.reason }]));
190
+ const items = pantryItems(dishes.map((d) => ({ name: d.name, quantity: d.quantity, ingredients: d.recipe.ingredients })));
191
+ const notes = dishes.flatMap((d) => d.recipe.yieldsNote ? [`${d.name === `#${d.index}` ? d.name : `#${d.index} ${d.name}`}: ${d.recipe.yieldsNote}`] : []);
192
+ const unreadLine = unread.length === 0
193
+ ? ''
194
+ : ` ${unread.length} recipe${unread.length === 1 ? '' : 's'} could not be read (${unread.map((u) => `#${u.index}`).join(', ')}): their staples are missing.`;
195
+ const full = resolveView(view, HF_VIEWS) === 'full';
196
+ return fenced({
197
+ ...head,
198
+ servings,
199
+ items,
200
+ summary: pantryLine(week, items) + unreadLine,
201
+ ...(notes.length > 0 ? { notes } : {}),
202
+ ...(unread.length > 0 ? { unread } : {}),
203
+ ...(full
204
+ ? {
205
+ dishes: dishes.map((d) => ({
206
+ index: d.index,
207
+ name: d.name,
208
+ quantity: d.quantity,
209
+ ...(d.recipe.amountsForServings !== undefined ? { amountsForServings: d.recipe.amountsForServings } : {}),
210
+ pantry: d.recipe.ingredients.filter((i) => i.notInBox).map(({ notInBox: _n, ...i }) => i),
211
+ })),
212
+ }
213
+ : {}),
214
+ });
215
+ });
150
216
  }
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  // literal below on release; every manifest that carries a version is listed in
3
3
  // release-please-config.json's extra-files and kept in lockstep by
4
4
  // tests/version-sync.test.ts. Keep the release marker on the export line only.
5
- export const VERSION = '0.2.0'; // x-release-please-version
5
+ export const VERSION = '0.4.0'; // x-release-please-version
package/manifest.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "manifest_version": "0.3",
4
4
  "name": "hellofresh-mcp",
5
5
  "display_name": "HelloFresh",
6
- "version": "0.2.0",
6
+ "version": "0.4.0",
7
7
  "description": "Unofficial HelloFresh (US) tools for Claude — subscription, weekly deliveries, menus, meal picks, skips and box sizes via your signed-in browser",
8
8
  "author": {
9
9
  "name": "Chris Chall",
@@ -39,7 +39,9 @@
39
39
  "MCP_CONFIRM_ELICITATION": "${user_config.confirm_elicitation}",
40
40
  "HELLOFRESH_DEBUG": "${user_config.debug}",
41
41
  "HELLOFRESH_PROFILES": "${user_config.profiles}",
42
- "HELLOFRESH_PROFILES_FILE": "${user_config.profiles_file}"
42
+ "HELLOFRESH_PROFILES_FILE": "${user_config.profiles_file}",
43
+ "HELLOFRESH_SESSION_FILE": "${user_config.session_file}",
44
+ "HELLOFRESH_SESSION_CACHE": "${user_config.session_cache}"
43
45
  }
44
46
  }
45
47
  },
@@ -86,6 +88,18 @@
86
88
  "title": "Planner profiles file (optional)",
87
89
  "description": "Optional. Path to a JSON file of meal-planner profiles. Defaults to ~/.config/hellofresh-mcp/profiles.json (used only when it exists).",
88
90
  "required": false
91
+ },
92
+ "session_file": {
93
+ "type": "string",
94
+ "title": "Session file (optional)",
95
+ "description": "Optional. Where the HelloFresh session is kept so it survives a restart (the token set only, never your id or email; file mode 0600). Defaults to ~/.hellofresh-mcp/session.json. Leave blank for the default.",
96
+ "required": false
97
+ },
98
+ "session_cache": {
99
+ "type": "string",
100
+ "title": "Keep the session across restarts (optional)",
101
+ "description": "Optional. \"false\" keeps the HelloFresh session in memory only, so every start reads it from the browser again. Defaults to on. Leave blank for the default.",
102
+ "required": false
89
103
  }
90
104
  },
91
105
  "tools": [
@@ -167,7 +181,11 @@
167
181
  },
168
182
  {
169
183
  "name": "hf_cooking_plan",
170
- "description": "Order a week's picked meals for cooking, most perishable first (fish, shellfish, ... vegetarian last), with a suggested day, why, time, key ingredients and recipe card; read-only."
184
+ "description": "Order a week's picked meals for cooking, most perishable first (fish, shellfish, ... vegetarian last), with a suggested day, why, time, key ingredients, pantry staples and recipe card; read-only."
185
+ },
186
+ {
187
+ "name": "hf_pantry_check",
188
+ "description": "List the pantry staples HelloFresh does not ship (salt, oil, butter...) for a week's picked meals, summed per ingredient and unit, with a one-line summary; read-only."
171
189
  },
172
190
  {
173
191
  "name": "hf_promo_status",
package/mint.yaml CHANGED
@@ -68,12 +68,26 @@ env:
68
68
  ~/.config/hellofresh-mcp/profiles.json, read only when it exists). When
69
69
  hosted, the file must live under the persistent dataDir; otherwise use
70
70
  HELLOFRESH_PROFILES.
71
+ - name: HELLOFRESH_SESSION_FILE
72
+ required: false
73
+ help: >-
74
+ Where the HelloFresh session (token set, never the customer's id or
75
+ email) is kept so it survives a restart. Defaults to
76
+ .hellofresh-mcp/session.json under the persistent dataDir (MCP_DATA_DIR),
77
+ else under HOME.
78
+ - name: HELLOFRESH_SESSION_CACHE
79
+ required: false
80
+ help: >-
81
+ on (default) keeps the session on disk across restarts; false keeps it
82
+ in memory only, so every start reads it from the browser again.
71
83
  state:
72
84
  dataDir: true
73
85
  reason: >-
74
86
  keeps the fetchproxy identity under
75
87
  $HOME/.fetchproxy/identity/hellofresh-mcp.json so the browser pairing
76
- survives restarts; without it every cold start asks the user to re-pair
88
+ survives restarts (without it every cold start asks the user to re-pair),
89
+ and the HelloFresh session under .hellofresh-mcp/session.json so a cold
90
+ start can reuse it while the browser is away
77
91
  # The server process dials only the HelloFresh API on www.hellofresh.com. The
78
92
  # apiV2Auth cookie is read and written only by the user's browser over the
79
93
  # bridge, never by this process.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrischall/hellofresh-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "mcpName": "io.github.chrischall/hellofresh-mcp",
6
6
  "description": "Unofficial HelloFresh (US) MCP server for Claude — subscription, weekly deliveries, menus, meal picks, skips and box sizes — developed and maintained by AI (Claude Code)",
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/chrischall/hellofresh-mcp",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.2.0",
9
+ "version": "0.4.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "@chrischall/hellofresh-mcp",
14
- "version": "0.2.0",
14
+ "version": "0.4.0",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  },
@@ -57,6 +57,18 @@
57
57
  "description": "Path to a JSON file of meal-planner profiles. Defaults to ~/.config/hellofresh-mcp/profiles.json, read only when it exists.",
58
58
  "isRequired": false,
59
59
  "format": "string"
60
+ },
61
+ {
62
+ "name": "HELLOFRESH_SESSION_FILE",
63
+ "description": "Where the HelloFresh session is kept across restarts (token set only, 0600). Defaults to .hellofresh-mcp/session.json under MCP_DATA_DIR, else HOME.",
64
+ "isRequired": false,
65
+ "format": "string"
66
+ },
67
+ {
68
+ "name": "HELLOFRESH_SESSION_CACHE",
69
+ "description": "on (default) keeps the session on disk across restarts; false keeps it in memory only.",
70
+ "isRequired": false,
71
+ "format": "string"
60
72
  }
61
73
  ]
62
74
  }
@@ -68,7 +68,14 @@ means the browser may be signed out: same remedy.
68
68
  - `hf_cooking_plan` `{week}` — the week's picks in cook order, most perishable
69
69
  first (fish → shellfish → other seafood → poultry → ground meat → beef/pork/lamb
70
70
  → vegetarian; ties by shorter time), each with a suggested day from the
71
- delivery date, why, time and key ingredients.
71
+ delivery date, why, time, key ingredients and `pantry` (the staples to have
72
+ on hand).
73
+ - `hf_pantry_check` `{week, view?}` — what to have in the pantry: the staples
74
+ HelloFresh does NOT ship (salt, pepper, oil, often butter/eggs/sugar/flour)
75
+ across the week's picks, summed per ingredient and unit (× quantity; "to
76
+ taste" when unmeasured) with the dishes using each, and a one-line `summary`
77
+ to pass on. `notes` flags nearest-yield amounts; `unread` names any recipe it
78
+ could not read.
72
79
 
73
80
  Reads take `view`: `compact` (default) is enough to decide; ask for `full` only
74
81
  for a field compact leaves out. Every `price` amount is in US dollars, whatever
@@ -187,7 +194,7 @@ On a host that groups MCPs by context (mcp-host's context groups), every tool
187
194
  but `hf_healthcheck` is in the **food** group, with these intents:
188
195
 
189
196
  - **whats-on** — `hf_list_deliveries`, the group's one canonical read (its `view: "brief"` gives one line per week); `hf_cooking_plan` (not canonical: the week's cook order).
190
- - **lookup** — `hf_get_subscription`, `hf_get_delivery`, `hf_get_menu`, `hf_list_box_sizes`, `hf_recent_picks`, `hf_list_profiles`, `hf_get_recipe`, `hf_list_favorites`, `hf_list_ratings`, `hf_promo_status`.
197
+ - **lookup** — `hf_get_subscription`, `hf_get_delivery`, `hf_get_menu`, `hf_list_box_sizes`, `hf_recent_picks`, `hf_list_profiles`, `hf_get_recipe`, `hf_pantry_check`, `hf_list_favorites`, `hf_list_ratings`, `hf_promo_status`.
191
198
  - **change** — `hf_select_meals`, `hf_set_week_size`, `hf_set_week_delivery_day`, `hf_skip_week`, `hf_unskip_week`, `hf_change_plan_size`, `hf_change_delivery_schedule`, `hf_favorite_recipe`, `hf_unfavorite_recipe`.
192
199
  - **other** — `hf_suggest_meals`, `hf_weekly_plan`, `hf_plan_weeks`.
193
200