formlab-mcp 0.7.8 → 0.7.9
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/tools/ingredients.js +2 -1
- package/vendor/cost.js +46 -5
- package/vendor/nesting.js +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formlab-mcp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
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.9",
|
|
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.9",
|
|
12
12
|
"runtimeHint": "npx",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
package/tools/ingredients.js
CHANGED
|
@@ -36,9 +36,10 @@ function _costPerKg(i) {
|
|
|
36
36
|
const dens = _densityKgPerL(i);
|
|
37
37
|
return dens ? +((v / _VOL_TO_L[unit]) / dens).toFixed(6) : null;
|
|
38
38
|
}
|
|
39
|
-
const pk = _pieceKg(i); // priced per piece (a wick): through the weight per piece (0.7.8)
|
|
39
|
+
const pk = _PACK_UNITS.has(unit) ? null : _pieceKg(i); // priced per piece (a wick): through the weight per piece (0.7.8); a box is many pieces
|
|
40
40
|
return pk ? +(v / pk).toFixed(6) : null;
|
|
41
41
|
}
|
|
42
|
+
const _PACK_UNITS = new Set(['box', 'boxes', 'pack', 'packs', 'package', 'case', 'cases', 'carton', 'cartons', 'bag', 'bags', 'pallet', 'pallets', 'dozen', 'doz', 'pair', 'pairs', 'set', 'sets', 'kit', 'kits', 'sleeve', 'tray', 'bundle', 'gross', 'ream', 'ppm', 'ppb', 'mol', 'mmol', 'eq', 'phr', '%', 'wt%', 'vol%']);
|
|
42
43
|
function _pieceKg(i) {
|
|
43
44
|
const m = i && i.unitMass; const v = m ? Number(m.value) : NaN;
|
|
44
45
|
const f = m ? _MASS_TO_KG[String(m.unit || '').toLowerCase()] : null;
|
package/vendor/cost.js
CHANGED
|
@@ -790,6 +790,13 @@ function amountConversions(amount, unit, ingredient, opts) {
|
|
|
790
790
|
} else {
|
|
791
791
|
res.note = `"${unit}" is a relative fraction — its absolute mass/volume depends on the batch size. Set a "Scale to batch" amount above to materialize.`;
|
|
792
792
|
}
|
|
793
|
+
} else if (ingredient && flIsPieceUnit(unit) && flPieceMassKg(ingredient.unitMass) != null) {
|
|
794
|
+
// 1 wick → its weight, through the weight per piece (2 Dec).
|
|
795
|
+
const kg = amt * flPieceMassKg(ingredient.unitMass);
|
|
796
|
+
res.cross = { label: `by weight per piece (${ingredient.unitMass.value} ${ingredient.unitMass.unit})`,
|
|
797
|
+
rows: _AMT_VIEW_MASS.map(u => ({ unit: u, value: kg / MASS_TO_KG[u] })) };
|
|
798
|
+
} else if (ingredient && flIsPieceUnit(unit)) {
|
|
799
|
+
res.note = 'Set a Weight per piece on the ingredient to see this in grams.';
|
|
793
800
|
} else {
|
|
794
801
|
res.note = 'No unit conversions available for this unit.';
|
|
795
802
|
}
|
|
@@ -817,9 +824,19 @@ function flPieceMassKg(unitMass) {
|
|
|
817
824
|
const v = unitMass ? parseFloat(unitMass.value) : NaN;
|
|
818
825
|
return (isFinite(v) && v > 0 && unitMass.unit in MASS_TO_KG) ? v * MASS_TO_KG[unitMass.unit] : null;
|
|
819
826
|
}
|
|
827
|
+
const FL_PACK_UNITS = new Set(['box', 'boxes', 'pack', 'packs', 'package', 'case', 'cases', 'carton', 'cartons', 'bag', 'bags', 'pallet', 'pallets', 'dozen', 'doz', 'pair', 'pairs', 'set', 'sets', 'kit', 'kits', 'sleeve', 'tray', 'bundle', 'gross', 'ream']);
|
|
828
|
+
// A count of pieces as people take them off the shelf: within 2% of a whole number it is that number (12 candles at
|
|
829
|
+
// 226.8 g against a 227.3 g recipe ask for 11.97 wicks, which means 12). Anything further off stays as computed.
|
|
830
|
+
function flPieceCount(n) {
|
|
831
|
+
if (n == null || !isFinite(n)) return n;
|
|
832
|
+
const r = Math.round(n);
|
|
833
|
+
return (r > 0 && Math.abs(n - r) <= 0.02 * r) ? r : +n.toFixed(3);
|
|
834
|
+
}
|
|
820
835
|
function flIsPieceUnit(u) {
|
|
821
836
|
const raw = String(u || '').trim(), lower = raw.toLowerCase();
|
|
822
837
|
if (!raw || raw === '%' || lower.startsWith('wt') || lower.startsWith('vol') || ['ppm', 'ppb', 'mol', 'mmol', 'eq', 'phr'].includes(lower)) return false;
|
|
838
|
+
// Packs hold many pieces (a box of wicks): never one piece, so never priced or weighed as one.
|
|
839
|
+
if (FL_PACK_UNITS.has(lower)) return false;
|
|
823
840
|
const _cu = (typeof db !== 'undefined' && db && db.customUnits && Object.prototype.hasOwnProperty.call(db.customUnits, raw)) ? db.customUnits[raw] : null;
|
|
824
841
|
if (_cu) return _cu.dimension === 'count'; // a custom count unit ("wick") is a piece; other custom units convert by their own rule
|
|
825
842
|
const hit = t => Object.keys(t).some(k => k === raw || k.toLowerCase() === lower);
|
|
@@ -1171,7 +1188,9 @@ function computeFormulationCost(formulation, displayCcy, basisUnit, _seen) {
|
|
|
1171
1188
|
const kinds = comp.map(c => flPieceRowKg(c) != null ? 'mass-abs' : classifyUnit(c.unit));
|
|
1172
1189
|
const allWt = comp.length && kinds.every(k => k === 'wt-frac');
|
|
1173
1190
|
const allVol = comp.length && kinds.every(k => k === 'vol-frac');
|
|
1174
|
-
|
|
1191
|
+
// A counted row still missing its weight per piece is reported on its own; it must not knock the gram rows off the absolute basis.
|
|
1192
|
+
const allAbs = comp.length && kinds.every((k, i) => k === 'mass-abs' || k === 'vol-abs' || (k !== 'wt-frac' && k !== 'vol-frac' && flIsPieceUnit(comp[i].unit)))
|
|
1193
|
+
&& kinds.some(k => k === 'mass-abs' || k === 'vol-abs');
|
|
1175
1194
|
const basis = allVol ? 'vol' : (allAbs ? 'abs' : 'wt');
|
|
1176
1195
|
|
|
1177
1196
|
// === Vol-% recipe: derive formulation density from per-row densities ===
|
|
@@ -1248,7 +1267,9 @@ function computeFormulationCost(formulation, displayCcy, basisUnit, _seen) {
|
|
|
1248
1267
|
const tryAutoPrice = (ing, c, unit, amount, kind) => {
|
|
1249
1268
|
if (!ing.cost || ing.cost.value == null || ing.cost.value === '') return { ok: false, reason: 'no cost on file' };
|
|
1250
1269
|
const perKgOwn = costPerKgInOwnCurrency(ing.cost, ing.density, ing.densityUnit, ing.unitMass);
|
|
1251
|
-
if (perKgOwn == null) return { ok: false, reason:
|
|
1270
|
+
if (perKgOwn == null) return { ok: false, reason: FL_PACK_UNITS.has(String(ing.cost.unit || '').trim().toLowerCase())
|
|
1271
|
+
? `price is per ${String(ing.cost.unit).trim()}: enter it per piece (with a weight per piece) or per kg`
|
|
1272
|
+
: 'could not convert price unit (needs density?)' };
|
|
1252
1273
|
const perKgDisplay = convertCurrencySync(perKgOwn, ing.cost.currency || 'USD', displayCcy);
|
|
1253
1274
|
if (perKgDisplay == null) return { ok: false, reason: 'unknown currency rate' };
|
|
1254
1275
|
|
|
@@ -1722,7 +1743,12 @@ function scaleCompositionToBatch(formulation, batchAmount, batchUnit) {
|
|
|
1722
1743
|
if (ok) partsSum += vol;
|
|
1723
1744
|
byRow.set(comp[i], vol);
|
|
1724
1745
|
});
|
|
1725
|
-
|
|
1746
|
+
const pieces = new Map();
|
|
1747
|
+
fr.rows.forEach((r, i) => {
|
|
1748
|
+
const c = comp[i], one = r.pieces ? flPieceRowKg(Object.assign({}, c, { amount: 1 })) : null;
|
|
1749
|
+
if (one && r.massFraction != null && isFinite(r.massFraction)) pieces.set(c, flPieceCount((r.massFraction * totalMassKg) / one));
|
|
1750
|
+
});
|
|
1751
|
+
return { unit: batchUnit, dim, byRow, anyNull, density: pd, totalMassKg, partsSum, pieces };
|
|
1726
1752
|
}
|
|
1727
1753
|
fr.rows.forEach((r, i) => {
|
|
1728
1754
|
const frac = dim === 'mass' ? r.massFraction : r.volFraction;
|
|
@@ -1736,10 +1762,18 @@ function scaleCompositionToBatch(formulation, batchAmount, batchUnit) {
|
|
|
1736
1762
|
out.pieces = new Map();
|
|
1737
1763
|
fr.rows.forEach((r, i) => {
|
|
1738
1764
|
const c = comp[i], g = byRow.get(c), one = r.pieces ? flPieceRowKg(Object.assign({}, c, { amount: 1 })) : null;
|
|
1739
|
-
if (one && g != null && isFinite(g)) out.pieces.set(c,
|
|
1765
|
+
if (one && g != null && isFinite(g)) out.pieces.set(c, flPieceCount((g * MASS_TO_KG[batchUnit]) / one));
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
if (dim === 'volume' && pd) {
|
|
1769
|
+
out.density = pd; out.totalMassKg = amt * VOL_TO_L[batchUnit] * pd.kgPerL; out.partsSum = amt;
|
|
1770
|
+
// A wick in a volume batch: no volume to scale, but still a count, from its mass share (2 Dec).
|
|
1771
|
+
out.pieces = new Map();
|
|
1772
|
+
fr.rows.forEach((r, i) => {
|
|
1773
|
+
const c = comp[i], one = r.pieces ? flPieceRowKg(Object.assign({}, c, { amount: 1 })) : null;
|
|
1774
|
+
if (one && r.massFraction != null && isFinite(r.massFraction)) out.pieces.set(c, flPieceCount((r.massFraction * out.totalMassKg) / one));
|
|
1740
1775
|
});
|
|
1741
1776
|
}
|
|
1742
|
-
if (dim === 'volume' && pd) { out.density = pd; out.totalMassKg = amt * VOL_TO_L[batchUnit] * pd.kgPerL; out.partsSum = amt; }
|
|
1743
1777
|
return out;
|
|
1744
1778
|
}
|
|
1745
1779
|
|
|
@@ -1898,6 +1932,8 @@ function sumActualRowsMassKg(rows, formula) {
|
|
|
1898
1932
|
if (!isFinite(amt)) continue;
|
|
1899
1933
|
const u = (c.unit || '').trim();
|
|
1900
1934
|
if (u in MASS_TO_KG) { kg += amt * MASS_TO_KG[u]; n++; continue; }
|
|
1935
|
+
const _pk = flPieceRowKg(c); // 12 wicks, by their weight per piece (2 Dec)
|
|
1936
|
+
if (_pk != null) { kg += _pk; n++; continue; }
|
|
1901
1937
|
if (u in VOL_TO_L) {
|
|
1902
1938
|
let d = null;
|
|
1903
1939
|
if (c.ingredientId) {
|
|
@@ -2058,6 +2094,11 @@ function renderWeighoutPanel(w, actuals, formula, copyOnclick, noun) {
|
|
|
2058
2094
|
const toUnit = (amt, from, key) => {
|
|
2059
2095
|
if (amt == null || !isFinite(amt)) return null;
|
|
2060
2096
|
if (!from || from === w.unit) return amt;
|
|
2097
|
+
// Wicks logged as "12 piece": through the ingredient's weight per piece into the sheet's mass unit (2 Dec).
|
|
2098
|
+
if (typeof key === 'string' && key.slice(0, 2) === 'i:' && flIsPieceUnit(from) && w.unit in MASS_TO_KG) {
|
|
2099
|
+
const kg = flPieceRowKg({ ingredientId: key.slice(2), amount: amt, unit: from });
|
|
2100
|
+
return kg == null ? null : kg / MASS_TO_KG[w.unit];
|
|
2101
|
+
}
|
|
2061
2102
|
if (typeof convertQuantityAtDensity !== 'function') return null;
|
|
2062
2103
|
const v = convertQuantityAtDensity(amt, from, w.unit, rowDensityKgPerL(key));
|
|
2063
2104
|
return (v == null || !isFinite(v)) ? null : v;
|
package/vendor/nesting.js
CHANGED
|
@@ -243,16 +243,20 @@ function _idealMixDensity(formulation) {
|
|
|
243
243
|
if (!formulation) return null;
|
|
244
244
|
const flat = _flattenComposition(formulation);
|
|
245
245
|
if (!flat.rows.length) return null;
|
|
246
|
-
let invSum = 0;
|
|
246
|
+
let invSum = 0, pieceW = 0;
|
|
247
247
|
for (const r of flat.rows) {
|
|
248
248
|
if (r._weight <= 0) continue;
|
|
249
249
|
const ing = db.ingredients.find(i => i.id === r.ingredientId);
|
|
250
250
|
if (!ing) return null;
|
|
251
251
|
const d = (typeof _densityToKgPerL === 'function')
|
|
252
252
|
? _densityToKgPerL(ing.density, ing.densityUnit) : null;
|
|
253
|
+
// A counted item with no density (a wick: weight per piece only) adds its mass and next to no volume,
|
|
254
|
+
// so a candle's density stays that of its wax. Only while such items stay a small share (2 Dec).
|
|
255
|
+
if (!d && typeof flPieceMassKg === 'function' && flPieceMassKg(ing.unitMass) != null) { pieceW += r._weight; continue; }
|
|
253
256
|
if (!d) return null;
|
|
254
257
|
invSum += r._weight / d;
|
|
255
258
|
}
|
|
259
|
+
if (pieceW > 0.05) return null;
|
|
256
260
|
return invSum > 0 ? 1 / invSum : null;
|
|
257
261
|
}
|
|
258
262
|
|