formlab-mcp 0.7.1 → 0.7.3
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/index.js +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
- package/tools/formulations.js +1 -1
- package/tools/lab.js +2 -0
- package/vendor/equipment-calibration.js +9 -3
- package/vendor/fragrance.js +11 -8
package/index.js
CHANGED
|
@@ -149,11 +149,11 @@ const PKG_VERSION = (() => {
|
|
|
149
149
|
const INSTRUCTIONS = `Times ending in "Z" (createdAt, updatedAt, holdAt, releasedAt, issuedAt, shipment dates…) are UTC. This lab's time zone is ${LOCAL_TZ}: when you give a date or time from one, convert it to ${LOCAL_TZ} first (late evening there can already be the next day in UTC). Plain dates with no time (testDate, preparedDate, expiryDate, best-by) are calendar days as entered: give them as they are. Day fields the server works out (asOf, a report's day when it has no test date, a supplier's lastReceived) are already ${LOCAL_TZ} days.
|
|
150
150
|
|
|
151
151
|
FormLab's QC definitions (answer by these; never infer them):
|
|
152
|
-
- In doubt (a reading): its instrument failed or was found out of tolerance at a calibration, and the reading falls between the last good calibration before it (with none on record, one calibration interval back, 12 months if no interval is set) and the repair's pass (or today while it still fails), or it was saved while the instrument was Out of service. Later calibrations do not clear it; a retest replaces the reading, or someone closes the instrument's review with a reason. The value and pass/fail stand. Tools: list_test_results in_doubt, get_test_result inDoubt, get_equipment doubtWindows.
|
|
152
|
+
- In doubt (a reading): its instrument failed or was found out of tolerance at a calibration, and the reading falls between the last good calibration before it (with none on record, one calibration interval back, 12 months if no interval is set) and the repair's pass (or today while it still fails; on that day, reports entered after the calibration are not in doubt), or it was saved while the instrument was Out of service. Later calibrations do not clear it; a retest replaces the reading, or someone closes the instrument's review with a reason. The value and pass/fail stand. Tools: list_test_results in_doubt, get_test_result inDoubt, get_equipment doubtWindows.
|
|
153
153
|
- Retest: repeats only a report's out-of-spec and in-doubt readings, linked (retestOf); it replaces them in rollups and on the CoA.
|
|
154
154
|
- Same-day readings: one point per test date; a day's readings average only under one spec; when two panels judged the same parameter that day, the later report stands.
|
|
155
155
|
- Holds: a held batch cannot ship until released (the Dashboard counts held batches with stock left); a lot on hold has status "hold" (incoming QC puts a received lot on hold until its QC releases it; FormLab does not set "quarantine" or "rejected" today, so a lot awaiting QC is on hold, not quarantined).
|
|
156
|
-
- Certificate of Analysis: latest result per parameter against its spec; required results come from the formula's releasePanel when set, else every panel used. Hard blocks: on hold, not made, no results. Out of spec ("Does not conform") and missing required results ("Not tested") can be issued with an override and a reason; a reading in doubt is only a warning.`;
|
|
156
|
+
- Certificate of Analysis: latest result per parameter against its spec; required results come from the formula's releasePanel when set, else every panel used. Hard blocks: on hold, not made, no results. Out of spec ("Does not conform") and missing required results ("Not tested") can be issued with an override and a reason; a reading in doubt is only a warning. A shipment recorded with QC open keeps the open items and the reason given (get_batch stockLedger: shippedWithQcOpen, qcReason).`;
|
|
157
157
|
const server = new Server(
|
|
158
158
|
{ name: 'formlab-mcp', version: PKG_VERSION },
|
|
159
159
|
{ capabilities: { tools: {} }, instructions: INSTRUCTIONS }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formlab-mcp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
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.7.
|
|
5
|
+
"version": "0.7.3",
|
|
6
6
|
"websiteUrl": "https://formvix.com/mcp",
|
|
7
7
|
"packages": [
|
|
8
8
|
{
|
|
9
9
|
"registryType": "npm",
|
|
10
10
|
"identifier": "formlab-mcp",
|
|
11
|
-
"version": "0.7.
|
|
11
|
+
"version": "0.7.3",
|
|
12
12
|
"runtimeHint": "npx",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
package/tools/formulations.js
CHANGED
|
@@ -200,7 +200,7 @@ const get_formulation = {
|
|
|
200
200
|
const get_fragrance_compliance = {
|
|
201
201
|
definition: {
|
|
202
202
|
name: 'get_fragrance_compliance',
|
|
203
|
-
description: 'A formulation\'s fragrance compliance as FormLab\'s Fragrance tab computes it (Pro; live workspace only): each fragrance material\'s % in the finished product against its IFRA limit for the product category (through sub-formulas), the highest dosage that passes and the material that limits it, and the EU fragrance allergens summed across materials with the ones to name on the label (above 0.001% leave-on, 0.01% rinse-off). Every limit is one the lab typed from a supplier\'s IFRA certificate; FormLab holds no IFRA limits of its own, so a material with no limit or declaration on file is reported as unknown and state is then "incomplete", never "conforms". Optional what-if inputs (not saved): category (IFRA product category, e.g. "5A" body lotion, "4" fine fragrance), use ("leave-on" | "rinse-off"), dosage (percent of a fragrance oil in the finished product). The result is based on the certificates on file and is not a certification: say so when you report it.',
|
|
203
|
+
description: 'A formulation\'s fragrance compliance as FormLab\'s Fragrance tab computes it (Pro; live workspace only): each fragrance material\'s % in the finished product against its IFRA limit for the product category (through sub-formulas), the highest dosage that passes and the material that limits it, and the EU fragrance allergens summed across materials with the ones to name on the label (above 0.001% leave-on, 0.01% rinse-off; category 12, candles and air care with no skin contact, needs no product use: allergens.applies is false there). Every limit is one the lab typed from a supplier\'s IFRA certificate; FormLab holds no IFRA limits of its own, so a material with no limit or declaration on file is reported as unknown and state is then "incomplete", never "conforms". Optional what-if inputs (not saved): category (IFRA product category, e.g. "5A" body lotion, "4" fine fragrance), use ("leave-on" | "rinse-off"), dosage (percent of a fragrance oil in the finished product). The result is based on the certificates on file and is not a certification: say so when you report it.',
|
|
204
204
|
inputSchema: {
|
|
205
205
|
type: 'object',
|
|
206
206
|
properties: {
|
package/tools/lab.js
CHANGED
|
@@ -440,6 +440,8 @@ const get_batch = {
|
|
|
440
440
|
// parentBatchId === this id (see list_batches).
|
|
441
441
|
stockLedger: (Array.isArray(b.stockLedger) ? b.stockLedger : []).map(e => ({
|
|
442
442
|
date: e.ts || null, delta: e.delta ?? null, unit: e.unit || b.unit || '', kind: e.kind || '', note: e.note || '',
|
|
443
|
+
...(e.customer ? { customer: e.customer } : {}),
|
|
444
|
+
...(Array.isArray(e.qcOpen) && e.qcOpen.length ? { shippedWithQcOpen: e.qcOpen, qcReason: e.qcReason || null } : {}),
|
|
443
445
|
})),
|
|
444
446
|
shippedQty: (Array.isArray(b.stockLedger) ? b.stockLedger : []).reduce((s, e) => e.kind === 'shipment' ? s + Math.abs(parseFloat(e.delta) || 0) : s, 0),
|
|
445
447
|
// Finished-batch hold: while set, the app records no shipment of this batch (QA / complaint / recall).
|
|
@@ -178,13 +178,19 @@ function eqCalWindows(e, todayIso) {
|
|
|
178
178
|
lookBack = eqCalInterval(e) || EQ_CAL_LOOKBACK_MONTHS; lookBackDefault = !eqCalInterval(e);
|
|
179
179
|
since = _eqCalSubMonths(bad.date, lookBack);
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
// untilAt: when the calibration that ends the window was entered (the adjustment itself, or the repair's pass).
|
|
182
|
+
// On that day, a report entered after it was taken on the corrected instrument (Jun, 1 Dec: RV-2's "Reference
|
|
183
|
+
// check, after calibration" read In doubt because the window took the whole day).
|
|
184
|
+
const ender = kind === 'adjusted' ? bad : (fixed && fixed.date === until ? fixed : null);
|
|
185
|
+
const untilAt = (ender && ender.loggedAt) || '';
|
|
186
|
+
out.push({ calId: bad.id || '', kind, at: bad.date || '', since, lookBack, lookBackDefault, until, untilAt, fixedAt: kind === 'fail' && fixed ? (fixed.date || '') : '', review: bad.id ? eqCalReviewOf(e, bad.id) : null });
|
|
182
187
|
});
|
|
183
188
|
return out;
|
|
184
189
|
}
|
|
185
190
|
function _eqCalWindowTests(w, tests) {
|
|
186
191
|
const day = (t) => String((t && t.testDate) || '').split('T')[0];
|
|
187
|
-
|
|
192
|
+
const after = (t) => !!(w.untilAt && t && t.createdAt && String(t.createdAt) > String(w.untilAt));
|
|
193
|
+
return (tests || []).filter(t => { const d = day(t); return d && (!w.since || d > w.since) && (!w.until || d < w.until || (d === w.until && !after(t))); })
|
|
188
194
|
.sort((a, b) => day(a).localeCompare(day(b)));
|
|
189
195
|
}
|
|
190
196
|
// The latest window still open (its review not closed), with its reports and batches; null when none is open.
|
|
@@ -200,7 +206,7 @@ function eqCalSuspect(e, tests, todayIso) {
|
|
|
200
206
|
const b = sm && sm.batchId ? (db.batches || []).find(x => x && x.id === sm.batchId && !x._trashed) : null;
|
|
201
207
|
if (b && !batches.includes(b)) batches.push(b);
|
|
202
208
|
});
|
|
203
|
-
return { calId: w.calId, kind: w.kind, at: w.at, since: w.since, lookBack: w.lookBack, lookBackDefault: w.lookBackDefault, until: w.until, fixedAt: w.fixedAt, tests: hit, batches, open: open.length };
|
|
209
|
+
return { calId: w.calId, kind: w.kind, at: w.at, since: w.since, lookBack: w.lookBack, lookBackDefault: w.lookBackDefault, until: w.until, untilAt: w.untilAt, fixedAt: w.fixedAt, tests: hit, batches, open: open.length };
|
|
204
210
|
}
|
|
205
211
|
|
|
206
212
|
// ---- Readings in doubt (Jun, 30 Nov: "Flag doubtful readings"; shared with the MCP server) ----
|
package/vendor/fragrance.js
CHANGED
|
@@ -33,6 +33,8 @@ const FL_FR_USES = { 'leave-on': 'Leave-on', 'rinse-off': 'Rinse-off' };
|
|
|
33
33
|
// Label when the allergen in the finished product is ABOVE this (% w/w): Annex III, column h.
|
|
34
34
|
const FL_FR_LABEL_OVER = { 'leave-on': 0.001, 'rinse-off': 0.01 };
|
|
35
35
|
// A stored or passed value is a use only when it is one of the two keys themselves: FL_FR_USES['constructor'] is truthy.
|
|
36
|
+
// Category 12 (candles, air care) has no skin contact: the cosmetic leave-on / rinse-off labelling does not apply.
|
|
37
|
+
const _frgUseApplies = (cat) => String(cat || '').toUpperCase() !== '12';
|
|
36
38
|
const _frgIsUse = (v) => typeof v === 'string' && Object.prototype.hasOwnProperty.call(FL_FR_USES, v);
|
|
37
39
|
|
|
38
40
|
// The individually labelled fragrance allergens: Annex III of Regulation (EC) No 1223/2009 as amended by Regulation
|
|
@@ -279,7 +281,7 @@ function flFrCompute(f, opts) {
|
|
|
279
281
|
st.use = _frgIsUse(st.use) ? st.use : '';
|
|
280
282
|
st.dosage = _frgNum(st.dosage) > 0 && _frgNum(st.dosage) <= FL_FR_DOSAGE_MAX ? _frgNum(st.dosage) : 100;
|
|
281
283
|
const out = { has: false, category: st.category, use: st.use, dosage: st.dosage, rootOil: false, rows: [], others: [], noLimit: [], noDecl: [],
|
|
282
|
-
noSource: [], unresolved: 0, max: [], allergens: [], unlisted: [], toLabel: [], over: [], verdict: 'setup', why: [] };
|
|
284
|
+
noSource: [], unresolved: 0, max: [], allergens: [], unlisted: [], toLabel: [], over: [], verdict: 'setup', why: [], useApplies: _frgUseApplies(st.category) };
|
|
283
285
|
if (!f) return out;
|
|
284
286
|
const wk = _frgWalk(f), k = st.dosage / 100;
|
|
285
287
|
out.rootOil = wk.rootOil; out.unresolved = wk.unresolved.length;
|
|
@@ -372,14 +374,14 @@ function flFrCompute(f, opts) {
|
|
|
372
374
|
|
|
373
375
|
const n = (a, one, many) => a.length + ' ' + (a.length === 1 ? one : many);
|
|
374
376
|
if (!st.category) out.why.push('Choose the product category.');
|
|
375
|
-
if (!st.use) out.why.push('Choose leave-on or rinse-off.');
|
|
377
|
+
if (!st.use && out.useApplies) out.why.push('Choose leave-on or rinse-off.');
|
|
376
378
|
if (out.over.length) out.why.push(n(out.over, 'material is', 'materials are') + ' over the limit.');
|
|
377
379
|
if (out.noLimit.length) out.why.push(n(out.noLimit, 'material has', 'materials have') + ' no limit on file for category ' + st.category + '.');
|
|
378
380
|
if (out.noDecl.length) out.why.push(n(out.noDecl, 'material has', 'materials have') + ' no allergen declaration.');
|
|
379
381
|
if (out.noSource.length) out.why.push(n(out.noSource, 'entry has', 'entries have') + ' no source document.');
|
|
380
382
|
if (out.unresolved) out.why.push('Part of the composition could not be weighed.');
|
|
381
383
|
out.verdict = !st.category ? 'setup' : out.over.length ? 'over'
|
|
382
|
-
: (!st.use || out.noLimit.length || out.noDecl.length || out.noSource.length || out.unresolved) ? 'unknown' : 'conforms';
|
|
384
|
+
: ((!st.use && out.useApplies) || out.noLimit.length || out.noDecl.length || out.noSource.length || out.unresolved) ? 'unknown' : 'conforms';
|
|
383
385
|
return out;
|
|
384
386
|
}
|
|
385
387
|
// A food, drink or supplement: IFRA and the cosmetic allergen list do not apply to it.
|
|
@@ -477,7 +479,7 @@ function flFrSummary(f, opts) {
|
|
|
477
479
|
reasons: c.why.slice(),
|
|
478
480
|
unknown: { noLimit: c.noLimit.slice(), noDeclaration: c.noDecl.slice(), noSourceDocument: c.noSource.map(x => `${x.name} (${x.what})`), notChecked: c.others.slice() },
|
|
479
481
|
allergens: {
|
|
480
|
-
use: c.use, threshold: thr, complete: !c.noDecl.length && !!c.use,
|
|
482
|
+
use: c.use, applies: c.useApplies !== false, threshold: thr, complete: !c.noDecl.length && (!!c.use || c.useApplies === false),
|
|
481
483
|
toLabel: c.toLabel.slice(),
|
|
482
484
|
rows: c.allergens.map(a => ({ name: a.name, cas: a.cas, pctInProduct: +a.pct.toPrecision(6), label: a.label, from: a.sources.map(x => x.name) })),
|
|
483
485
|
notOnEuList: c.unlisted.map(a => ({ name: a.name, cas: a.cas, pctInProduct: +a.pct.toPrecision(6) })),
|
|
@@ -502,7 +504,8 @@ function _frgStatementBlocks(f, table) {
|
|
|
502
504
|
s.materials.map(m => ({ name: m.name, pct: p(m.pctInProduct), limit: m.limit, status: m.status, amendment: m.amendment || '—', document: m.document || 'None on file' })))}
|
|
503
505
|
${s.unknown.notChecked.length ? `<p class="muted">Not fragrance materials, not checked: ${e(s.unknown.notChecked.join(', '))}.</p>` : ''}`;
|
|
504
506
|
const a = s.allergens;
|
|
505
|
-
const lead = !a.use ? '
|
|
507
|
+
const lead = !a.use && !a.applies ? 'Cosmetic allergen labelling (leave-on or rinse-off) does not apply to category 12, no skin contact.'
|
|
508
|
+
: !a.use ? 'Leave-on or rinse-off is not set on the formula, so the label column cannot be decided.'
|
|
506
509
|
: a.toLabel.length ? `To name on the label (above ${a.threshold}% in a ${a.use} product): ${a.toLabel.join(', ')}.` : `None above ${a.threshold}% in a ${a.use} product.`;
|
|
507
510
|
const rows = a.rows.map(r => ({ name: r.name, cas: r.cas || '—', pct: p(r.pctInProduct), label: r.label == null ? '—' : r.label ? 'Label' : 'Below', from: r.from.join(', ') }))
|
|
508
511
|
.concat(a.notOnEuList.map(r => ({ name: r.name, cas: r.cas || '—', pct: p(r.pctInProduct), label: 'Not on the EU list', from: '' })));
|
|
@@ -541,7 +544,7 @@ function flFrAiLine(f) {
|
|
|
541
544
|
const mats = s.materials.slice(0, 12).map(m => `${m.name} ${_frgPct(m.pctInProduct)}% vs ${m.limit}${m.status === 'Pass' || m.status === 'Not restricted' ? '' : ' [' + m.status + ']'}`).join(', ');
|
|
542
545
|
const al = s.allergens;
|
|
543
546
|
return `${s.statement} ${max ? 'Max dosage: ' + max + '. ' : ''}Materials (% in product vs limit): ${mats}${s.materials.length > 12 ? ` (+${s.materials.length - 12} more)` : ''}.`
|
|
544
|
-
+ (al.use ? ` Allergens to label (${al.use}, above ${al.threshold}%): ${al.toLabel.length ? al.toLabel.join(', ') : 'none'}${al.missing.length ? ` [incomplete: ${al.missing.length} without a declaration]` : ''}.` : ' Allergen labelling undecided: leave-on or rinse-off not set.')
|
|
547
|
+
+ (al.use ? ` Allergens to label (${al.use}, above ${al.threshold}%): ${al.toLabel.length ? al.toLabel.join(', ') : 'none'}${al.missing.length ? ` [incomplete: ${al.missing.length} without a declaration]` : ''}.` : al.applies ? ' Allergen labelling undecided: leave-on or rinse-off not set.' : ' Cosmetic allergen labelling does not apply (category 12, no skin contact).')
|
|
545
548
|
+ ` ${s.basis}`;
|
|
546
549
|
} catch (_) { return ''; }
|
|
547
550
|
}
|
|
@@ -714,7 +717,7 @@ function _frgControlsHtml(f, c) {
|
|
|
714
717
|
return `<div class="card"><div class="card-header"><h2>Product</h2><span id="fr-saved" class="fl-saved-tick" role="status"></span></div>
|
|
715
718
|
<div class="card-body nl-form fr-form-side">
|
|
716
719
|
<label>IFRA category<select id="fr-cat-in" onchange="flFrSet('${id}','category',this.value)"><option value="">Choose…</option>${FL_FR_CATEGORIES.map(k => `<option value="${k}"${c.category === k ? ' selected' : ''}>${_frgEsc(_frgCatText(k))}</option>`).join('')}</select></label>
|
|
717
|
-
|
|
720
|
+
${c.useApplies || c.use ? `<label>Product use<span class="nl-unit"><span class="fl-seg-group sm" role="group" aria-label="Product use">${seg('leave-on')}${seg('rinse-off')}</span></span></label>` : ''}
|
|
718
721
|
${c.rootOil ? `<label data-tip="How much of this oil goes into the finished product. 100 checks it as sold.">Dosage in the product<span class="nl-unit"><input id="fr-dose-in" type="number" min="0" max="100" step="any" inputmode="decimal" value="${st.dosage !== 100 ? _frgEsc(String(st.dosage)) : ''}" placeholder="100" onchange="flFrSet('${id}','dosage',this.value)"><em>%</em></span></label>` : ''}
|
|
719
722
|
${c.others.length ? `<div class="fr-dim" data-tip="${_frgEsc(c.others.slice(0, 12).join(', ') + (c.others.length > 12 ? ` +${c.others.length - 12} more` : ''))}">${c.others.length} other ${c.others.length === 1 ? 'ingredient is not a fragrance material' : 'ingredients are not fragrance materials'}. Not checked.</div>` : ''}
|
|
720
723
|
</div></div>`;
|
|
@@ -749,7 +752,7 @@ function flFrTabHtml(f) {
|
|
|
749
752
|
<div class="card"><div class="card-header"><h2>IFRA</h2></div>
|
|
750
753
|
<div class="card-body">${_frgVerdictHtml(c)}${_frgMaxHtml(c)}${_frgIfraTableHtml(c)}</div></div>
|
|
751
754
|
<div class="card"><div class="card-header"><h2>Allergens <span class="nl-sub">EU</span></h2></div>
|
|
752
|
-
<div class="card-body">${c.use ? `<div class="fr-dim fr-lead">${c.toLabel.length ? `<strong>${c.toLabel.length} to name on the label</strong> (above ${FL_FR_LABEL_OVER[c.use]}% ${c.use}).` : `None above ${FL_FR_LABEL_OVER[c.use]}% ${c.use}.`}${c.noDecl.length ? ' Incomplete: ' + c.noDecl.length + ' without a declaration.' : ''}</div>` :
|
|
755
|
+
<div class="card-body">${c.use ? `<div class="fr-dim fr-lead">${c.toLabel.length ? `<strong>${c.toLabel.length} to name on the label</strong> (above ${FL_FR_LABEL_OVER[c.use]}% ${c.use}).` : `None above ${FL_FR_LABEL_OVER[c.use]}% ${c.use}.`}${c.noDecl.length ? ' Incomplete: ' + c.noDecl.length + ' without a declaration.' : ''}</div>` : `<div class="fr-dim fr-lead">${c.useApplies ? 'Choose leave-on or rinse-off to see which to label.' : 'Cosmetic allergen labelling does not apply to category 12 (no skin contact).'}</div>`}
|
|
753
756
|
${_frgAllergenTableHtml(c)}
|
|
754
757
|
<div class="fr-dim fr-legal">Based on the certificates and declarations on file. Not a certification.</div></div></div>
|
|
755
758
|
</div>
|