formlab-mcp 0.6.64 → 0.6.65

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
@@ -53,7 +53,7 @@ Ask Claude (or another MCP client) things like:
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
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), and per series the **moving range** (MR̄, its limit, the jumps above it) |
56
- | `list_stability_pulls` | Stability pulls due across the whole workspace (the app's Needs Attention row): every formula on a study, its next pull per storage condition overdue or due within `within_days` (default 7), on its own pull schedule or the standard one; a test of any parameter counts as the pull; studies more than 60 days late listed apart as stopped |
56
+ | `list_stability_pulls` | Stability pulls due across the whole workspace (the app's Needs Attention row): every formula on a study, its next pull per storage condition overdue or due within `within_days` (default 7), on its own pull schedule or the standard one, with the samples to pull; a test of any parameter counts as the pull; studies more than 60 days late listed apart as stopped |
57
57
  | `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?"* |
58
58
  | `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` |
59
59
  | `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.64",
3
+ "version": "0.6.65",
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.64",
5
+ "version": "0.6.65",
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.64",
11
+ "version": "0.6.65",
12
12
  "runtimeHint": "npx",
13
13
  "transport": {
14
14
  "type": "stdio"
@@ -1416,7 +1416,10 @@ function _condTempC(label) {
1416
1416
  const range = s.match(/(\d+(?:\.\d+)?)\s*(?:–|-|to)\s*(\d+(?:\.\d+)?)\s*(?:°|º|deg(?:rees)?\.?)?\s*([CF])\b/i);
1417
1417
  if (range) return toC((parseFloat(range[1]) + parseFloat(range[2])) / 2, range[3]);
1418
1418
  const one = s.match(/(^|[^\d.\-–])(-?\d+(?:\.\d+)?)\s*(?:°|º|deg(?:rees)?\.?)?\s*([CF])\b/i);
1419
- return one ? toC(parseFloat(one[2]), one[3]) : null;
1419
+ if (one) return toC(parseFloat(one[2]), one[3]);
1420
+ // ICH shorthand, temperature / humidity: "40/75", "25/60 % RH" (QA sweep, Jun 1 Nov).
1421
+ const ich = s.match(/(^|[^\d.\/])(-?\d{1,2})\s*\/\s*(\d{2,3})\s*(?:%\s*(?:RH)?)?(?![\d.\/])/i);
1422
+ return ich && +ich[3] >= 10 && +ich[3] <= 100 && +ich[2] >= -40 && +ich[2] <= 70 ? +ich[2] : null;
1420
1423
  }
1421
1424
  // The study at a glance, one row per storage condition (the app's Time points plot): what was tested at each time
1422
1425
  // point from the entity's T₀ (its first test under any condition), the time points skipped, and the next pull with
@@ -1435,7 +1438,9 @@ function _tpCond(ps, t0, tC, targetMonths, plan, now) {
1435
1438
  cells.get(b.key).points.push(p);
1436
1439
  });
1437
1440
  cells.forEach(c => { c.pf = c.points.some(p => p.pf === 'fail') ? 'fail' : c.points.some(p => p.pf === 'pass') ? 'pass' : null; });
1438
- const lastKey = Math.max(...cells.keys());
1441
+ // A test dated after today (a typo, or entered ahead) shows, but doesn't count as pulled yet (QA sweep, Jun 1 Nov).
1442
+ const done = [...cells.values()].filter(c => c.points.some(p => p.date.getTime() <= now + _MS_PER_DAY)).map(c => c.key);
1443
+ const lastKey = done.length ? Math.max(...done) : -1;
1439
1444
  const nextE = ladder.find(e => keyOf(e) > lastKey);
1440
1445
  const next = nextE == null ? null : (() => {
1441
1446
  const due = t0 + _pullDays(nextE) * _MS_PER_DAY;
@@ -1492,27 +1497,43 @@ function _mcpExplorationIds(db) {
1492
1497
  // any parameter counts as the pull; T₀ is the formula's first such test. Exploration runs, archived and trashed formulas
1493
1498
  // are left out; a pull more than _PULL_STALE_D days late is a study that stopped (returned apart, as `stopped`).
1494
1499
  const _PULL_STALE_D = 60;
1500
+ // A condition key naming how a reading was measured, not where the sample was stored.
1501
+ const _RUN_TEMP_KEY = /^(?:test|measur\w*|run|sample|bath|plate|probe|cell|oven)?\s*temp(?:erature)?$|^measured at$/i;
1502
+ // The storage part of a reading's conditions: the first with a temperature whose key isn't a measurement setting;
1503
+ // "RPM 50" beside it is left out, so it doesn't split the study.
1504
+ function _mcpStorageCond(m) {
1505
+ const c = m && m.conditions;
1506
+ if (!c || typeof c !== 'object') return '';
1507
+ for (const [k, v] of Object.entries(c)) {
1508
+ if (v == null || v === '' || _RUN_TEMP_KEY.test(String(k).trim())) continue;
1509
+ const one = `${k} ${v}`;
1510
+ if (_condTempC(one) != null) return one;
1511
+ }
1512
+ return '';
1513
+ }
1495
1514
  function _mcpPullsDue(db, now) {
1496
1515
  const due = [], stopped = [];
1497
1516
  const explore = _mcpExplorationIds(db);
1498
1517
  const defT = parseFloat(db.defaultShelfLifeMonths);
1499
1518
  const samplesOf = new Map();
1500
- (db.samples || []).forEach(x => { if (x && !x._trashed && x.formulationId) { if (!samplesOf.has(x.formulationId)) samplesOf.set(x.formulationId, new Set()); samplesOf.get(x.formulationId).add(x.id); } });
1519
+ const live = new Set(); // samples still on the shelf: a Discarded one is never named to pull
1520
+ (db.samples || []).forEach(x => { if (x && !x._trashed && x.formulationId) { if (!samplesOf.has(x.formulationId)) samplesOf.set(x.formulationId, new Set()); samplesOf.get(x.formulationId).add(x.id); if (x.status !== 'Discarded') live.add(x.id); } });
1501
1521
  const testsOf = new Map();
1502
1522
  (db.testResults || []).forEach(t => { if (t && !t._trashed && t.sampleId) { if (!testsOf.has(t.sampleId)) testsOf.set(t.sampleId, []); testsOf.get(t.sampleId).push(t); } });
1503
1523
  (db.formulations || []).forEach(f => {
1504
1524
  if (!f || f._trashed || f.deletedAt || f.status === 'Archived' || explore.has(f.id)) return;
1505
1525
  const sids = samplesOf.get(f.id);
1506
1526
  if (!sids) return;
1507
- const byCond = new Map(), params = new Map();
1527
+ const byCond = new Map(), params = new Map(), condSamples = new Map();
1508
1528
  sids.forEach(sid => (testsOf.get(sid) || []).forEach(t => {
1509
1529
  const day = String(t.testDate || '').slice(0, 10), ms = Date.parse(day);
1510
1530
  if (!Number.isFinite(ms)) return;
1511
1531
  (t.measurements || []).forEach(m => {
1512
- const cond = _mcpCondLabel(m).trim();
1513
- if (!cond || _condTempC(cond) == null) return;
1514
- if (!byCond.has(cond)) byCond.set(cond, new Map());
1532
+ const cond = _mcpStorageCond(m).trim();
1533
+ if (!cond) return;
1534
+ if (!byCond.has(cond)) { byCond.set(cond, new Map()); condSamples.set(cond, new Set()); }
1515
1535
  byCond.get(cond).set(day, ms);
1536
+ condSamples.get(cond).add(sid);
1516
1537
  const p = String(m.parameter || '').trim(); if (p) params.set(p, (params.get(p) || 0) + 1);
1517
1538
  });
1518
1539
  }));
@@ -1527,8 +1548,12 @@ function _mcpPullsDue(db, now) {
1527
1548
  const tC = _condTempC(cond);
1528
1549
  const r = _tpCond([...d.values()].map(ms => ({ date: new Date(ms) })), t0, tC, target, plan, now);
1529
1550
  if (!r.next) return;
1551
+ const sampleIds = [...condSamples.get(cond)].filter(id => live.has(id));
1552
+ if (!sampleIds.length) return; // every sample under it discarded: the study is over there
1553
+ const last = r.cells.get(r.lastKey);
1530
1554
  const row = { formula: { id: f.id, uid: f.uid || null, name: f.name || f.uid || 'Formula' }, condition: cond, temperatureC: _round(tC, 1),
1531
- schedule: r.own ? 'formula' : 'standard', t0: _dayOf(t0), lastTimePoint: r.cells.get(r.lastKey).label, ..._nextOut(r.next), parameter: param };
1555
+ schedule: r.own ? 'formula' : 'standard', t0: _dayOf(t0), lastTimePoint: last ? last.label : null, ..._nextOut(r.next), parameter: param,
1556
+ samples: sampleIds.map(id => { const x = (db.samples || []).find(y => y && y.id === id); return x ? (x.uid || x.id) : id; }) };
1532
1557
  (r.next.days < -_PULL_STALE_D ? stopped : due).push(row);
1533
1558
  });
1534
1559
  });
@@ -1831,7 +1856,7 @@ const get_stability = {
1831
1856
  const list_stability_pulls = {
1832
1857
  definition: {
1833
1858
  name: 'list_stability_pulls',
1834
- description: 'Stability pulls due across the whole workspace: the app\'s Needs Attention "stability pulls due" row, without naming a formula. Every formula on a stability study (tests under a storage condition with a temperature in its name, on 2+ dates) gives its next pull per condition, on the formula\'s own pull schedule or the standard one (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). A test of ANY parameter in a time point under that condition counts as the pull; T0 is the formula\'s first such test. Returns the pulls overdue or due within within_days (default 7), soonest first, with formula, condition, time point, due date, daysUntil (negative = overdue), schedule, the last time point tested, and the parameter the study measures most. A pull more than 60 days late is a study that stopped: listed apart under stopped. Exploration runs (DOE / screening), archived and trashed formulas are left out, as in the app. For one formula\'s full time-point grid use get_stability (timePoints).',
1859
+ description: 'Stability pulls due across the whole workspace: the app\'s Needs Attention "stability pulls due" row, without naming a formula. Every formula on a stability study (tests under a storage condition with a temperature in its name, on 2+ dates) gives its next pull per condition, on the formula\'s own pull schedule or the standard one (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). A test of ANY parameter in a time point under that condition counts as the pull; T0 is the formula\'s first such test. Returns the pulls overdue or due within within_days (default 7), soonest first, with formula, condition, time point, due date, daysUntil (negative = overdue), schedule, the last time point tested, the parameter the study measures most, and the samples to pull (UIDs; discarded ones left out, and a condition whose samples are all discarded has nothing due). Only the storage part of a reading\'s conditions counts (a measurement temperature such as Temperature 25 °C does not make a study); ICH shorthand such as 40/75 reads as 40 °C; a test dated after as_of does not count as pulled yet. A pull more than 60 days late is a study that stopped: listed apart under stopped. Exploration runs (DOE / screening), archived and trashed formulas are left out, as in the app. For one formula\'s full time-point grid use get_stability (timePoints).',
1835
1860
  inputSchema: {
1836
1861
  type: 'object',
1837
1862
  properties: {