formlab-mcp 0.7.5 → 0.7.6

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 CHANGED
@@ -153,7 +153,7 @@ FormLab's QC definitions (answer by these; never infer them):
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. A shipment recorded with QC open keeps the open items and the reason given (get_batch stockLedger: shippedWithQcOpen, qcReason).`;
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). A shipment recorded from 2 Dec 2026 also says which CoA it went with (coaIssuedAt, coaCustomer, coaPo; coaIssuedAt null = no CoA issued) and noLotsRecorded (true = no ingredient lots recorded for the batch or its parents, so a recall trace stops at the batch).`;
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.5",
3
+ "version": "0.7.6",
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",
5
+ "version": "0.7.6",
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.5",
11
+ "version": "0.7.6",
12
12
  "runtimeHint": "npx",
13
13
  "transport": {
14
14
  "type": "stdio"
package/tools/lab.js CHANGED
@@ -442,6 +442,8 @@ const get_batch = {
442
442
  date: e.ts || null, delta: e.delta ?? null, unit: e.unit || b.unit || '', kind: e.kind || '', note: e.note || '',
443
443
  ...(e.customer ? { customer: e.customer } : {}),
444
444
  ...(Array.isArray(e.qcOpen) && e.qcOpen.length ? { shippedWithQcOpen: e.qcOpen, qcReason: e.qcReason || null } : {}),
445
+ // 2 Dec: the CoA it went with (null = none issued), and no ingredient lots recorded. Older shipments carry neither.
446
+ ...(e.kind === 'shipment' && 'coaAt' in e ? { coaIssuedAt: e.coaAt || null, ...(e.coaCustomer ? { coaCustomer: e.coaCustomer } : {}), ...(e.coaPo ? { coaPo: e.coaPo } : {}), noLotsRecorded: !!e.noLots } : {}),
445
447
  })),
446
448
  shippedQty: (Array.isArray(b.stockLedger) ? b.stockLedger : []).reduce((s, e) => e.kind === 'shipment' ? s + Math.abs(parseFloat(e.delta) || 0) : s, 0),
447
449
  // Finished-batch hold: while set, the app records no shipment of this batch (QA / complaint / recall).
@@ -396,7 +396,8 @@ function flRxSubRowEq(sub, parentAmount, groups) {
396
396
  }
397
397
  const _FL_RX_SHORT = { epoxy: 'epoxy', amineH: 'amine H', oh: 'OH', nco: 'NCO', cooh: 'COOH', amine: 'amine', sih: 'Si-H', vinyl: 'vinyl', h2o: 'water', ester: 'oil', base: 'lye' };
