formlab-mcp 0.6.69 → 0.6.71
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 +1 -1
- package/package.json +1 -1
- package/peptide.js +10 -1
- package/server.json +2 -2
- package/tools/analytics.js +37 -5
- package/tools/lab.js +6 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ Ask Claude (or another MCP client) things like:
|
|
|
42
42
|
| `list_batches` | Filtered list of production / lab-prep events |
|
|
43
43
|
| `get_batch` | Full record + actual composition, measured/derived **actual volume** (mass ÷ density, never a sum of per-ingredient volumes) and **actual mass** (yield, else summed as-prepared inputs — mL rows through that ingredient's density — else measured volume × density), **estimatedVolume** (mass ÷ the formula's finished density when no actual exists, flagged `estimate: true`), **plannedMass** for volume-target batches (target × finished density) and **formulaFinishedDensity**, the **process** method + any **process-factor values** (DOE inputs), samples + blend lineage, and — as a finished-goods lot — its storage **`location`** + finished-goods **`stockLedger`** (shipments out + adjustments; `shippedQty` total), and its **theoretical parameters computed on the batch as made** (actual composition when logged — `basis: "actual"` — else the recipe; the batch's own parameter list when it overrides the formula's) |
|
|
44
44
|
| `list_samples` | Filtered list of physical specimens |
|
|
45
|
-
| `get_sample` | Full record + canonical variant + test reports + blend lineage |
|
|
45
|
+
| `get_sample` | Full record + canonical variant + test reports + blend lineage + its stability pulls (next pull, or pulled at) |
|
|
46
46
|
| `list_test_results` | Filtered list of test reports (by sample, parameter, **measured-value range** (`value_min`/`value_max` — a curve at its final point, a distribution at its spec's statistic or D50), **grade** (`min_grade`/`max_grade` on a ranked scale), **text value** (`value_equals`), **run condition** (`condition`), date, or lab) |
|
|
47
47
|
| `get_test_result` | Full report: every measurement's value, spec, any per-measurement run **conditions**, and the **resolved instrument** (`instrumentSource`: row / method / run). Complex types carry a `representative` (time-series → final, distribution → D50; a distribution also its `bins` and, when its spec names a statistic, `judged` at it); a ranked grade carries its `scale` and `rank`; a time series adds `aggregated` (per-timestamp mean ± sd) and `pointReplicates` (repeat readings at one `t`). Report-level `seriesReplicates` lists parameters measured 2+ times as separate rows — point vs series replicates are distinct. Each measurement also gives its **effective spec** (`effectiveSpec`, `specSource`: override / template / parameter / none) and `passFail` — panel and Test Method specs apply exactly as in the app, and every pass/fail count across the tools uses the same rule |
|
|
48
48
|
| `get_doe_matrix` | Pivot matrix (CSV by default) — rows × ingredients × parameters. A parameter measured under two or more **run conditions** (storage 25 °C vs 40 °C) is one column per condition (`pH`, `pH · 40 °C`; the bare name is the base arm), never averaged together — same columns, in the same order (grouped by measurement type, the test panel's order within a group), as the app's DOE Matrix |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formlab-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.71",
|
|
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/peptide.js
CHANGED
|
@@ -25,7 +25,16 @@ const NTERM_SMILES = {
|
|
|
25
25
|
};
|
|
26
26
|
const CTERM_SMILES = { NH2: 'N', OMe: 'OC' };
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
// The app's _seqSplit / _seqFreeEnds / _tokenizeSequence (48y): any dash, spaces dropped, /…/ mods whole, and the free
|
|
29
|
+
// ends written out (H-…-OH, H-…-NH2) are the amine and the acid, not His and Hyp + His.
|
|
30
|
+
const SEQ_DASHES = /[\u2010-\u2015\u2212]/g;
|
|
31
|
+
function tokenize(raw) {
|
|
32
|
+
if (!raw || typeof raw !== 'string') return [];
|
|
33
|
+
const t = (raw.replace(SEQ_DASHES, '-').match(/\/[^\/]*\/|[^\/-]+/g) || []).map(s => s.replace(/\s+/g, '')).filter(Boolean);
|
|
34
|
+
const n = t.length, last = t[n - 1];
|
|
35
|
+
const freeN = n >= 3 && t[0] === 'H' && /^(OH|NH2|OMe)$/.test(last), freeC = n >= 2 && last === 'OH';
|
|
36
|
+
return t.slice(freeN ? 1 : 0, freeC ? -1 : undefined);
|
|
37
|
+
}
|
|
29
38
|
function residues(tokens) {
|
|
30
39
|
const out = [];
|
|
31
40
|
for (const tok of tokens) {
|
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.71",
|
|
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.71",
|
|
12
12
|
"runtimeHint": "npx",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
package/tools/analytics.js
CHANGED
|
@@ -1511,7 +1511,9 @@ function _mcpStorageCond(m) {
|
|
|
1511
1511
|
}
|
|
1512
1512
|
return '';
|
|
1513
1513
|
}
|
|
1514
|
-
|
|
1514
|
+
// perSample (a Map) also gets each sample's pulls, as the app's formula page reads them (stabNextPullsBySample): sid →
|
|
1515
|
+
// [{ condition, ...next, schedule, pulledAt }], a sample tested at one time point past T₀ being the container pulled.
|
|
1516
|
+
function _mcpPullsDue(db, now, perSample) {
|
|
1515
1517
|
const due = [], stopped = [];
|
|
1516
1518
|
const explore = _mcpExplorationIds(db);
|
|
1517
1519
|
const defT = parseFloat(db.defaultShelfLifeMonths);
|
|
@@ -1531,15 +1533,30 @@ function _mcpPullsDue(db, now) {
|
|
|
1531
1533
|
(t.measurements || []).forEach(m => {
|
|
1532
1534
|
const cond = _mcpStorageCond(m).trim();
|
|
1533
1535
|
if (!cond) return;
|
|
1534
|
-
if (!byCond.has(cond)) { byCond.set(cond, new Map()); condSamples.set(cond, new
|
|
1536
|
+
if (!byCond.has(cond)) { byCond.set(cond, new Map()); condSamples.set(cond, new Map()); }
|
|
1535
1537
|
byCond.get(cond).set(day, ms);
|
|
1536
|
-
condSamples.get(cond)
|
|
1538
|
+
const cs = condSamples.get(cond); // the containers stored under it, with their test days
|
|
1539
|
+
if (!cs.has(sid)) cs.set(sid, new Set());
|
|
1540
|
+
cs.get(sid).add(ms);
|
|
1537
1541
|
const p = String(m.parameter || '').trim(); if (p) params.set(p, (params.get(p) || 0) + 1);
|
|
1538
1542
|
});
|
|
1539
1543
|
}));
|
|
1540
1544
|
const conds = [...byCond.entries()].filter(([, d]) => d.size >= 2);
|
|
1541
1545
|
if (!conds.length) return;
|
|
1542
1546
|
const t0 = Math.min(...conds.flatMap(([, d]) => [...d.values()]));
|
|
1547
|
+
// A container in a chamber and not tested yet joins the study its storageLocation names (the app's 48v rule): the
|
|
1548
|
+
// same temperature, and a humidity it names picks between two.
|
|
1549
|
+
sids.forEach(sid => {
|
|
1550
|
+
if (testsOf.has(sid) || !live.has(sid)) return;
|
|
1551
|
+
const x = (db.samples || []).find(y => y && y.id === sid), loc = String((x && x.storageLocation) || '');
|
|
1552
|
+
const tC = loc ? _condTempC(loc) : null;
|
|
1553
|
+
if (tC == null) return;
|
|
1554
|
+
const at = conds.filter(([c]) => _condTempC(c) === tC);
|
|
1555
|
+
if (!at.length) return;
|
|
1556
|
+
const rh = (loc.match(/\/\s*(\d{2,3})|(\d{2,3})\s*%/) || []).slice(1).find(Boolean);
|
|
1557
|
+
const [cond] = (rh && at.find(([c]) => new RegExp(`(^|\\D)${rh}(\\D|$)`).test(c.replace(/-?\d+(?:\.\d+)?\s*°/, '')))) || at[0];
|
|
1558
|
+
condSamples.get(cond).set(sid, new Set());
|
|
1559
|
+
});
|
|
1543
1560
|
const ownT = parseFloat(f.shelfLifeMonths);
|
|
1544
1561
|
const target = ownT > 0 ? ownT : defT > 0 ? defT : null;
|
|
1545
1562
|
const plan = _tpPlanOf(f);
|
|
@@ -1548,7 +1565,7 @@ function _mcpPullsDue(db, now) {
|
|
|
1548
1565
|
const tC = _condTempC(cond);
|
|
1549
1566
|
const r = _tpCond([...d.values()].map(ms => ({ date: new Date(ms) })), t0, tC, target, plan, now);
|
|
1550
1567
|
if (!r.next) return;
|
|
1551
|
-
const sampleIds = [...condSamples.get(cond)].filter(id => live.has(id));
|
|
1568
|
+
const sampleIds = [...condSamples.get(cond).keys()].filter(id => live.has(id));
|
|
1552
1569
|
if (!sampleIds.length) return; // every sample under it discarded: the study is over there
|
|
1553
1570
|
const last = r.cells.get(r.lastKey);
|
|
1554
1571
|
// Every pull still ahead on this schedule, the next and each one after it: the app's pull calendar (47k).
|
|
@@ -1558,6 +1575,13 @@ function _mcpPullsDue(db, now) {
|
|
|
1558
1575
|
schedule: r.own ? 'formula' : 'standard', t0: _dayOf(t0), lastTimePoint: last ? last.label : null, ..._nextOut(r.next), parameter: param, ahead,
|
|
1559
1576
|
samples: sampleIds.map(id => { const x = (db.samples || []).find(y => y && y.id === id); return x ? (x.uid || x.id) : id; }) };
|
|
1560
1577
|
(r.next.days < -_PULL_STALE_D ? stopped : due).push(row);
|
|
1578
|
+
if (perSample && r.next.days >= -_PULL_STALE_D) sampleIds.forEach(id => {
|
|
1579
|
+
const keys = new Map();
|
|
1580
|
+
condSamples.get(cond).get(id).forEach(ms => { if (ms <= now + _MS_PER_DAY) { const b = _tpBucket((ms - t0) / _MS_PER_DAY, r.weekDays); keys.set(b.key, b.label); } });
|
|
1581
|
+
const pts = [...keys.entries()].sort((a, b) => a[0] - b[0]);
|
|
1582
|
+
if (!perSample.has(id)) perSample.set(id, []);
|
|
1583
|
+
perSample.get(id).push({ condition: cond, ..._nextOut(r.next), schedule: row.schedule, pulledAt: pts.length === 1 && pts[0][0] > 0 ? pts[0][1] : null });
|
|
1584
|
+
});
|
|
1561
1585
|
});
|
|
1562
1586
|
});
|
|
1563
1587
|
const byDays = (a, b) => a.daysUntil - b.daysUntil;
|
|
@@ -1949,7 +1973,15 @@ const list_stability_pulls = {
|
|
|
1949
1973
|
},
|
|
1950
1974
|
};
|
|
1951
1975
|
|
|
1952
|
-
|
|
1976
|
+
// One sample's pulls (get_sample): its studies' next pulls, soonest first, a container already pulled last.
|
|
1977
|
+
function _mcpSamplePulls(db, sample, now) {
|
|
1978
|
+
const per = new Map();
|
|
1979
|
+
const { due } = _mcpPullsDue(db, now, per);
|
|
1980
|
+
return { list: (per.get(sample.id) || []).sort((a, b) => (!!a.pulledAt - !!b.pulledAt) || a.daysUntil - b.daysUntil),
|
|
1981
|
+
formulaOnStudy: due.some(x => x.formula.id === sample.formulationId) };
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
export { _mcpSamplePulls, _mcpRepNumber, _mcpMeasType, _evalPassFail, _resolveSpec, _shelfLife, _shelfLifeAssess, _mcpCondTags, _mcpArmNames, _mcpCondDefaultScore, _mcpCondSig, _mcpCondLabel, _mcpParamGroupsOf };
|
|
1953
1985
|
// ============================================================
|
|
1954
1986
|
// compare_test_results — the app's Compare Results table (js/views/testing-
|
|
1955
1987
|
// compare.js), 13g. Items are formulas, batches, samples or test reports; each
|
package/tools/lab.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { getStore, resolveById } from '../data.js';
|
|
10
10
|
import { theoreticalParams } from '../theoretical.js';
|
|
11
|
+
import { _mcpSamplePulls } from './analytics.js';
|
|
11
12
|
|
|
12
13
|
// --- Self-contained unit conversion + actual-volume derivation ---------------
|
|
13
14
|
// The MCP server has no access to the app's cost.js helpers, so a small local
|
|
@@ -350,11 +351,12 @@ const list_samples = {
|
|
|
350
351
|
const get_sample = {
|
|
351
352
|
definition: {
|
|
352
353
|
name: 'get_sample',
|
|
353
|
-
description: 'Get full details for a single sample including its actual variant composition, all test results bound to it, blend lineage, and
|
|
354
|
+
description: 'Get full details for a single sample including its actual variant composition, all test results bound to it, blend lineage, storage info, and its stability pulls (the formula page\'s Next pull column): stabilityPulls lists each study it is stored under with the next time point, due date, daysUntil (negative = overdue) and schedule, soonest first; pulledAt names the one time point a container tested once past T0 was pulled for (it is no longer in the study). A sample not tested yet joins the study its storageLocation names (e.g. "Chamber 40 °C", "25/60"). Accepts internal id or UID (e.g. SAMP-0001).',
|
|
354
355
|
inputSchema: {
|
|
355
356
|
type: 'object',
|
|
356
357
|
properties: {
|
|
357
358
|
id: { type: 'string', description: 'Internal id or UID of the sample.' },
|
|
359
|
+
as_of: { type: 'string', description: 'Date (YYYY-MM-DD) its stability pulls count from. Default today.' },
|
|
358
360
|
},
|
|
359
361
|
required: ['id'],
|
|
360
362
|
},
|
|
@@ -364,6 +366,7 @@ const get_sample = {
|
|
|
364
366
|
const s = resolveById('samples', args.id);
|
|
365
367
|
if (!s) return { error: `No sample found for id "${args.id}".` };
|
|
366
368
|
const tests = (db.testResults || []).filter(t => t.sampleId === s.id);
|
|
369
|
+
const pulls = _mcpSamplePulls(db, s, args.as_of && /^\d{4}-\d{2}-\d{2}$/.test(args.as_of) ? Date.parse(args.as_of) : Date.now());
|
|
367
370
|
const canonical = (s.actualVariants || []).find(v => v.isCanonical) || (s.actualVariants || [])[0] || null;
|
|
368
371
|
const parents = Array.isArray(s.sourceBlend)
|
|
369
372
|
? s.sourceBlend.map(p => {
|
|
@@ -386,6 +389,8 @@ const get_sample = {
|
|
|
386
389
|
compositionRowCount: Array.isArray(canonical.composition) ? canonical.composition.length : 0,
|
|
387
390
|
} : null,
|
|
388
391
|
sourceBlendParents: parents,
|
|
392
|
+
stabilityPulls: pulls.list,
|
|
393
|
+
...(!tests.length && !pulls.list.length && pulls.formulaOnStudy ? { stabilityPullsNote: 'Not tested yet, and its storageLocation names none of its formula\'s study chambers (e.g. "40 °C"), so it has no pulls.' } : {}),
|
|
389
394
|
testCount: tests.length,
|
|
390
395
|
tests: tests.map(t => ({
|
|
391
396
|
id: t.id,
|