formlab-mcp 0.6.66 → 0.6.68
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 +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
- package/theoretical.js +30 -1
- package/tools/analytics.js +63 -6
- package/tools/ingredients.js +5 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Ask Claude (or another MCP client) things like:
|
|
|
33
33
|
| `find_similar_formulations` | Find formulas using a given ingredient ≥ threshold % |
|
|
34
34
|
| `compare_formulations` | Pairwise side-by-side composition diff |
|
|
35
35
|
| `list_ingredients` | Filtered list of raw materials. Filters: `family`, `supplier`, `name_contains`, `in_stock_only`, `ingredient_class` (small-molecule / surfactant / polymer / extract / fragrance / pigment / sequence / mixture), `sequence_contains` (e.g. `KTTKS` → Matrixyl), `taxon_contains` (e.g. `Centella`) |
|
|
36
|
-
| `get_ingredient` | Full record + supplier / **cost ($/kg)** / stock / chemical name / molecular weight / storage / formulations using it, plus **GHS safety** (pictograms, H/P codes, signal word), **per-jurisdiction regulatory status**, **approved sources** (the suppliers / manufacturers qualified to supply this material — ASL/AML), and **inventory lots** (balances + expiry + the source each was received from). Returns every class-specific sub-object when present: `sequence` (peptide / oligo), `taxon` (NCBI ID + scientific name), `ingredientClass`, `extractDetails`, `sequenceDetails`, `polymerDetails`, `surfactantDetails`, `pigmentDetails`, `fragranceDetails`, and its **custom fields** with units (`customFields`: protein / carb / fat in g/100g, solids %… — what theoretical parameters read) |
|
|
36
|
+
| `get_ingredient` | Full record + supplier / **cost ($/kg)** / stock / chemical name / molecular weight / storage / formulations using it, plus **GHS safety** (pictograms, H/P codes, signal word), **per-jurisdiction regulatory status**, **approved sources** (the suppliers / manufacturers qualified to supply this material — ASL/AML), and **inventory lots** (balances + expiry + the source each was received from). Returns every class-specific sub-object when present: `sequence` (peptide / oligo), `taxon` (NCBI ID + scientific name), `ingredientClass`, `extractDetails`, `sequenceDetails`, `polymerDetails`, `surfactantDetails`, `pigmentDetails`, `fragranceDetails`, and its **custom fields** with units (`customFields`: protein / carb / fat in g/100g, solids %… — what theoretical parameters read), and its **reactive groups** (EEW, AHEW, OH number, NCO %, acid / amine value: as entered, in the datasheet's terms and meq/g, with any row the app ignores and why) |
|
|
37
37
|
| `list_lots` | Inventory lots across ingredients (each a received batch with its own remaining balance, supplier, expiry, **unit cost**, **status** — `active` / `hold` / `quarantine` / `rejected`; held lots are blocked from consumption, with a `holdReason` — and the **approved source** it was received from: `source.supplier` + `source.manufacturer`, where recalls hinge on the manufacturer). Each lot also reports its **Certificate of Analysis** (`coa`: linked, or matched by lot number) and `coaMissing` for an in-stock lot without one. Filters: `ingredient_id`, `expiring_within_days`, `status` (e.g. `hold` to find lots held for a recall), `missing_coa` |
|
|
38
38
|
| `list_suppliers` | Supplier / manufacturer records with roll-ups — ingredients approved, lots received / on hand (+ value at paid cost), qualified / trial / disqualified source counts, last receipt; lots count by supplier **and** by manufacturer |
|
|
39
39
|
| `get_supplier` | One supplier in full: record, every ingredient it's an approved source for, every lot from it, and the **recall trace** (batches that consumed those lots → products, shipments, samples, sub-batches; lots on hold flagged) |
|
|
@@ -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, 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) |
|
|
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). Leave out `parameter` for **All parameters**: every parameter's spec status and months to spec, out of spec first, and the one that limits shelf life |
|
|
56
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` |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formlab-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.68",
|
|
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.
|
|
5
|
+
"version": "0.6.68",
|
|
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.
|
|
11
|
+
"version": "0.6.68",
|
|
12
12
|
"runtimeHint": "npx",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
package/theoretical.js
CHANGED
|
@@ -26,7 +26,26 @@ function source() {
|
|
|
26
26
|
// Runs inside the vm: evaluates one formulation's (or batch's) parameters and
|
|
27
27
|
// returns a JSON string, so only plain text crosses back.
|
|
28
28
|
const EPILOGUE = `
|
|
29
|
-
;function
|
|
29
|
+
;function __rx(id) {
|
|
30
|
+
var ing = (db.ingredients || []).find(function (x) { return x && x.id === id; });
|
|
31
|
+
if (!ing) return '[]';
|
|
32
|
+
var meq = flRxIngMeq(ing);
|
|
33
|
+
var stored = ing.reactiveGroups || [];
|
|
34
|
+
var counted = []; // the stored row each group's value came from (the app takes the first valid one)
|
|
35
|
+
var out = Object.keys(meq).map(function (g) {
|
|
36
|
+
var e = stored.find(function (x) { return x && x.group === g && flRxMeq(x, ing.mw) != null; });
|
|
37
|
+
if (e) counted.push(e);
|
|
38
|
+
return { group: g, label: FL_RX_GROUPS[g].label, datasheet: flRxTermText(g, meq[g]), meqPerG: +meq[g].toPrecision(4),
|
|
39
|
+
entered: e ? { basis: FL_RX_BASES[e.basis].label, value: +e.value } : 'water, counted by its CAS number' };
|
|
40
|
+
});
|
|
41
|
+
stored.forEach(function (x) {
|
|
42
|
+
if (!x || counted.indexOf(x) >= 0) return;
|
|
43
|
+
var why = !FL_RX_GROUPS[x.group] ? 'unknown group' : !FL_RX_BASES[x.basis] ? 'unknown basis' : (x.basis === 'f' && !(+ing.mw > 0)) ? 'groups per molecule needs the MW' : !(+x.value > 0) ? 'no positive value' : 'a second row for the group (the first counts)';
|
|
44
|
+
out.push({ group: x.group, ignored: true, entered: { basis: (FL_RX_BASES[x.basis] || {}).label || x.basis, value: x.value }, why: why });
|
|
45
|
+
});
|
|
46
|
+
return JSON.stringify(out);
|
|
47
|
+
}
|
|
48
|
+
function __theo(kind, id) {
|
|
30
49
|
var coll = kind === 'batch' ? db.batches : db.formulations;
|
|
31
50
|
var e = (coll || []).find(function (x) { return x && x.id === id; });
|
|
32
51
|
if (!e) return '[]';
|
|
@@ -66,6 +85,16 @@ function contextFor(db) {
|
|
|
66
85
|
return ctx;
|
|
67
86
|
}
|
|
68
87
|
|
|
88
|
+
// An ingredient's reactive groups as the app reads them (js/reactive.js): [{ group, label, datasheet ("AHEW 42.6
|
|
89
|
+
// g/eq"), meqPerG, entered: { basis, value } }], plus the rows it ignores and why (ignored: true, why).
|
|
90
|
+
export function reactiveGroups(db, id) {
|
|
91
|
+
try {
|
|
92
|
+
const ctx = contextFor(db);
|
|
93
|
+
vm.runInContext('var __rid = ' + JSON.stringify(String(id)) + ';', ctx);
|
|
94
|
+
return JSON.parse(vm.runInContext('__rx(__rid)', ctx, { timeout: 2000 }));
|
|
95
|
+
} catch (e) { return []; }
|
|
96
|
+
}
|
|
97
|
+
|
|
69
98
|
// [{ name, value, unit, formula, error, warning, spec, pass, pinned, basis }] —
|
|
70
99
|
// value null when it can't be computed (error says why); warning is the Params
|
|
71
100
|
// tab's ⚠ note ("2 ingredients missing carb", "sugar in mixed units (…)");
|
package/tools/analytics.js
CHANGED
|
@@ -1663,21 +1663,73 @@ function _mcpArrhenius(points, spec, atC, order, targetMonths) {
|
|
|
1663
1663
|
return out;
|
|
1664
1664
|
}
|
|
1665
1665
|
|
|
1666
|
+
// get_stability without a parameter: the app's All parameters plot (FormLab 47i) as numbers. Every parameter the
|
|
1667
|
+
// entity was tested for, each run through get_stability itself, out of spec now first, then by months to spec (the
|
|
1668
|
+
// earliest condition's projection from T0); the first to cross is the parameter that limits shelf life. The app's
|
|
1669
|
+
// order before that: numeric before graded, then most readings (_stabAvailableParameters).
|
|
1670
|
+
async function _mcpAllParameters(entity, entityType, sampleIds, args, db) {
|
|
1671
|
+
const names = new Map(); // lower case → { name, n, numeric }
|
|
1672
|
+
(db.testResults || []).filter(t => sampleIds.has(t.sampleId)).forEach(t => (t.measurements || []).forEach(m => {
|
|
1673
|
+
const name = (m.parameter || '').trim(); if (!name) return;
|
|
1674
|
+
const k = name.toLowerCase(), ty = _mcpMeasType(m);
|
|
1675
|
+
if (!names.has(k)) names.set(k, { name, n: 0, numeric: false });
|
|
1676
|
+
const e = names.get(k); e.n++; if (ty !== 'ordinal' && ty !== 'categorical') e.numeric = true;
|
|
1677
|
+
}));
|
|
1678
|
+
const order = [...names.values()].sort((a, b) => (b.numeric - a.numeric) || (b.n - a.n));
|
|
1679
|
+
const rows = [];
|
|
1680
|
+
for (const p of order) {
|
|
1681
|
+
const r = await get_stability.handler({ ...args, parameter: p.name });
|
|
1682
|
+
if (!r || r.error || !(r.series || []).length) continue;
|
|
1683
|
+
const graded = r.kind === 'ordinal' || r.kind === 'categorical';
|
|
1684
|
+
const failing = r.series.filter(se => graded ? (se.latest && se.latest.pf === 'fail') : se._latestFail).map(se => se.condition);
|
|
1685
|
+
const shelf = graded ? [] : r.series.filter(se => se.shelfLife && se.shelfLife._pointTotal != null)
|
|
1686
|
+
.sort((a, b) => a.shelfLife._pointTotal - b.shelfLife._pointTotal);
|
|
1687
|
+
const first = shelf[0] || null;
|
|
1688
|
+
rows.push({
|
|
1689
|
+
parameter: p.name, kind: graded ? r.kind : 'numeric', ...(r.unit ? { unit: r.unit } : {}),
|
|
1690
|
+
spec: graded ? r.spec : ((r.spec && (r.spec.min != null || r.spec.max != null)) ? { min: r.spec.min, max: r.spec.max } : null),
|
|
1691
|
+
conditions: r.series.map(se => se.condition), testDates: r.pointCount,
|
|
1692
|
+
outOfSpecNow: failing.length > 0, ...(failing.length ? { outOfSpecConditions: failing } : {}),
|
|
1693
|
+
shelfLife: first ? { condition: first.condition, fromT0Months: first.shelfLife.fromT0Months, ci95FromT0Months: first.shelfLife.ci95FromT0Months,
|
|
1694
|
+
verdict: first.shelfLife.verdict, headingToward: first.shelfLife.headingToward } : null,
|
|
1695
|
+
_t: first ? first.shelfLife._pointTotal : Infinity,
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
if (!rows.length) return { error: `No dated measurements on ${entity.uid || entity.id}.` };
|
|
1699
|
+
rows.sort((a, b) => (b.outOfSpecNow - a.outOfSpecNow) || (a._t - b._t));
|
|
1700
|
+
const ranked = rows.filter(r => r.shelfLife).sort((a, b) => a._t - b._t);
|
|
1701
|
+
const formula = entityType === 'formulation' ? entity
|
|
1702
|
+
: (db.formulations || []).find(f => f.id === (entity.formulationId || ((db.batches || []).find(b => b.id === entity.batchId) || {}).formulationId)) || null;
|
|
1703
|
+
const ownT = formula ? parseFloat(formula.shelfLifeMonths) : NaN, defT = parseFloat(db.defaultShelfLifeMonths);
|
|
1704
|
+
const target = (Number.isFinite(ownT) && ownT > 0) ? { months: ownT, source: 'formula' }
|
|
1705
|
+
: (Number.isFinite(defT) && defT > 0) ? { months: defT, source: 'workspace default' } : null;
|
|
1706
|
+
return {
|
|
1707
|
+
entity: { type: entityType, uid: entity.uid, name: entity.name || entity.uid },
|
|
1708
|
+
allParameters: true,
|
|
1709
|
+
outOfSpecNow: rows.filter(r => r.outOfSpecNow).map(r => r.parameter),
|
|
1710
|
+
limitingParameter: ranked.length ? { parameter: ranked[0].parameter, ...ranked[0].shelfLife } : null,
|
|
1711
|
+
then: ranked.slice(1, 3).map(r => ({ parameter: r.parameter, condition: r.shelfLife.condition, fromT0Months: r.shelfLife.fromT0Months })),
|
|
1712
|
+
targetShelfLife: target,
|
|
1713
|
+
parameters: rows.map(({ _t, ...r }) => r),
|
|
1714
|
+
note: 'Every parameter the entity was tested for, as the app\'s All parameters plot: each judged on its own spec, out of spec now first (the latest test date of any condition failed), then by months to spec. shelfLife = the earliest-crossing condition\'s projection from T0 (point estimate and 95% bound, verdict against targetShelfLife), null = no reportable projection or a ranked / text parameter (those have no regression). limitingParameter = the first to cross spec: it sets the shelf life; then = the next two. For one parameter\'s full analysis (series, drift, control chart, time points, Arrhenius) call get_stability with that parameter.',
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1666
1718
|
const get_stability = {
|
|
1667
1719
|
definition: {
|
|
1668
1720
|
name: 'get_stability',
|
|
1669
|
-
description: 'Grounded stability / shelf-life analysis for one entity × parameter — the deterministic numbers behind the Stability & Trends view. Pass a formulation (pools all its samples), a sample (that sample over time), or a batch (pools its samples) by id or UID, plus a parameter name. Returns the time series, drift (per-month slope + R²), an individuals control chart (mean ± 3σ + out-of-control points), spec status, and an ICH-flavored projected shelf life (linear extrapolation to the spec crossing: point estimate + the conservative 95%-confidence-bound crossing). When measurements carry run conditions (e.g. Storage 25 °C vs 40 °C) it splits into one series per condition — a true accelerated-vs-ambient comparison. A point is one TEST DATE: every reading taken that day under that condition is averaged (points = test dates, readings = the raw count), so replicates never count as separate time points in the drift, control chart or shelf-life fit — the same points as the app. A ranked-scale (ordinal, e.g. pencil hardness) or text (e.g. appearance) parameter returns kind "ordinal" / "categorical" instead: per-condition points with the label (median rank for an ordinal), pass/fail, firstFail, latest and scaleShift — the app\'s step / pass-fail-strip trend, with no regression. Also returns timePoints (the app\'s Time points plot: per condition, what was tested at each time point, skipped pulls, the next pull with its due date and whether it is overdue, on the formula\'s own pull schedule or the standard one) and arrhenius (the app\'s Arrhenius plot: rates at the storage temperatures fitted to predict the rate and shelf life at predict_at_c, with 95% CIs and a verdict against the target shelf life). Use these figures directly; do not re-derive the regression.',
|
|
1721
|
+
description: 'Grounded stability / shelf-life analysis for one entity × parameter — the deterministic numbers behind the Stability & Trends view. Pass a formulation (pools all its samples), a sample (that sample over time), or a batch (pools its samples) by id or UID, plus a parameter name. Returns the time series, drift (per-month slope + R²), an individuals control chart (mean ± 3σ + out-of-control points), spec status, and an ICH-flavored projected shelf life (linear extrapolation to the spec crossing: point estimate + the conservative 95%-confidence-bound crossing). When measurements carry run conditions (e.g. Storage 25 °C vs 40 °C) it splits into one series per condition — a true accelerated-vs-ambient comparison. A point is one TEST DATE: every reading taken that day under that condition is averaged (points = test dates, readings = the raw count), so replicates never count as separate time points in the drift, control chart or shelf-life fit — the same points as the app. A ranked-scale (ordinal, e.g. pencil hardness) or text (e.g. appearance) parameter returns kind "ordinal" / "categorical" instead: per-condition points with the label (median rank for an ordinal), pass/fail, firstFail, latest and scaleShift — the app\'s step / pass-fail-strip trend, with no regression. Also returns timePoints (the app\'s Time points plot: per condition, what was tested at each time point, skipped pulls, the next pull with its due date and whether it is overdue, on the formula\'s own pull schedule or the standard one) and arrhenius (the app\'s Arrhenius plot: rates at the storage temperatures fitted to predict the rate and shelf life at predict_at_c, with 95% CIs and a verdict against the target shelf life). Without a parameter it returns every parameter at once (the app\'s All parameters plot): out of spec now first, then by months to spec, and limitingParameter, the one that crosses spec first and so sets the shelf life. Use these figures directly; do not re-derive the regression.',
|
|
1670
1722
|
inputSchema: {
|
|
1671
1723
|
type: 'object',
|
|
1672
1724
|
properties: {
|
|
1673
1725
|
entity_id: { type: 'string', description: 'A formulation, sample, or batch — id or UID (e.g. FRM-002, SMP-007, BTC-001). The type is auto-detected and sets the pooling level.' },
|
|
1674
|
-
parameter: { type: 'string', description: 'The measured parameter to analyze (case-insensitive, e.g. "Niacinamide assay").' },
|
|
1726
|
+
parameter: { type: 'string', description: 'The measured parameter to analyze (case-insensitive, e.g. "Niacinamide assay"). Leave it out for every parameter at once: each one\'s spec status and months to spec, and the parameter that limits shelf life.' },
|
|
1675
1727
|
by_condition: { type: 'boolean', description: 'Split the series by captured storage condition (default true). Set false to pool all conditions into one trend.' },
|
|
1676
1728
|
predict_at_c: { type: 'number', description: 'Arrhenius: the storage temperature (°C) to predict the rate and shelf life at (default 25; the app offers 5, 25 and 30).' },
|
|
1677
1729
|
order: { type: 'string', enum: ['zero', 'first'], description: 'Arrhenius kinetics: "zero" (a steady change per month, default) or "first" (a steady % change per month, e.g. an assay or viscosity falling by a share of what is left). meanR2ByOrder compares the two.' },
|
|
1678
1730
|
as_of: { type: 'string', description: 'Date (YYYY-MM-DD) that time points\' next pulls are counted from (due in / overdue). Default today.' },
|
|
1679
1731
|
},
|
|
1680
|
-
required: ['entity_id'
|
|
1732
|
+
required: ['entity_id'],
|
|
1681
1733
|
},
|
|
1682
1734
|
},
|
|
1683
1735
|
handler: async (args) => {
|
|
@@ -1693,7 +1745,7 @@ const get_stability = {
|
|
|
1693
1745
|
: new Set((db.samples || []).filter(s => (entityType === 'batch' ? s.batchId : s.formulationId) === entity.id).map(s => s.id));
|
|
1694
1746
|
|
|
1695
1747
|
const paramLc = (args.parameter || '').trim().toLowerCase();
|
|
1696
|
-
if (!paramLc) return
|
|
1748
|
+
if (!paramLc) return _mcpAllParameters(entity, entityType, sampleIds, args, db);
|
|
1697
1749
|
const points = [];
|
|
1698
1750
|
const skipped = { ordinal: 0, categorical: 0 };
|
|
1699
1751
|
const graded = []; // ordinal / text readings, for the step / strip trend (12w)
|
|
@@ -1788,6 +1840,7 @@ const get_stability = {
|
|
|
1788
1840
|
const ys = pts.map(p => p.value);
|
|
1789
1841
|
const n = ys.length;
|
|
1790
1842
|
const out = { points: n, readings: pts.reduce((a, p) => a + (p.readings || 1), 0), from: pts[0].date.toISOString().slice(0, 10), to: pts[n - 1].date.toISOString().slice(0, 10), values: ys.map(v => _round(v, 6)), latest: _round(ys[n - 1], 6) };
|
|
1843
|
+
Object.defineProperty(out, '_latestFail', { value: pts[n - 1].pf === 'fail' });
|
|
1791
1844
|
if (n < 2) { out.note = 'Fewer than 2 points — no trend/shelf-life.'; return out; }
|
|
1792
1845
|
// Drift on real elapsed months (not point order), like the shelf-life
|
|
1793
1846
|
// projection and the app's Stability view: uneven ICH schedules
|
|
@@ -1826,17 +1879,21 @@ const get_stability = {
|
|
|
1826
1879
|
overdue: as ? as.overdue : false,
|
|
1827
1880
|
reportable: !!as,
|
|
1828
1881
|
};
|
|
1882
|
+
// For the all-parameters ranking: the unrounded months from T0, and whether the latest test date failed.
|
|
1883
|
+
if (out.shelfLife && as) Object.defineProperty(out.shelfLife, '_pointTotal', { value: as.pointTotal });
|
|
1829
1884
|
return out;
|
|
1830
1885
|
};
|
|
1831
1886
|
|
|
1887
|
+
// A spread drops analyze's non-enumerable _latestFail (for the all-parameters ranking): carry it over.
|
|
1888
|
+
const withCond = (condition, pts) => { const a = analyze(pts); return Object.defineProperty({ condition, ...a }, '_latestFail', { value: a._latestFail }); };
|
|
1832
1889
|
const split = args.by_condition !== false && points.some(p => p.cond);
|
|
1833
1890
|
let series;
|
|
1834
1891
|
if (split) {
|
|
1835
1892
|
const byC = new Map();
|
|
1836
1893
|
points.forEach(p => { const k = p.cond || '(no condition)'; if (!byC.has(k)) byC.set(k, []); byC.get(k).push(p); });
|
|
1837
|
-
series = [...byC.keys()].sort().map(k => (
|
|
1894
|
+
series = [...byC.keys()].sort().map(k => withCond(k, byC.get(k)));
|
|
1838
1895
|
} else {
|
|
1839
|
-
series = [
|
|
1896
|
+
series = [withCond(null, points)];
|
|
1840
1897
|
}
|
|
1841
1898
|
|
|
1842
1899
|
return {
|
package/tools/ingredients.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { getStore, resolveById } from '../data.js';
|
|
8
8
|
import { ingredientSmiles } from '../peptide.js';
|
|
9
|
+
import { reactiveGroups } from '../theoretical.js';
|
|
9
10
|
|
|
10
11
|
// FormLab's export is the raw db, so ingredients carry the APP field shapes:
|
|
11
12
|
// `cas` (not casNumber) and `cost = {value, currency, unit}` (not a flat
|
|
@@ -170,7 +171,7 @@ const list_ingredients = {
|
|
|
170
171
|
const get_ingredient = {
|
|
171
172
|
definition: {
|
|
172
173
|
name: 'get_ingredient',
|
|
173
|
-
description: 'Get full details for a single ingredient: cost ($/kg), GHS safety (pictograms / H- / P-codes / signal word), per-jurisdiction regulatory status, approved sources (the suppliers/manufacturers qualified to supply this material — ASL/AML), inventory lots (balances + expiry + the source each was received from), recent stock movements, and the formulations using it, plus its `customFields` (name, value, unit — e.g. protein / carb / fat in g/100g, solids %; what theoretical parameters read). Accepts internal id or UID (e.g. ING-001).',
|
|
174
|
+
description: 'Get full details for a single ingredient: cost ($/kg), GHS safety (pictograms / H- / P-codes / signal word), per-jurisdiction regulatory status, approved sources (the suppliers/manufacturers qualified to supply this material — ASL/AML), inventory lots (balances + expiry + the source each was received from), recent stock movements, and the formulations using it, plus its `customFields` (name, value, unit — e.g. protein / carb / fat in g/100g, solids %; what theoretical parameters read) and `reactiveGroups` (EEW, AHEW, OH number, NCO %, acid / amine value, Si-H, vinyl, water: the datasheet value as entered, the same in the datasheet\'s own terms, and meq/g; rows the app ignores are listed with why). Accepts internal id or UID (e.g. ING-001).',
|
|
174
175
|
inputSchema: {
|
|
175
176
|
type: 'object',
|
|
176
177
|
properties: {
|
|
@@ -228,6 +229,9 @@ const get_ingredient = {
|
|
|
228
229
|
// (protein / carb / fat in g/100g for nutrition, solids % for NV, …).
|
|
229
230
|
// The unit is a label; a 0 is a value.
|
|
230
231
|
customFields: (ing.customFields || []).filter(c => c && c.name).map(c => ({ name: c.name, value: c.value != null ? c.value : '', unit: c.unit || '', ...(c.info ? { info: c.info } : {}) })),
|
|
232
|
+
// Reactive groups (EEW, AHEW, OH number, NCO %, acid / amine value, Si-H, vinyl, water) as the app reads them,
|
|
233
|
+
// in the datasheet's terms and meq/g, with any row it ignores and why.
|
|
234
|
+
reactiveGroups: reactiveGroups(db, ing.id),
|
|
231
235
|
safety,
|
|
232
236
|
regulatory,
|
|
233
237
|
lots,
|