formlab-mcp 0.6.91 → 0.6.92
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/README.md +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
- package/tools/lab.js +33 -2
package/README.md
CHANGED
|
@@ -41,8 +41,8 @@ Ask Claude (or another MCP client) things like:
|
|
|
41
41
|
| `get_supplier` | One supplier in full: record, every ingredient it's an approved source for, every lot from it, and the **recall trace** (batches that consumed those lots → products, shipments, samples, sub-batches; lots on hold flagged) |
|
|
42
42
|
| `list_documents` | The document register (same as the app's Documents page): ingredient SDS / PDS / CoA / other with lot, version, source and expiry; test and notebook attachments; per-record uploads and links (formulas, batches, samples, suppliers, equipment…). File **metadata** only, never the text inside a file, with who added each file (`addedBy`) and when. Filters: `type`, `record`, `linked`, `query`, `lot`, `format`, `expiry`, `expiring_within_days`, `without_expiry`, `uploaded_within_days`, `added_by`. A `summary` block carries the page's tile counts: expired, expiring in 30 days, SDS/CoA without expiry, ingredients missing an SDS (+ coverage %), lots in stock without a CoA, added last 7 days |
|
|
43
43
|
| `list_inventory` | Portfolio stock rollup — one row per ingredient with on-hand qty, summed lot balance, nearest expiry, and a low-stock flag (on-hand ≤ `reorderThreshold`, or zero). Filters: `low_stock_only`, `expiring_within_days`, `family` |
|
|
44
|
-
| `list_batches` | Filtered list of production / lab-prep events; each row has **`bestBy`**; filter by `best_by_before` (past best-by = today) or `lots_expire_first` |
|
|
45
|
-
| `get_batch` | Full record + actual composition, measured/derived **actual volume** (mass ÷ density, never a sum of per-ingredient volumes) and **actual mass** (yield, else summed as-prepared inputs — mL rows through that ingredient's density — else measured volume × density), **estimatedVolume** (mass ÷ the formula's finished density when no actual exists, flagged `estimate: true`), **plannedMass** for volume-target batches (target × finished density) and **formulaFinishedDensity**, the **process** method + any **process-factor values** (DOE inputs), samples + blend lineage, and — as a finished-goods lot — its **`bestBy`** (the adjusted date with its change, reason, note and retest report, else prepared date + shelf life; `lotsExpiringFirst` = lots it drew from that expire sooner), its storage **`location`** + finished-goods **`stockLedger`** (shipments out + adjustments; `shippedQty` total), and its **theoretical parameters computed on the batch as made** (actual composition when logged — `basis: "actual"` — else the recipe; the batch's own parameter list when it overrides the formula's) |
|
|
44
|
+
| `list_batches` | Filtered list of production / lab-prep events; each row has **`bestBy`**; filter by `best_by_before` (past best-by = today) or `lots_expire_first`, `on_hold`, `made_with_lot` (batches that drew from a recalled lot), `held_lot` (drew from any lot now on hold) |
|
|
45
|
+
| `get_batch` | Full record + **`lotsUsed`** (raw lots drawn, with each lot's status and hold reason now) + actual composition, measured/derived **actual volume** (mass ÷ density, never a sum of per-ingredient volumes) and **actual mass** (yield, else summed as-prepared inputs — mL rows through that ingredient's density — else measured volume × density), **estimatedVolume** (mass ÷ the formula's finished density when no actual exists, flagged `estimate: true`), **plannedMass** for volume-target batches (target × finished density) and **formulaFinishedDensity**, the **process** method + any **process-factor values** (DOE inputs), samples + blend lineage, and — as a finished-goods lot — its **`bestBy`** (the adjusted date with its change, reason, note and retest report, else prepared date + shelf life; `lotsExpiringFirst` = lots it drew from that expire sooner), its storage **`location`** + finished-goods **`stockLedger`** (shipments out + adjustments; `shippedQty` total), and its **theoretical parameters computed on the batch as made** (actual composition when logged — `basis: "actual"` — else the recipe; the batch's own parameter list when it overrides the formula's) |
|
|
46
46
|
| `list_samples` | Filtered list of physical specimens |
|
|
47
47
|
| `get_sample` | Full record + canonical variant + test reports + blend lineage + its stability pulls (next pull, or pulled at) |
|
|
48
48
|
| `list_test_results` | Filtered list of test reports (by sample, parameter, **measured-value range** (`value_min`/`value_max` — a curve at its final point, a distribution at its spec's statistic or D50), **grade** (`min_grade`/`max_grade` on a ranked scale), **text value** (`value_equals`), **run condition** (`condition`), date, or lab) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formlab-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.92",
|
|
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.92",
|
|
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.92",
|
|
12
12
|
"runtimeHint": "npx",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
package/tools/lab.js
CHANGED
|
@@ -284,10 +284,26 @@ function _trimSample(s, formulationsById, batchesById) {
|
|
|
284
284
|
};
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
// Raw lots a batch drew, net of material returned to the lot, with each lot's status now (0.6.92).
|
|
288
|
+
function _batchLotsUsed(db, batchId) {
|
|
289
|
+
const net = new Map();
|
|
290
|
+
(db.stockMovements || []).forEach(m => {
|
|
291
|
+
if (!m || m.batchId !== batchId || !m.lotId) return;
|
|
292
|
+
const d = Number(m.delta); if (!Number.isFinite(d)) return;
|
|
293
|
+
net.set(m.lotId, (net.get(m.lotId) || 0) - d);
|
|
294
|
+
});
|
|
295
|
+
return [...net].filter(([, q]) => q > 0.0000005).map(([lotId, q]) => {
|
|
296
|
+
const l = (db.lots || []).find(x => x && x.id === lotId) || {};
|
|
297
|
+
const ing = (db.ingredients || []).find(i => i && i.id === l.ingredientId);
|
|
298
|
+
return { lotId, lotUid: l.uid || '', lotNumber: l.lotNumber || '', ingredient: ing ? (ing.uid || ing.name || '') : '', ingredientName: ing ? (ing.name || '') : '',
|
|
299
|
+
qty: Math.round(q * 1e6) / 1e6, unit: l.unit || '', status: l.status || 'active', holdReason: l.status === 'hold' ? (l.holdReason || '') : '' };
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
287
303
|
const list_batches = {
|
|
288
304
|
definition: {
|
|
289
305
|
name: 'list_batches',
|
|
290
|
-
description: 'List batches (production / lab-prep events), optionally filtered by formulation, status, origin-only (hides batches derived from other batches), best-by before a date,
|
|
306
|
+
description: 'List batches (production / lab-prep events), optionally filtered by formulation, status, origin-only (hides batches derived from other batches), best-by before a date, batches whose ingredient lots expire before their best-by, batches made with a given raw lot (made_with_lot), or with a lot now on hold (held_lot). Each row carries `bestBy` (date, adjusted or from shelf life, the reason, lots expiring first). Returns metadata; use get_batch for the full consumption ledger and samples.',
|
|
291
307
|
inputSchema: {
|
|
292
308
|
type: 'object',
|
|
293
309
|
properties: {
|
|
@@ -299,6 +315,8 @@ const list_batches = {
|
|
|
299
315
|
lots_expire_first: { type: 'boolean', description: 'When true, only batches that drew from an ingredient lot expiring before the batch\'s best-by (the app\'s ⚠ on Best by).' },
|
|
300
316
|
shipped_to: { type: 'string', description: 'Only batches with a shipment whose note (customer / destination / PO) contains this text, case-insensitive. Use it to find which batch went to a customer.' },
|
|
301
317
|
on_hold: { type: 'boolean', description: 'When true, only finished batches currently on hold (no shipment can be recorded until released).' },
|
|
318
|
+
made_with_lot: { type: 'string', description: 'Only batches that drew from this raw lot: its lot number (e.g. "BIT-9912", from a supplier recall), lot UID, or internal id. Answers "which batches used the recalled lot?"; pair with on_hold to see which are not held yet.' },
|
|
319
|
+
held_lot: { type: 'boolean', description: 'When true, only batches that drew from a raw lot now on hold, whether or not the batch itself is held.' },
|
|
302
320
|
limit: { type: 'number', description: 'Max rows (default 50, max 500).' },
|
|
303
321
|
},
|
|
304
322
|
},
|
|
@@ -314,8 +332,18 @@ const list_batches = {
|
|
|
314
332
|
if (!f) return { error: `No formulation matched "${args.formulation_id}".` };
|
|
315
333
|
formId = f.id;
|
|
316
334
|
}
|
|
335
|
+
let lotBatches = null;
|
|
336
|
+
if (args.made_with_lot) {
|
|
337
|
+
const w = norm(args.made_with_lot).trim();
|
|
338
|
+
const lotIds = new Set((db.lots || []).filter(l => l && !l._trashed && (l.id === args.made_with_lot || norm(l.uid) === w || norm(l.lotNumber) === w)).map(l => l.id));
|
|
339
|
+
if (!lotIds.size) return { error: `No lot matched "${args.made_with_lot}" (lot number, lot UID, or id).` };
|
|
340
|
+
lotBatches = new Set((db.stockMovements || []).filter(m => m && lotIds.has(m.lotId) && m.batchId && Number(m.delta) < 0).map(m => m.batchId));
|
|
341
|
+
}
|
|
342
|
+
const heldBatches = args.held_lot ? (() => { const held = new Set((db.lots || []).filter(l => l && !l._trashed && l.status === 'hold').map(l => l.id)); return new Set((db.stockMovements || []).filter(m => m && held.has(m.lotId) && m.batchId && Number(m.delta) < 0).map(m => m.batchId)); })() : null;
|
|
317
343
|
const filtered = (db.batches || []).filter(b => {
|
|
318
344
|
if (!b || b._trashed) return false;
|
|
345
|
+
if (lotBatches && !lotBatches.has(b.id)) return false;
|
|
346
|
+
if (heldBatches && !heldBatches.has(b.id)) return false;
|
|
319
347
|
if (formId && b.formulationId !== formId) return false;
|
|
320
348
|
if (args.status && !norm(b.status).includes(norm(args.status))) return false;
|
|
321
349
|
if (args.origin_only && b.parentBatchId) return false;
|
|
@@ -341,7 +369,7 @@ const list_batches = {
|
|
|
341
369
|
const get_batch = {
|
|
342
370
|
definition: {
|
|
343
371
|
name: 'get_batch',
|
|
344
|
-
description: 'Get full details for a single batch including its actual composition (as-prepared, when logged), child samples, lineage (parent / sub-blend parents), and — treating the batch as a finished-goods lot — its storage `location` and finished-goods `stockLedger` (shipments out + adjustments; on-hand = produced − sample pulls − sub-batch draws + Σ ledger). Plus finished-product density + actual volume (measured directly or derived as actual mass ÷ measured density — never summed from per-ingredient volumes). Accepts internal id or UID. Also returns `theoreticalParameters` computed on the batch as made (its actual composition when logged — `basis: "actual"` — else the recipe of its formula), with the batch parameter list when it overrides the one on the formula; same fields as get_formulation.',
|
|
372
|
+
description: 'Get full details for a single batch including the raw lots it drew (lotsUsed: lot number, quantity, and the status of each lot now, with holdReason for a lot on hold), its actual composition (as-prepared, when logged), child samples, lineage (parent / sub-blend parents), and — treating the batch as a finished-goods lot — its storage `location` and finished-goods `stockLedger` (shipments out + adjustments; on-hand = produced − sample pulls − sub-batch draws + Σ ledger). Plus finished-product density + actual volume (measured directly or derived as actual mass ÷ measured density — never summed from per-ingredient volumes). Accepts internal id or UID. Also returns `theoreticalParameters` computed on the batch as made (its actual composition when logged — `basis: "actual"` — else the recipe of its formula), with the batch parameter list when it overrides the one on the formula; same fields as get_formulation.',
|
|
345
373
|
inputSchema: {
|
|
346
374
|
type: 'object',
|
|
347
375
|
properties: {
|
|
@@ -391,6 +419,9 @@ const get_batch = {
|
|
|
391
419
|
shippedQty: (Array.isArray(b.stockLedger) ? b.stockLedger : []).reduce((s, e) => e.kind === 'shipment' ? s + Math.abs(parseFloat(e.delta) || 0) : s, 0),
|
|
392
420
|
// Finished-batch hold: while set, the app records no shipment of this batch (QA / complaint / recall).
|
|
393
421
|
hold: (b.fgHold && b.fgHold.at) ? { since: b.fgHold.at, by: b.fgHold.by || '', reason: b.fgHold.reason || '' } : null,
|
|
422
|
+
// 0.6.92: the raw lots this batch drew (net of returns), each with its status now. A lot on hold
|
|
423
|
+
// here ("status: hold" + holdReason) is why a recall reaches this batch, held or not.
|
|
424
|
+
lotsUsed: _batchLotsUsed(getStore().db, b.id),
|
|
394
425
|
theoreticalParameters: theoreticalParams(getStore().db, 'batch', b.id),
|
|
395
426
|
};
|
|
396
427
|
},
|