398
398
  function flRxEqCellHtml(list) {
399
- if (!list || !list.length) return '<span class="fl-rx-dim">—</span>';
399
+ // The dash sits in the numbers' column, not under the group names (25l).
400
+ if (!list || !list.length) return '<span class="fl-rx-eqs"><span class="fl-rx-eq fl-rx-dim">—</span><i></i></span>';
400
401
  // The arithmetic on hover (Jun, 28 Oct): 14.6 g × 23.5 meq/g = 0.343 eq (AHEW 42.6 g/eq). The TOTAL cell has no amount.
401
402
  const tip = x => (x.amount != null ? `${flRxFmt(x.amount)} g × ${flRxFmt(x.meq)} meq/g = ${x.eq.toFixed(3)} eq (${flRxTermText(x.group, x.meq)})` : `Σ ${_FL_RX_SHORT[x.group]} = ${x.eq.toFixed(3)} eq per 100 g`);
402
403
  // Two columns (Jun, 28 Oct: "epoxy and amine H should align by the number"): the numbers right-aligned, the group
@@ -434,6 +435,16 @@ function flRxStripHtml(f) {
434
435
  const solve = open && found.some(x => x.pair.key === open.pair) ? _flRxSolveRowHtml(f, open) : '';
435
436
  return `<div class="fl-rx-strip" id="fl-rx-strip-${esc(f.id)}"><span class="fl-rx-kicker">${kicker}</span>${chips}${kit}</div>${solve}`;
436
437
  }
438
+ // Leaving the formula closes an open Solve row: it used to stay open in memory and come back with the page (Jun, 1 Dec:
439
+ // "the second time the composition table loads, the solver shows up"). A redraw of the same page keeps it (25l).
440
+ if (typeof window !== 'undefined') {
441
+ window._viewLeaveHooks = window._viewLeaveHooks || {};
442
+ const _prevLeave = window._viewLeaveHooks['formulation-detail'];
443
+ window._viewLeaveHooks['formulation-detail'] = (toView, toParams) => {
444
+ Object.keys(_flRxSolveOpen).forEach(k => { delete _flRxSolveOpen[k]; });
445
+ if (typeof _prevLeave === 'function') _prevLeave(toView, toParams);
446
+ };
447
+ }
437
448
  // formulations.js holds the strip in #fl-rx-wrap-<id>; a target or the Solve row redraws only that.
438
449
  function flRxStripWrapHtml(f) { return f ? `<div class="fl-rx-wrap" id="fl-rx-wrap-${esc(f.id)}">${flRxStripHtml(f)}</div>` : ''; }
439
450
  function _flRxRefreshStrip(fId) {
@@ -502,6 +513,15 @@ function _flRxSolvableRows(f, pair) {
502
513
  function _flRxQsIdx(comp) { const qs = typeof QS_ROLE !== 'undefined' ? QS_ROLE : 'Balance (q.s.)'; return (comp || []).findIndex(c => c && c.role === qs); }
503
514
  // "Keep the total" moves the q.s. row by the same amount, so only when both rows are in one unit.
504
515
  function _flRxQsFor(comp, row) { const qi = _flRxQsIdx(comp); return qi >= 0 && qi !== row && String((comp[qi] || {}).unit || '') === String((comp[row] || {}).unit || '') ? qi : -1; }
516
+ // The total a Solve leaves (Jun, 1 Dec): in a % formula off 100 it is a warning that says how to keep 100, else the
517
+ // plain readout (25m).
518
+ function _flRxTotalHtml(comp, total, qi, keepQs) {
519
+ const rows = (comp || []).filter(c => c && (c.ingredientId || c.formulationId));
520
+ const pct = rows.length && rows.every(c => /%/.test(String(c.unit || '')));
521
+ if (!pct || Math.abs(total - 100) < 0.05) return ` <span class="fl-rx-dim">· total ${+total.toFixed(2)}</span>`;
522
+ const how = qi >= 0 && !keepQs ? 'tick keep the total' : _flRxQsIdx(comp) < 0 ? 'set one row’s role to Balance (q.s.) to keep 100' : '';
523
+ return ` <span class="fl-rx-warn">· total ${+total.toFixed(2)} ${esc(rows[0].unit)}${how ? ': ' + how : ''}</span>`;
524
+ }
505
525
  function _flRxIndexWith(comp, pair) { return flRxEval(pair, _flRxRows(comp)).index; }
506
526
  // Pure: the amount of comp[rowIdx] (and the q.s. row's, when keepQs) at which the index is `target`.
507
527
  // The index is a ratio, so it moves one way as one row's amount grows: a bisection finds it, through the same rows
@@ -616,7 +636,7 @@ function _flRxSolveRowHtml(f, st) {
616
636
  // The amounts as typed (18.05 → 20.06), not rounded to three figures: both sides of the arrow read alike.
617
637
  out = `${esc(_flRxRowName(c))} ${+r.from} → <b>${esc(r.amount)}</b> ${unit} <span class="fl-rx-dim">(${d >= 0 ? '+' : ''}${+d.toFixed(4)})</span>`
618
638
  + (r.qsIdx >= 0 ? ` <span class="fl-rx-dim">· ${esc(_flRxRowName(comp[r.qsIdx]))} ${+r.qsFrom} → ${r.qsAmount}</span>` : '')
619
- + ` <span class="fl-rx-dim">· total ${+total.toFixed(2)}</span>`
639
+ + _flRxTotalHtml(comp, total, _flRxQsFor(comp, st.row), st.keepQs)
620
640
  + (() => { const k = flRxKitRatio(comp.map((x, i) => (i === st.row ? { ...x, amount: r.amount } : i === r.qsIdx ? { ...x, amount: r.qsAmount } : x))); return k ? ` <span class="fl-rx-dim">· mix ${_flRxRatioText(k.weight)}</span>` : ''; })()
621
641
  + (outRange ? ` <span class="fl-rx-warn">outside its range (${lo ?? '…'}–${hi ?? '…'})</span>` : '');
622
642
  ok = !outRange;
@@ -626,12 +646,12 @@ function _flRxSolveRowHtml(f, st) {
626
646
  <b>Solve</b>
627
647
  <label>index <input type="number" step="any" min="0" value="${esc(String(st.target))}" oninput="_flRxSolveSet('${escJsAttr(f.id)}','target',this.value)" onkeydown="if(event.key==='Enter'&&!event.isComposing)flRxApplySolve('${escJsAttr(f.id)}')"></label>
628
648
  <label>by changing <select onchange="_flRxSolveSet('${escJsAttr(f.id)}','row',this.value)">${rows.map(opt).join('')}</select></label>
629
- <span class="fl-rx-result" id="fl-rx-result-${esc(f.id)}">${out}</span>
630
649
  ${qi >= 0 ? `<label class="fl-rx-check"><input type="checkbox"${st.keepQs ? ' checked' : ''} onchange="_flRxSolveSet('${escJsAttr(f.id)}','keepQs',this.checked)"> keep the total (from the q.s. row)</label>` : ''}
631
650
  <span class="fl-rx-solve-act">
632
651
  <button type="button" class="btn btn-secondary btn-sm" onclick="flRxOpenSolve('${escJsAttr(f.id)}','${escJsAttr(st.pair)}')">Cancel</button>
633
652
  <button type="button" class="btn btn-primary btn-sm" onclick="flRxApplySolve('${escJsAttr(f.id)}')"${ok ? '' : ' disabled'}>Apply</button>
634
653
  </span>
654
+ <span class="fl-rx-result" id="fl-rx-result-${esc(f.id)}">${out}</span>
635
655
  </div>`;
636
656
  }
637
657
  // The soap Solve row: superfat by changing the lye, then lye concentration by changing a water row.
@@ -653,7 +673,7 @@ function _flRxSoapSolveRowHtml(f, st) {
653
673
  + (r.qsIdx >= 0 ? ` <span class="fl-rx-dim">· ${esc(_flRxRowName(comp[r.qsIdx]))} ${+r.qsFrom} → ${r.qsAmount}</span>` : '')
654
674
  + (w && !w.error && wc ? ` · ${move(_flRxRowName(wc), _flRxNum(wc.amount) || 0, w.amount, wc.unit)}` : '')
655
675
  + (w && w.error ? ` <span class="fl-rx-warn">${w.error === 'bad' ? 'Enter a lye concentration between 0 and 100 %.' : `${esc(_flRxRowName(wc))} alone can’t reach ${_flRxPct(st.conc)} %.`}</span>` : '')
656
- + (res.comp ? ` <span class="fl-rx-dim">· total ${+res.comp.reduce((s, x) => s + (_flRxNum(x.amount) || 0), 0).toFixed(2)}</span>` : '')
676
+ + (res.comp ? _flRxTotalHtml(res.comp, res.comp.reduce((s, x) => s + (_flRxNum(x.amount) || 0), 0), qi, st.keepQs) : '')
657
677
  + (outRange ? ` <span class="fl-rx-warn">outside its range (${lo ?? '…'}–${hi ?? '…'})</span>` : '');
658
678
  ok = !outRange && !(w && w.error);
659
679
  }
@@ -661,16 +681,16 @@ function _flRxSoapSolveRowHtml(f, st) {
661
681
  const fid = escJsAttr(f.id);
662
682
  return `<div class="fl-rx-solve" id="fl-rx-solve-${esc(f.id)}">
663
683
  <b>Solve</b>
664
- <label>superfat <input type="number" step="any" value="${esc(String(+sf.toFixed(4)))}" oninput="_flRxSolveSet('${fid}','superfat',this.value)" onkeydown="if(event.key==='Enter'&&!event.isComposing)flRxApplySolve('${fid}')"> %</label>
665
- <label>by changing <select onchange="_flRxSolveSet('${fid}','row',this.value)">${rows.map(i => opt(i, st.row)).join('')}</select></label>
666
- ${waters.length ? `<label>lye concentration <input type="number" step="any" min="0" max="100" placeholder="keep" value="${esc(st.conc == null ? '' : String(st.conc))}" oninput="_flRxSolveSet('${fid}','conc',this.value)" onkeydown="if(event.key==='Enter'&&!event.isComposing)flRxApplySolve('${fid}')"> %</label>
667
- <label>by changing <select onchange="_flRxSolveSet('${fid}','wrow',this.value)">${waters.map(i => opt(i, st.wrow)).join('')}</select></label>` : ''}
668
- <span class="fl-rx-result" id="fl-rx-result-${esc(f.id)}">${out}</span>
684
+ <span class="fl-rx-sgrp"><label>superfat <input type="number" step="any" value="${esc(String(+sf.toFixed(4)))}" oninput="_flRxSolveSet('${fid}','superfat',this.value)" onkeydown="if(event.key==='Enter'&&!event.isComposing)flRxApplySolve('${fid}')"> %</label>
685
+ <label>by changing <select onchange="_flRxSolveSet('${fid}','row',this.value)">${rows.map(i => opt(i, st.row)).join('')}</select></label></span>
686
+ ${waters.length ? `<span class="fl-rx-sgrp"><label>lye concentration <input type="number" step="any" min="0" max="100" placeholder="keep" value="${esc(st.conc == null ? '' : String(st.conc))}" oninput="_flRxSolveSet('${fid}','conc',this.value)" onkeydown="if(event.key==='Enter'&&!event.isComposing)flRxApplySolve('${fid}')"> %</label>
687
+ <label>by changing <select onchange="_flRxSolveSet('${fid}','wrow',this.value)">${waters.map(i => opt(i, st.wrow)).join('')}</select></label></span>` : ''}
669
688
  ${qi >= 0 ? `<label class="fl-rx-check"><input type="checkbox"${st.keepQs ? ' checked' : ''} onchange="_flRxSolveSet('${fid}','keepQs',this.checked)"> keep the total (from the q.s. row)</label>` : ''}
670
689
  <span class="fl-rx-solve-act">
671
690
  <button type="button" class="btn btn-secondary btn-sm" onclick="flRxOpenSolve('${fid}','${escJsAttr(st.pair)}')">Cancel</button>
672
691
  <button type="button" class="btn btn-primary btn-sm" onclick="flRxApplySolve('${fid}')"${ok ? '' : ' disabled'}>Apply</button>
673
692
  </span>
693
+ <span class="fl-rx-result" id="fl-rx-result-${esc(f.id)}">${out}</span>
674
694
  </div>`;
675
695
  }
676
696
  function _flRxSolveSet(fId, k, v) {