formlab-mcp 0.6.62 → 0.6.63

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/README.md CHANGED
@@ -52,7 +52,7 @@ Ask Claude (or another MCP client) things like:
52
52
  | `compare_batches` | Reproducibility of 2+ runs (ideally of one formula): each run's **yield %**, actual produced mass, cost/kg; per-ingredient **drift** across the runs vs the formula's proposed wt-%; and the biggest **outlier** run. `basis`: `wt_percent` (default) or `amount` |
53
53
  | `get_batch_pivot` | Production analytics — aggregate batches by `group_by` (formula / status / month / prepared_by / project) × `metric` (count, avg_yield_pct, total_produced_kg, avg_cost_per_batch, total_samples, total_tests), with share + total for additive metrics. Optional `batch_uids` scope + `status` filter |
54
54
  | `get_project_pivot` | Portfolio analytics — aggregate projects by `group_by` (status / phase / priority / business_unit / site / customer / lead, or `cf:<custom field>`) × `metric` (count, total_formulas / batches / samples, total_cost, avg_formulas / batches / cost_per_batch), rolling child activity + cost up by any project attribute. Optional `project_uids` scope |
55
- | `get_stability` | Grounded stability / shelf-life analysis for a formulation, sample or batch × parameter (auto-detected): time-series, drift (per-month slope + R²), an I-chart (mean ±3σ + out-of-control points), spec status, and an ICH-Q1E-flavored projected shelf life (point + 95%-CI crossing), all on **one point per test date per run condition** (replicates averaged, never separate time points), split by storage condition. A ranked-scale (ordinal) or text parameter returns its step / pass-fail series instead: per-condition points, firstFail, latest, scaleShift. Also the app's **Time points** (per condition: tested time points, skipped pulls, the next pull with its due date and whether it's overdue, on the formula's own pull schedule or the standard one; `as_of`) and **Arrhenius** (rates at the storage temperatures → the rate, Ea, Q10 and shelf life at `predict_at_c`, zero or first `order`, with 95% CIs and a verdict against the target) |
55
+ | `get_stability` | Grounded stability / shelf-life analysis for a formulation, sample or batch × parameter (auto-detected): time-series, drift (per-month slope + R²), an I-chart (mean ±3σ + out-of-control points), spec status, and an ICH-Q1E-flavored projected shelf life (point + 95%-CI crossing), all on **one point per test date per run condition** (replicates averaged, never separate time points), split by storage condition. A ranked-scale (ordinal) or text parameter returns its step / pass-fail series instead: per-condition points, firstFail, latest, scaleShift. Also the app's **Time points** (per condition: tested time points, skipped pulls, the next pull with its due date and whether it's overdue, on the formula's own pull schedule, in months or weeks, or the standard one; `as_of`) and **Arrhenius** (rates at the storage temperatures → the rate, Ea, Q10 and shelf life at `predict_at_c`, zero or first `order`, with 95% CIs and a verdict against the target) |
56
56
  | `get_design_space` | COMPOSITION design space for one project, several (`projects`) or any formula list (`formulas`, across projects — like the app's Scope → DOE Matrix): which ingredients vary and over what observed wt-% ranges (ranked), an occupied-region summary ("where you've been"), the biggest untested **interior gap** as ready-to-seed DOE ranges (a combination you could have made but skipped), and an optional standardised **2-component PCA** of all varying ingredients — loadings, variance-explained, scree, and a full-dimensional gap. Optional `axes` (choose the 2–3 axes), `by_role` (map ingredients summed by primary Function, e.g. Pigment / Solvent / Film Former — no gap, roles aren't DOE factors) and `property` (highest / lowest formula plus the ingredients whose level tracks it, Spearman ρ). Reports formulas that aren't on the map and the spread on it. Matches the in-app Design Space Viewer exactly. Answers *"where haven't I explored?"* / *"what should I formulate next?"* |
57
57
  | `list_doe_designs` | Saved DOE designs — the *recipe* behind each batch of runs: design type, factors + ranges, constraints, run count, D-efficiency. Filters: `project`, `design_type`, `constrained_only`, `name_contains` |
58
58
  | `get_doe_design` | One design in full: constraints in plain language, the model it was optimised for, generation settings (run budget, replicates, centre points, seed) and the complete run matrix with the formulation each run became |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formlab-mcp",
3
- "version": "0.6.62",
3
+ "version": "0.6.63",
4
4
  "mcpName": "io.github.juliu1980/formlab-mcp",
5
5
  "description": "Read-only Model Context Protocol server for FormLab. Lets Claude and other MCP clients read and analyze your FormLab data, from a local export file or your live cloud workspace.",
6
6
  "homepage": "https://formvix.com/mcp",
package/server.json CHANGED
@@ -2,13 +2,13 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.juliu1980/formlab-mcp",
4
4
  "description": "Read-only MCP server for FormLab formulation data: a local export file or your live cloud workspace.",
5
- "version": "0.6.62",
5
+ "version": "0.6.63",
6
6
  "websiteUrl": "https://formvix.com/mcp",
7
7
  "packages": [
8
8
  {
9
9
  "registryType": "npm",
10
10
  "identifier": "formlab-mcp",
11
- "version": "0.6.62",
11
+ "version": "0.6.63",
12
12
  "runtimeHint": "npx",
13
13
  "transport": {
14
14
  "type": "stdio"
@@ -1356,18 +1356,31 @@ function _shelfLifeAssess(sl, targetMonths, now) {
1356
1356
  const _MS_PER_DAY = 86400000;
1357
1357
  const _PULLS_ACCEL = [1, 2, 3, 6];
1358
1358
  const _PULLS_LONG = [1, 2, 3, 6, 9, 12, 18, 24, 36];
1359
- // A time point from days since T₀: T₀ (≤ 3 days), weeks under 3 weeks, else whole months. key = days, for sorting.
1360
- function _tpBucket(days) {
1359
+ // A time point from days since T₀: T₀ (≤ 3 days), weeks under 3 weeks (or past the last week a schedule names), else
1360
+ // whole months. key = days, for sorting.
1361
+ function _tpBucket(days, weekDays = 21) {
1361
1362
  if (days <= 3) return { key: 0, label: 'T₀' };
1362
- if (days < 21) { const w = Math.max(1, Math.round(days / 7)); return { key: w * 7, label: `${w} wk` }; }
1363
+ if (days < weekDays) { const w = Math.max(1, Math.round(days / 7)); return { key: w * 7, label: `${w} wk` }; }
1363
1364
  const m = Math.max(1, Math.round(days / 30.4375));
1364
1365
  return { key: Math.round(m * 30.4375), label: `${m} mo` };
1365
1366
  }
1366
- // A formula's own pull months (Stability → Time points → Pull schedule): { long, accel }, accel = 35 °C and up.
1367
+ // A pull on a schedule: a number of months, or "<n>w" for weeks (Jun, 1 Nov: short accelerated and freeze-thaw
1368
+ // studies pull at 1, 2, 4 weeks).
1369
+ function _pullWeeks(e) { const w = typeof e === 'string' && /^(\d*\.?\d+)w$/.exec(e); return w ? +w[1] : null; }
1370
+ function _pullDays(e) { const w = _pullWeeks(e); return w != null ? w * 7 : +e * 30.4375; }
1371
+ function _pullLabel(e) { const w = _pullWeeks(e); return w != null ? `${w} wk` : `${+e} mo`; }
1372
+ // Valid pulls, one per day count, in time order.
1373
+ function _pullsClean(a) {
1374
+ if (!Array.isArray(a)) return [];
1375
+ const seen = new Set();
1376
+ return a.map(e => _pullWeeks(e) != null ? e : Number(e)).filter(e => _pullDays(e) > 0)
1377
+ .sort((x, y) => _pullDays(x) - _pullDays(y)).filter(e => { const d = _pullDays(e); return !seen.has(d) && seen.add(d); });
1378
+ }
1379
+ // A formula's own pull schedule (Stability → Time points → Pull schedule, or its Edit): { long, accel }, accel = 35 °C
1380
+ // and up.
1367
1381
  function _tpPlanOf(formula) {
1368
1382
  const p = formula && formula.stabilityPulls;
1369
- const ok = a => Array.isArray(a) ? [...new Set(a.map(Number).filter(m => m > 0))].sort((x, y) => x - y) : [];
1370
- return { long: p ? ok(p.long) : [], accel: p ? ok(p.accel) : [] };
1383
+ return { long: p ? _pullsClean(p.long) : [], accel: p ? _pullsClean(p.accel) : [] };
1371
1384
  }
1372
1385
  function _tpOwnPulls(plan, tC) {
1373
1386
  const own = plan && plan[tC != null && tC >= 35 ? 'accel' : 'long'];
@@ -1407,23 +1420,26 @@ function _mcpTimePoints(points, formula, targetMonths, now) {
1407
1420
  const rows = [...byCond.entries()].map(([cond, ps]) => ({ cond, ps, tC: cond ? _condTempC(cond) : null }))
1408
1421
  .sort((a, b) => (a.tC == null ? -Infinity : a.tC) - (b.tC == null ? -Infinity : b.tC) || a.cond.localeCompare(b.cond))
1409
1422
  .map(({ cond, ps, tC }) => {
1423
+ const ladder = _tpLadder(tC, targetMonths, plan);
1424
+ // A schedule in weeks keeps its time points in weeks up to its last week pull.
1425
+ const weekDays = Math.max(21, ...ladder.filter(e => _pullWeeks(e) != null).map(e => _pullDays(e) + 4));
1426
+ const keyOf = e => _tpBucket(_pullDays(e), weekDays).key;
1410
1427
  const cells = new Map();
1411
1428
  ps.forEach(p => {
1412
- const b = _tpBucket((p.date.getTime() - t0) / _MS_PER_DAY);
1429
+ const b = _tpBucket((p.date.getTime() - t0) / _MS_PER_DAY, weekDays);
1413
1430
  if (!cells.has(b.key)) cells.set(b.key, { ...b, dates: new Set(), pfs: [] });
1414
1431
  const c = cells.get(b.key); c.dates.add(day(p.date)); c.pfs.push(p.pf);
1415
1432
  });
1416
1433
  const lastKey = Math.max(...cells.keys());
1417
- const ladder = _tpLadder(tC, targetMonths, plan);
1418
- const nextM = ladder.find(m => Math.round(m * 30.4375) > lastKey);
1419
- const due = nextM == null ? null : t0 + nextM * _MS_PER_MONTH;
1420
- return { cond, tC, cells, lastKey, ladder, ladderKeys: ladder.map(m => Math.round(m * 30.4375)), own: !!_tpOwnPulls(plan, tC),
1421
- next: nextM == null ? null : { timePoint: `${nextM} mo`, due: day(due), daysUntil: Math.floor((due - now) / _MS_PER_DAY) } };
1434
+ const nextE = ladder.find(e => keyOf(e) > lastKey);
1435
+ const due = nextE == null ? null : t0 + _pullDays(nextE) * _MS_PER_DAY;
1436
+ return { cond, tC, cells, lastKey, weekDays, ladder, ladderKeys: ladder.map(keyOf), own: !!_tpOwnPulls(plan, tC),
1437
+ next: nextE == null ? null : { timePoint: _pullLabel(nextE), due: day(due), daysUntil: Math.floor((due - now) / _MS_PER_DAY) } };
1422
1438
  });
1423
1439
  // Skipped: a time point before this row's last test that its schedule, or (on the standard one) another row at its
1424
- // temperature, has.
1440
+ // temperature on the standard one, has.
1425
1441
  rows.forEach(r => {
1426
- const peers = r.own ? [] : rows.filter(o => o !== r && (o.tC != null ? o.tC === r.tC : o.cond === r.cond));
1442
+ const peers = r.own ? [] : rows.filter(o => o !== r && !o.own && (o.tC != null ? o.tC === r.tC : o.cond === r.cond));
1427
1443
  const keys = new Set([...r.ladderKeys, ...peers.flatMap(o => [...o.cells.keys()])]);
1428
1444
  r.skipped = [...keys].filter(k => k > 0 && k < r.lastKey && !r.cells.has(k)).sort((a, b) => a - b);
1429
1445
  });
@@ -1433,10 +1449,10 @@ function _mcpTimePoints(points, formula, targetMonths, now) {
1433
1449
  condition: r.cond || null,
1434
1450
  temperatureC: r.tC != null ? _round(r.tC, 1) : null,
1435
1451
  schedule: r.own ? 'formula' : 'standard',
1436
- pullMonths: r.ladder,
1452
+ pulls: r.ladder.map(_pullLabel),
1437
1453
  tested: [...r.cells.values()].sort((a, b) => a.key - b.key).map(c => ({ timePoint: c.label, testDates: c.dates.size,
1438
1454
  pf: c.pfs.includes('fail') ? 'fail' : c.pfs.includes('pass') ? 'pass' : null })),
1439
- skipped: r.skipped.map(k => _tpBucket(k).label),
1455
+ skipped: r.skipped.map(k => _tpBucket(k, r.weekDays).label),
1440
1456
  next: r.next ? { ...r.next, overdue: r.next.daysUntil < 0 } : null,
1441
1457
  })),
1442
1458
  };
@@ -1725,8 +1741,8 @@ const get_stability = {
1725
1741
  targetShelfLife: target ? { months: target.months, source: target.source } : null,
1726
1742
  timePoints: _mcpTimePoints(points, formula, target && target.months, asOf),
1727
1743
  arrhenius: specVaries ? null : _mcpArrhenius(points, spec, Number.isFinite(+args.predict_at_c) && args.predict_at_c !== null && args.predict_at_c !== '' ? +args.predict_at_c : 25, args.order === 'first' ? 'first' : 'zero', target && target.months),
1728
- timePointsNote: 'timePoints: one row per storage condition, time points counted from t0 (the first test under any condition): tested (pf "fail" when any reading that time point failed), skipped (a time point before the last test that the schedule or another condition at that temperature has, but this one does not), next (the next pull not yet tested, its due date, daysUntil; overdue = past as_of; null = schedule complete). schedule "formula" = the formula\'s own pull months, else "standard": 1, 2, 3, 6 months at 35 °C and up; 1, 2, 3, 6, 9, 12, 18, 24, 36 months up to the target shelf life.',
1729
- arrheniusNote: 'arrhenius (null when no condition names a temperature): rates per storage temperature (3+ test dates each), ln(rate) against 1/T fitted and read at predictAtC: activation energy, Q10, the rate there with its 95% CI, and the shelf life there from the T0 value to the spec limit (ci95Months: a faster rate gives the low end). "> 120" = beyond 10 years. verdict as shelfLife.verdict, against targetShelfLife. realTimeShelfLifeMonths = the trend projection at predictAtC itself when that temperature was tested. why = no prediction, and the reason.',
1744
+ timePointsNote: 'timePoints: one row per storage condition, time points counted from t0 (the first test under any condition): tested (pf "fail" when any reading that time point failed), skipped (a time point before the last test that the schedule or another condition at that temperature has, but this one does not), next (the next pull not yet tested, its due date, daysUntil; overdue = past as_of; null = schedule complete). schedule "formula" = the formula\'s own pulls (months, or weeks such as "2 wk"), else "standard": 1, 2, 3, 6 months at 35 °C and up; 1, 2, 3, 6, 9, 12, 18, 24, 36 months up to the target shelf life; pulls lists the row\'s schedule.',
1745
+ arrheniusNote: 'arrhenius (null when no condition names a temperature): rates per storage temperature (3+ test dates each), ln(rate) against 1/T fitted and read at predictAtC: activation energy, Q10 (how many times faster 10 °C warmer, from predictAtC to predictAtC + 10; it varies with temperature), the rate there with its 95% CI, and the shelf life there from the T0 value to the spec limit (ci95Months: a faster rate gives the low end). "> 120" = beyond 10 years. verdict as shelfLife.verdict, against targetShelfLife. realTimeShelfLifeMonths = the trend projection at predictAtC itself when that temperature was tested. why = no prediction, and the reason.',
1730
1746
  note: 'shelfLife.fromT0Months / ci95FromT0Months are the projected shelf life counted from the first test (T0): point estimate and the conservative (ICH Q1E) 95%-bound crossing. remainingMonths / ci95Months are the same, counted from the last test. verdict compares against targetShelfLife: "short" = the trend crosses spec before the target, "marginal" = the trend clears it but the 95% bound does not, "meets" = both clear it; null = no target set (then concern is by time left: medium <3 mo or overdue, else info). A projection never reaches \"high\": high is reserved for a MEASURED out-of-spec value (spec.latestInSpec=false). short/overdue → medium, marginal/meets → info. overdue=true means projectedCrossDate is already past today (time left runs from the last test), so the sample is probably out of spec now — recommend a re-test. reportable=false means the app shows no projection (R² < 0.3, crossing already past, or beyond 5 years). Numbers are computed here — narrate them, do not recompute.',
1731
1747
  };
1732
1748
  },
@@ -30,8 +30,9 @@ function _trimFormulation(f) {
30
30
  // Target shelf life (months): sets finished-goods expiry AND is what
31
31
  // get_stability judges the projected shelf life against.
32
32
  shelfLifeMonths: f.shelfLifeMonths ?? null,
33
- // Its own stability pull months (Stability → Time points → Pull schedule): long = below 35 °C, accel = 35 °C and
34
- // up; null = the standard schedule. get_stability's timePoints follow it.
33
+ // Its own stability pull schedule (Stability → Time points → Pull schedule, or its Edit): long = below 35 °C,
34
+ // accel = 35 °C and up; a number is months, "2w" two weeks; null = the standard schedule. get_stability's timePoints
35
+ // follow it.
35
36
  stabilityPulls: f.stabilityPulls && (Array.isArray(f.stabilityPulls.long) || Array.isArray(f.stabilityPulls.accel)) ? { long: f.stabilityPulls.long || [], accel: f.stabilityPulls.accel || [] } : null,
36
37
  // Density of the MIXED product (g/mL), when declared — volume-targeted
37
38
  // batches scale by it instead of the ideal-mix estimate. null = not set.