formlab-mcp 0.7.16 → 0.7.17
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/package.json +1 -1
- package/server.json +2 -2
- package/vendor/cost.js +21 -0
- package/vendor/fragrance.js +58 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formlab-mcp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.17",
|
|
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.17",
|
|
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.17",
|
|
12
12
|
"runtimeHint": "npx",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
package/vendor/cost.js
CHANGED
|
@@ -386,6 +386,16 @@ function flUnitOptionsHtml(units, cur) {
|
|
|
386
386
|
if (e.target.style.cursor !== c) e.target.style.cursor = c;
|
|
387
387
|
});
|
|
388
388
|
document.addEventListener('mouseout', function (e) { if (isCombo(e.target)) e.target.style.cursor = ''; });
|
|
389
|
+
// One highlight (.active) that the mouse moves as the arrow keys do (31c; hover lit a second row). Only a real pointer
|
|
390
|
+
// move counts, so rows the arrow keys scroll under a still pointer don't take it.
|
|
391
|
+
var lastXY = '';
|
|
392
|
+
document.addEventListener('mousemove', function (e) {
|
|
393
|
+
var xy = e.clientX + ',' + e.clientY; if (xy === lastXY) return; lastXY = xy;
|
|
394
|
+
var it = e.target && e.target.closest && e.target.closest('.fl-unit-combo-item');
|
|
395
|
+
if (!it) return;
|
|
396
|
+
var idx = items().indexOf(it);
|
|
397
|
+
if (idx >= 0 && idx !== activeIdx) highlight(idx);
|
|
398
|
+
});
|
|
389
399
|
// A click on the field reopens the list after a pick (the field kept focus,
|
|
390
400
|
// so no focusin fires). Capture phase: dialogs stop click propagation.
|
|
391
401
|
document.addEventListener('click', function (e) {
|
|
@@ -862,6 +872,17 @@ function flIsPieceUnit(u) {
|
|
|
862
872
|
const hit = t => Object.keys(t).some(k => k === raw || k.toLowerCase() === lower);
|
|
863
873
|
return !hit(MASS_TO_KG) && !hit(VOL_TO_L) && !(typeof LENGTH_TO_M !== 'undefined' && hit(LENGTH_TO_M));
|
|
864
874
|
}
|
|
875
|
+
// A count unit read with its number (dogfood 6 Dec: "24 jar of 24 jar", "2 candle returned"): 24 jars, 1 jar, 2 boxes.
|
|
876
|
+
// Only words people count (a piece unit or a pack); mass, volume, %, "each", codes and words already plural stay as written.
|
|
877
|
+
const FL_UNIT_NO_PLURAL = new Set(['each', 'ea', 'pc', 'pcs', 'unit', 'units', 'eq', 'mol', 'dozen', 'doz', 'gross', 'ream']);
|
|
878
|
+
function flUnitN(n, unit) {
|
|
879
|
+
const u = String(unit == null ? '' : unit), x = Math.abs(parseFloat(n));
|
|
880
|
+
if (!u || !isFinite(x) || x === 1 || u.length > 20 || !/^[a-z]+$/.test(u) || /s$/.test(u) || FL_UNIT_NO_PLURAL.has(u)) return u;
|
|
881
|
+
if (!(flIsPieceUnit(u) || FL_PACK_UNITS.has(u))) return u;
|
|
882
|
+
if (/(x|z|ch|sh)$/.test(u)) return u + 'es';
|
|
883
|
+
if (/[^aeiou]y$/.test(u)) return u.slice(0, -1) + 'ies';
|
|
884
|
+
return u + 's';
|
|
885
|
+
}
|
|
865
886
|
// The word for one piece in "Weight per …" (5 Dec, Jun: "is per piece better or per unit better because piece itself is
|
|
866
887
|
// a unit"): the stock unit when it is one item (jar, wick, candle), else "piece". A pack (box, bag) holds many pieces and
|
|
867
888
|
// "each" / "unit" say nothing, so those read "piece"; so do mass and volume units.
|
package/vendor/fragrance.js
CHANGED
|
@@ -286,11 +286,14 @@ function flFrCompute(f, opts) {
|
|
|
286
286
|
if (!f) return out;
|
|
287
287
|
const wk = _frgWalk(f), k = st.dosage / 100;
|
|
288
288
|
out.rootOil = wk.rootOil; out.unresolved = wk.unresolved.length;
|
|
289
|
+
// What could not be weighed, by name (dogfood 6 Dec: a lotion read "check the units and densities" when its xanthan
|
|
290
|
+
// row pointed at an ingredient in Trash).
|
|
291
|
+
out.unresolvedWhy = wk.unresolved.map(_frgUnresolvedText).filter(Boolean);
|
|
289
292
|
const mats = new Map(), others = new Set();
|
|
290
293
|
const listedCount = !!st.category || flFrIsCosmetic(f); // a listed substance counts here by its CAS alone
|
|
291
294
|
wk.leaves.forEach(l => {
|
|
292
295
|
const ing = _frgIng(l.ingredientId);
|
|
293
|
-
if (!ing) { out.unresolved++; return; }
|
|
296
|
+
if (!ing) { out.unresolved++; out.unresolvedWhy.push(_frgUnresolvedText({ reason: 'missing-ingredient', ingredientId: l.ingredientId })); return; }
|
|
294
297
|
if (!l.inOil && !flFrIsMaterial(ing) && !(listedCount && flFrIsListed(ing))) { others.add(_frgName(ing)); return; }
|
|
295
298
|
const m = mats.get(ing.id) || { ing, w: 0, byOil: new Map() };
|
|
296
299
|
m.w += l.w;
|
|
@@ -701,13 +704,33 @@ function _frgAllergenTableHtml(c) {
|
|
|
701
704
|
return `<div class="table-wrapper"><table class="fr-table fl-band" id="fr-table-${v}"><thead><tr>${_frgTh(v, 'name', 'Allergen')}${_frgTh(v, 'cas', 'CAS')}${_frgTh(v, 'pct', 'In product', true)}${_frgTh(v, 'label', c.use ? _frgEsc(FL_FR_USES[c.use]) : 'Label')}${_frgTh(v, 'from', 'From')}</tr></thead>
|
|
702
705
|
<tbody>${_frgSorted(all, v, _frgAllergenSortVal).map(row).join('')}</tbody></table></div>`;
|
|
703
706
|
}
|
|
707
|
+
// One unweighable row in words: "Xanthan Gum is in Trash", "Glycerin: no density".
|
|
708
|
+
function _frgUnresolvedText(u) {
|
|
709
|
+
if (!u) return '';
|
|
710
|
+
const ingName = id => { const i = _frgIng(id); if (i) return _frgName(i); const t = typeof flTrashEntryFor === 'function' ? flTrashEntryFor('ingredient', id) : null; return t && t.item ? t.item.name : ''; };
|
|
711
|
+
const formName = id => { const f = (db.formulations || []).find(x => x && x.id === id); if (f) return f.name || f.uid; const t = typeof flTrashEntryFor === 'function' ? flTrashEntryFor('formulation', id) : null; return t && t.item ? t.item.name : ''; };
|
|
712
|
+
switch (u.reason) {
|
|
713
|
+
case 'missing-ingredient': { const n = ingName(u.ingredientId); return n ? `${n} is in Trash` : 'an ingredient that is no longer here'; }
|
|
714
|
+
case 'deleted-subformula': { const n = formName(u.formulationId); return n ? `${n} is in Trash` : 'a sub-formula that is no longer here'; }
|
|
715
|
+
case 'no-density': return `${ingName(u.ingredientId) || 'an ingredient'}: no density`;
|
|
716
|
+
case 'no-subformula-density': return `${formName(u.formulationId) || 'a sub-formula'}: no density`;
|
|
717
|
+
case 'no-weight': return `${u.ingredientId ? ingName(u.ingredientId) : formName(u.formulationId) || 'a row'}: no weight per piece`;
|
|
718
|
+
case 'unknown-unit': return `${ingName(u.ingredientId) || 'a row'}: unit "${u.unit || ''}"`;
|
|
719
|
+
case 'mixed-basis': return 'percent rows mixed with weight rows';
|
|
720
|
+
case 'cycle': return 'a sub-formula that contains itself';
|
|
721
|
+
case 'bad-amount': return `${u.ingredientId ? ingName(u.ingredientId) : formName(u.formulationId) || 'a row'}: amount "${u.amount}"`;
|
|
722
|
+
default: return '';
|
|
723
|
+
}
|
|
724
|
+
}
|
|
704
725
|
function _frgUnknownsHtml(c) {
|
|
705
726
|
const list = (a) => `<span translate="no">${_frgEsc(a.slice(0, 12).join(', '))}${a.length > 12 ? ` and ${a.length - 12} more` : ''}</span>`;
|
|
706
727
|
const parts = [];
|
|
707
728
|
if (c.noLimit.length) parts.push(`<div><strong>No limit on file for category ${_frgEsc(c.category)}:</strong> ${list(c.noLimit)}</div>`);
|
|
708
729
|
if (c.noDecl.length) parts.push(`<div><strong>No allergen declaration:</strong> ${list(c.noDecl)}</div>`);
|
|
709
730
|
if (c.noSource.length) parts.push(`<div><strong>No source document:</strong> ${list(c.noSource.map(s => `${s.name} (${s.what})`))}</div>`);
|
|
710
|
-
if (c.unresolved) parts.push(
|
|
731
|
+
if (c.unresolved) parts.push(c.unresolvedWhy && c.unresolvedWhy.length
|
|
732
|
+
? `<div><strong>Composition:</strong> part of it could not be weighed: ${list([...new Set(c.unresolvedWhy)])}.</div>`
|
|
733
|
+
: '<div><strong>Composition:</strong> part of it could not be weighed. Check the units and densities on the Composition tab.</div>');
|
|
711
734
|
if (!parts.length) return '';
|
|
712
735
|
return `<div class="card"><div class="card-header"><h2>Unknown</h2></div><div class="card-body fr-unknowns">${parts.join('')}
|
|
713
736
|
<div class="fr-dim">Add the limits, the declaration, and their documents on each ingredient (Edit, Fragrance details).</div></div></div>`;
|
|
@@ -1100,29 +1123,53 @@ async function flFrReadDoc(which) {
|
|
|
1100
1123
|
const list = document.getElementById(which === 'limits' ? 'f-fr-limits' : 'f-fr-allergens'), sel2 = document.getElementById(which === 'limits' ? 'f-fr-cert' : 'f-fr-decl');
|
|
1101
1124
|
if (!list || !sel2 || sel2.value !== doc.id) return;
|
|
1102
1125
|
const file = _frgText(doc.filename) || 'the document';
|
|
1126
|
+
// A row already here that the document says otherwise is updated and marked (dogfood 6 Dec: a 52nd Amendment
|
|
1127
|
+
// certificate read over the 51st kept 5A at 0.15 % where it said 0.40 %, and "2 already here" hid it).
|
|
1103
1128
|
let added = 0, had = 0, res;
|
|
1129
|
+
const changed = [];
|
|
1104
1130
|
if (which === 'limits') {
|
|
1105
1131
|
res = flFrLimitsFromExtract(raw);
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1132
|
+
const kindOf = r => r.unrestricted ? 'unrestricted' : (r.prohibited || _frgNum(r.maxPct) === 0) ? 'prohibited' : 'limit';
|
|
1133
|
+
const textOf = (kind, m) => kind === 'limit' ? `${m} %` : kind === 'prohibited' ? 'prohibited' : 'not restricted';
|
|
1134
|
+
const byCat = new Map([...list.querySelectorAll('.fr-limit-row')].map(x => [x.querySelector('.fr-l-cat').value, x]));
|
|
1135
|
+
res.rows.forEach(r => {
|
|
1136
|
+
const old = byCat.get(r.category);
|
|
1137
|
+
if (!old) { list.insertAdjacentHTML('beforeend', _frgLimitRowHtml(r)); list.lastElementChild.classList.add('fr-new'); added++; return; }
|
|
1138
|
+
const k0 = old.querySelector('.fr-l-kind').value, m0 = _frgNum(old.querySelector('.fr-l-max').value), k1 = kindOf(r), m1 = _frgNum(r.maxPct);
|
|
1139
|
+
if (k0 === k1 && (k1 !== 'limit' || m0 === m1)) { had++; return; }
|
|
1140
|
+
old.insertAdjacentHTML('afterend', _frgLimitRowHtml(r));
|
|
1141
|
+
const nw = old.nextElementSibling; old.remove(); nw.classList.add('fr-new');
|
|
1142
|
+
changed.push(`${r.category} ${textOf(k0, m0)} → ${textOf(k1, m1)}`);
|
|
1143
|
+
});
|
|
1108
1144
|
const am = document.getElementById('f-fr-amend');
|
|
1109
|
-
if (am &&
|
|
1145
|
+
if (am && res.amendment && am.value.trim() !== res.amendment) {
|
|
1146
|
+
if (am.value.trim()) changed.push(`amendment ${am.value.trim()} → ${res.amendment}`);
|
|
1147
|
+
am.value = res.amendment;
|
|
1148
|
+
}
|
|
1110
1149
|
} else {
|
|
1111
1150
|
res = flFrAllergensFromExtract(raw);
|
|
1112
1151
|
const keyOf = (n, c) => { const e = flFrAllergenFor(n, c); return e ? 'e' + e.ref : _frgKey(n) || _frgCas(c); };
|
|
1113
|
-
const
|
|
1114
|
-
res.rows.forEach(r => {
|
|
1152
|
+
const byKey = new Map([...list.querySelectorAll('.fr-al-row')].map(x => [keyOf(x.querySelector('.fr-a-name').value, x.querySelector('.fr-a-cas').value), x]));
|
|
1153
|
+
res.rows.forEach(r => {
|
|
1154
|
+
const old = byKey.get(keyOf(r.substance, r.cas));
|
|
1155
|
+
if (!old) { list.insertAdjacentHTML('beforeend', _frgAllergenRowHtml(r)); list.lastElementChild.classList.add('fr-new'); added++; return; }
|
|
1156
|
+
const pin = old.querySelector('.fr-a-pct'), p0 = _frgNum(pin.value), p1 = _frgNum(r.pct);
|
|
1157
|
+
if (p0 === p1) { had++; return; }
|
|
1158
|
+
pin.value = String(r.pct); old.classList.add('fr-new');
|
|
1159
|
+
changed.push(`${old.querySelector('.fr-a-name').value || r.substance} ${pin.defaultValue || '?'} → ${r.pct} %`);
|
|
1160
|
+
});
|
|
1115
1161
|
const none = document.getElementById('f-fr-none');
|
|
1116
1162
|
if (none) { if (added) none.checked = false; else if (res.none && !list.children.length) none.checked = true; }
|
|
1117
1163
|
}
|
|
1118
1164
|
if (typeof flOpenFold === 'function') flOpenFold(which === 'limits' ? 'f-fr-fold-limits' : 'f-fr-fold-allergens');
|
|
1119
1165
|
_frgFormCheck();
|
|
1120
|
-
if (added && typeof _ingMarkDirty === 'function') { try { _ingMarkDirty(); } catch (_) {} }
|
|
1166
|
+
if ((added || changed.length) && typeof _ingMarkDirty === 'function') { try { _ingMarkDirty(); } catch (_) {} }
|
|
1121
1167
|
const what = which === 'limits' ? ['limit', 'limits'] : ['allergen', 'allergens'];
|
|
1122
|
-
const bits = [added ? `${added} ${what[added === 1 ? 0 : 1]} read from ${file}` : (which === 'allergens' && res.none ? `${file} declares none` : `Nothing new read from ${file}`)];
|
|
1123
|
-
if (
|
|
1168
|
+
const bits = [added ? `${added} ${what[added === 1 ? 0 : 1]} read from ${file}` : changed.length ? `Read from ${file}` : (which === 'allergens' && res.none ? `${file} declares none` : `Nothing new read from ${file}`)];
|
|
1169
|
+
if (changed.length) bits.push(`${changed.length} changed (${changed.slice(0, 3).join('; ')}${changed.length > 3 ? '; …' : ''})`);
|
|
1170
|
+
if (had) bits.push(`${had} unchanged`);
|
|
1124
1171
|
if (res.skipped) bits.push(`${res.skipped} skipped`);
|
|
1125
|
-
say(bits.join(', ') + (added ? '. Check each against the document, then Save.' : '.'), added ? 'info' : undefined);
|
|
1172
|
+
say(bits.join(', ') + (added || changed.length ? '. Check each against the document, then Save.' : '.'), added || changed.length ? 'info' : undefined);
|
|
1126
1173
|
}
|
|
1127
1174
|
|
|
1128
1175
|
// What the ingredient form saves. → { error } | { details: fields for fragranceDetails, fragranceAllergens, allergenDeclDocId }
|