formlab-mcp 0.6.65 → 0.6.66
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/theoretical.js +1 -1
- package/vendor/reactive.js +7 -2
- package/vendor/theoretical-params.js +24 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formlab-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.66",
|
|
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.66",
|
|
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.66",
|
|
12
12
|
"runtimeHint": "npx",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
package/theoretical.js
CHANGED
|
@@ -39,7 +39,7 @@ const EPILOGUE = `
|
|
|
39
39
|
var r = res[p.id] || {};
|
|
40
40
|
var v = (!r.error && Number.isFinite(r.value)) ? r.value : null;
|
|
41
41
|
var warning = null;
|
|
42
|
-
try { var m = _tpMissingNote(_tpMissingInputs(p.formula, rows)); if (m) warning = m.text; } catch (_) {}
|
|
42
|
+
try { var m = r.needsDensity ? _tpNeedsDensityNote(r.needsDensity) : _tpMissingNote(_tpMissingInputs(p.formula, rows)); if (m) warning = m.text; } catch (_) {}
|
|
43
43
|
var spec = (p.spec && (p.spec.min != null || p.spec.max != null)) ? { min: p.spec.min != null ? p.spec.min : null, max: p.spec.max != null ? p.spec.max : null } : null;
|
|
44
44
|
var pass = (v != null && spec) ? ((spec.min == null || v >= spec.min) && (spec.max == null || v <= spec.max)) : null;
|
|
45
45
|
return { name: p.name || '', value: v, unit: p.unit || '', formula: p.formula || '', error: r.error || null,
|
package/vendor/reactive.js
CHANGED
|
@@ -170,7 +170,11 @@ function flRxMixedUnits(comp) {
|
|
|
170
170
|
const typed = new Set((comp || []).filter(c => c && (c.ingredientId || c.formulationId) && _flRxNum(c.amount) > 0)
|
|
171
171
|
.map(c => (abs(c.unit) ? 'abs' : _flRxUnitBasis(c.unit))).filter(Boolean));
|
|
172
172
|
if (typed.size > 1) return true;
|
|
173
|
-
|
|
173
|
+
const built = _flRxRows(comp).filter(r => r && r.amount > 0);
|
|
174
|
+
// A row still in mL once built had no density, so none were made masses: an all-mL recipe multiplied millilitres
|
|
175
|
+
// by meq per gram (QA sweep, Jun 1 Nov: 100 mL of a 1.16 g/mL epoxy counted as 100 g).
|
|
176
|
+
if (typeof isVolUnit === 'function' && built.some(r => isVolUnit(r.unit))) return true;
|
|
177
|
+
return new Set(built.map(r => _flRxUnitBasis(r.unit)).filter(Boolean)).size > 1;
|
|
174
178
|
}
|
|
175
179
|
// The pairs a composition holds: both sides present.
|
|
176
180
|
function flRxPairsFor(comp) {
|
|
@@ -193,6 +197,7 @@ function flRxKitRatio(comp) {
|
|
|
193
197
|
const rows = _flRxRows(comp).filter(r => r && r.ing && r.ing._isSubFormula);
|
|
194
198
|
if (rows.length !== parts.length || !(rows[0].amount > 0)) return null;
|
|
195
199
|
const subs = parts.map(c => (db.formulations || []).find(g => g.id === c.formulationId));
|
|
200
|
+
if (subs.some(g => !g || g._trashed || g.deletedAt)) return null; // a part deleted or in Trash: no ratio to quote (QA sweep)
|
|
196
201
|
const dens = subs.map(g => (g && typeof _rolledUpDensity === 'function') ? _rolledUpDensity(g) : null);
|
|
197
202
|
const vol = dens.every(d => d > 0) ? rows.map((r, i) => r.amount / dens[i]) : null;
|
|
198
203
|
return {
|
|
@@ -455,7 +460,7 @@ function flRxBatchStripHtml(b) {
|
|
|
455
460
|
const comp = hasActual ? b.actualComposition : (f ? f.composition : []);
|
|
456
461
|
const found = flRxPairsFor(comp);
|
|
457
462
|
if (!found.length) return '';
|
|
458
|
-
if (flRxMixedUnits(comp)) return `<div class="fl-rx-strip" id="fl-rx-bstrip-${esc(b.id)}"><span class="fl-rx-kicker">Reactive balance</span><span class="fl-rx-warn">Rows in different units: put them on one basis for an index.</span></div>`;
|
|
463
|
+
if (flRxMixedUnits(comp)) return `<div class="fl-rx-strip" id="fl-rx-bstrip-${esc(b.id)}"><span class="fl-rx-kicker">Reactive balance</span><span class="fl-rx-warn">Rows in different units (% and g, or mL without a density): put them on one basis for an index.</span></div>`;
|
|
459
464
|
const pro = typeof hasFeature !== 'function' || hasFeature('reactive.solve');
|
|
460
465
|
const planned = f && hasActual && !flRxMixedUnits(f.composition) ? flRxPairsFor(f.composition) : [];
|
|
461
466
|
const chips = found.map(({ pair, index }) => {
|
|
@@ -243,6 +243,8 @@ function _tpTransformRefs(expr) {
|
|
|
243
243
|
// Evaluate a compiled formula against a row set. Aggregation helpers
|
|
244
244
|
// are passed in fresh on each call so they close over the right rows.
|
|
245
245
|
function _tpEvaluate(formula, rows) {
|
|
246
|
+
// mL rows without a density (_tpBuildRows): no number from the rows, never raw mL read as wt% (smart search calls in here).
|
|
247
|
+
if (rows && rows.needsDensity && /\b(row|ing)\./i.test(String(formula || ''))) return NaN;
|
|
246
248
|
const fn = _tpCompile(formula);
|
|
247
249
|
const safe = (rows || []).filter(Boolean);
|
|
248
250
|
const filteredFor = (cf) => {
|
|
@@ -375,21 +377,26 @@ function _tpEvaluateAll(params, rows) {
|
|
|
375
377
|
visiting[p.id] = true;
|
|
376
378
|
|
|
377
379
|
const valueMap = {};
|
|
378
|
-
let depError = '';
|
|
380
|
+
let depError = '', needsDensity = null;
|
|
379
381
|
for (const ref of _tpScanParamRefs(p.formula)) {
|
|
380
382
|
const key = ref.name.toLowerCase();
|
|
381
383
|
const dep = byName[key];
|
|
382
384
|
if (!dep) { depError = depError || `Unknown parameter [${ref.name}]`; continue; }
|
|
383
385
|
if (dep.id === p.id) { depError = depError || 'Circular reference'; continue; }
|
|
384
386
|
const dr = resolve(dep);
|
|
387
|
+
if (dr.needsDensity) { needsDensity = dr.needsDensity; continue; }
|
|
385
388
|
if (dr.error) { depError = depError || `[${ref.name}] → ${dr.error}`; continue; }
|
|
386
389
|
if (!Number.isFinite(dr.value)) { depError = depError || `[${ref.name}] is not a number`; continue; }
|
|
387
390
|
valueMap[key] = dr.value;
|
|
388
391
|
}
|
|
389
392
|
|
|
393
|
+
// Reads the recipe's rows while some are mL with no density: no value, and the ingredients to fix.
|
|
394
|
+
if (!needsDensity && rows && rows.needsDensity && /\b(row|ing)\./i.test(String(p.formula || ''))) needsDensity = rows.needsDensity;
|
|
390
395
|
let res;
|
|
391
396
|
if (depError) {
|
|
392
397
|
res = { value: null, error: depError, name: p.name };
|
|
398
|
+
} else if (needsDensity) {
|
|
399
|
+
res = { value: null, error: '', name: p.name, needsDensity };
|
|
393
400
|
} else {
|
|
394
401
|
try {
|
|
395
402
|
const substituted = _tpSubstituteParamRefs(p.formula, valueMap);
|
|
@@ -460,17 +467,24 @@ function _tpBuildRows(composition) {
|
|
|
460
467
|
const isV = u => (typeof isVolUnit === 'function') && isVolUnit(u);
|
|
461
468
|
const abs = rows.filter(r => isM(r.unit) || isV(r.unit));
|
|
462
469
|
if (abs.length && typeof massToKg === 'function' && typeof volToL === 'function') {
|
|
470
|
+
const noDensity = [];
|
|
463
471
|
const grams = abs.map(r => {
|
|
464
472
|
if (isM(r.unit)) { const f = massToKg(r.unit); return (f != null) ? r.amount * f * 1000 : null; }
|
|
465
473
|
const L = volToL(r.unit);
|
|
466
474
|
let d = null;
|
|
467
475
|
if (r._srcIng && typeof _densityToKgPerL === 'function') d = _densityToKgPerL(r._srcIng.density, r._srcIng.densityUnit);
|
|
468
476
|
else if (r._srcSub && typeof _rolledUpDensity === 'function') { const sub = db.formulations.find(g => g.id === r._srcSub); d = sub ? _rolledUpDensity(sub) : null; }
|
|
469
|
-
|
|
477
|
+
const ok = L != null && d != null && isFinite(d) && d > 0;
|
|
478
|
+
if (!ok && r.amount > 0) noDensity.push(r._srcIng ? (r._srcIng.name || '(unnamed)') : (r._subName || 'sub-formula'));
|
|
479
|
+
return ok ? r.amount * L * d * 1000 : null;
|
|
470
480
|
});
|
|
471
481
|
const total = grams.reduce((a, g) => a + (g || 0), 0);
|
|
472
482
|
if (grams.every(g => g != null && isFinite(g)) && total > 0) {
|
|
473
483
|
abs.forEach((r, i) => { r.amount = (grams[i] / total) * 100; r.unit = 'wt%'; });
|
|
484
|
+
} else if (noDensity.length) {
|
|
485
|
+
// A volume row with no density leaves every row as typed, and an expression would read raw mL as if it were
|
|
486
|
+
// wt% (Jun, 1 Nov). Said here, so _tpEvaluateAll gives those parameters no value instead.
|
|
487
|
+
Object.defineProperty(rows, 'needsDensity', { value: [...new Set(noDensity)], enumerable: false });
|
|
474
488
|
}
|
|
475
489
|
}
|
|
476
490
|
rows.forEach(r => { delete r._srcIng; delete r._srcSub; });
|
|
@@ -976,6 +990,12 @@ function _tpMissingInputs(formula, rows) {
|
|
|
976
990
|
res.ingredients = [...names];
|
|
977
991
|
return res;
|
|
978
992
|
}
|
|
993
|
+
// The line for a parameter left without a value: mL rows need a density to count by mass.
|
|
994
|
+
function _tpNeedsDensityNote(names) {
|
|
995
|
+
const n = names.length;
|
|
996
|
+
return { text: `Needs a density: ${names.slice(0, 2).join(', ')}${n > 2 ? ` +${n - 2} more` : ''}`,
|
|
997
|
+
tip: `Rows in mL count by mass. Give ${n === 1 ? 'it' : 'these'} a density, or enter the recipe in g or %: ${names.join(', ')}.` };
|
|
998
|
+
}
|
|
979
999
|
// One short line for the table (and its tooltip), '' when nothing is missing.
|
|
980
1000
|
function _tpMissingNote(miss) {
|
|
981
1001
|
if (!miss) return null;
|
|
@@ -1050,7 +1070,7 @@ function renderTheoreticalParamsHtml(entityType, entity) {
|
|
|
1050
1070
|
// Pass/fail vs. spec, if defined
|
|
1051
1071
|
const pfBadge = (!errorText && Number.isFinite(value)) ? _tpSpecBadgeHtml(value, p.spec) : '';
|
|
1052
1072
|
|
|
1053
|
-
const miss = (!errorText && Number.isFinite(value)) ? _tpMissingNote(_tpMissingInputs(p.formula, evalRows)) : null;
|
|
1073
|
+
const miss = (!errorText && Number.isFinite(value)) ? _tpMissingNote(_tpMissingInputs(p.formula, evalRows)) : (r.needsDensity ? _tpNeedsDensityNote(r.needsDensity) : null);
|
|
1054
1074
|
const missHtml = miss ? `<div class="tp-miss" title="${esc(miss.tip)}" style="margin-top:3px;font-size:11px;font-weight:400;color:var(--dk-amber-fg, #b45309);cursor:help">⚠ ${esc(miss.text)}</div>` : '';
|
|
1055
1075
|
|
|
1056
1076
|
const formulaPreview = (p.formula || '').length > 80
|
|
@@ -1136,7 +1156,7 @@ function _tpPinnedChipsHtml(entityType, entity) {
|
|
|
1136
1156
|
if (okMin && okMax) { bg = 'var(--dk-green-bg2, #dcfce7)'; fg = 'var(--dk-green-fg, #15803d)'; bd = 'var(--dk-green-line, #bbf7d0)'; }
|
|
1137
1157
|
else { bg = 'var(--dk-red-bg2, #fee2e2)'; fg = 'var(--dk-red-fg, #b91c1c)'; bd = 'var(--dk-red-line, #fecaca)'; }
|
|
1138
1158
|
} else if (r.error) { fg = 'var(--dk-red-fg, #b91c1c)'; }
|
|
1139
|
-
const miss = (!r.error && Number.isFinite(r.value)) ? _tpMissingNote(_tpMissingInputs(p.formula, chipRows)) : null;
|
|
1159
|
+
const miss = (!r.error && Number.isFinite(r.value)) ? _tpMissingNote(_tpMissingInputs(p.formula, chipRows)) : (r.needsDensity ? _tpNeedsDensityNote(r.needsDensity) : null);
|
|
1140
1160
|
const title = r.error ? r.error : ((p.description || `${p.name}${p.unit ? ' (' + p.unit + ')' : ''}`) + (miss ? '\n⚠ ' + miss.text + '\n' + miss.tip : ''));
|
|
1141
1161
|
return `<span title="${esc(title)}" style="display:inline-flex;align-items:baseline;gap:5px;padding:3px 9px;border-radius:9999px;background:${bg};border:1px solid ${bd};font-size:11.5px;line-height:1.4;white-space:nowrap">
|
|
1142
1162
|
<span style="color:var(--dk-muted, #64748b)">${esc(p.name)}</span>
|