formlab-mcp 0.6.94 → 0.6.95
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 -0
- package/data.js +14 -0
- package/index.js +5 -2
- package/package.json +1 -1
- package/server.json +2 -2
- package/tools/analytics.js +3 -3
- package/tools/discussions.js +2 -2
- package/tools/library.js +2 -2
- package/tools/suppliers.js +2 -2
package/README.md
CHANGED
|
@@ -212,3 +212,5 @@ The wrapped form is the default since 2026; the legacy form is supported for old
|
|
|
212
212
|
## License
|
|
213
213
|
|
|
214
214
|
The server code is MIT-licensed. It bundles FormLab's calculation engine (`vendor/`) under a proprietary license that allows use only as part of formlab-mcp; see LICENSE.
|
|
215
|
+
|
|
216
|
+
**Dates.** Stored times are UTC (`…Z`). The server tells the assistant this computer's time zone, so dates and times are given in local time; days the server works out (`asOf`, `lastReceived`, a report with no test date) are already local days. Plain dates (test, prepared, expiry) are calendar days as entered.
|
package/data.js
CHANGED
|
@@ -201,3 +201,17 @@ export function flattenComposition(formulation, depth = 0) {
|
|
|
201
201
|
});
|
|
202
202
|
return { rows: [...merged.values()] };
|
|
203
203
|
}
|
|
204
|
+
|
|
205
|
+
// 0.6.95: days in the lab's local time zone (Jun, 28 Nov). Stored times are UTC ("…Z"); a day cut from one with
|
|
206
|
+
// slice(0, 10) is the UTC day, which in the evening west of Greenwich is already tomorrow. The server runs on the
|
|
207
|
+
// lab's own computer, so its clock's zone is the lab's. A plain YYYY-MM-DD (test, prepared, expiry dates) is a
|
|
208
|
+
// calendar day as entered and stays as it is.
|
|
209
|
+
export const LOCAL_TZ = (() => { try { return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'; } catch (_) { return 'UTC'; } })();
|
|
210
|
+
const _ymd = d => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
211
|
+
export function localDay(v) {
|
|
212
|
+
if (v == null || v === '') return '';
|
|
213
|
+
if (typeof v === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(v)) return v;
|
|
214
|
+
const d = v instanceof Date ? v : new Date(v);
|
|
215
|
+
return isNaN(d.getTime()) ? String(v).slice(0, 10) : _ymd(d);
|
|
216
|
+
}
|
|
217
|
+
export function localToday() { return _ymd(new Date()); }
|
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
ListToolsRequestSchema,
|
|
28
28
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
29
29
|
|
|
30
|
-
import { loadStore, watchStore, getStore } from './data.js';
|
|
30
|
+
import { loadStore, watchStore, getStore, LOCAL_TZ } from './data.js';
|
|
31
31
|
import { startCloud } from './cloud.js';
|
|
32
32
|
import * as formulations from './tools/formulations.js';
|
|
33
33
|
import * as ingredients from './tools/ingredients.js';
|
|
@@ -144,9 +144,12 @@ const PKG_VERSION = (() => {
|
|
|
144
144
|
}
|
|
145
145
|
})();
|
|
146
146
|
|
|
147
|
+
// 0.6.95: the lab's time zone, so a stored UTC time ("…Z") is told as the local day and time (an evening time west of
|
|
148
|
+
// Greenwich is already tomorrow in UTC). Plain dates are calendar days as entered.
|
|
149
|
+
const INSTRUCTIONS = `Times ending in "Z" (createdAt, updatedAt, holdAt, releasedAt, issuedAt, shipment dates…) are UTC. This lab's time zone is ${LOCAL_TZ}: when you give a date or time from one, convert it to ${LOCAL_TZ} first (late evening there can already be the next day in UTC). Plain dates with no time (testDate, preparedDate, expiryDate, best-by) are calendar days as entered: give them as they are. Day fields the server works out (asOf, a report's day when it has no test date, a supplier's lastReceived) are already ${LOCAL_TZ} days.`;
|
|
147
150
|
const server = new Server(
|
|
148
151
|
{ name: 'formlab-mcp', version: PKG_VERSION },
|
|
149
|
-
{ capabilities: { tools: {} } }
|
|
152
|
+
{ capabilities: { tools: {} }, instructions: INSTRUCTIONS }
|
|
150
153
|
);
|
|
151
154
|
|
|
152
155
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formlab-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.95",
|
|
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.95",
|
|
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.95",
|
|
12
12
|
"runtimeHint": "npx",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
package/tools/analytics.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// - get_stability (drift + I-chart + shelf-life, split by condition)
|
|
11
11
|
// ============================================================
|
|
12
12
|
|
|
13
|
-
import { getStore, resolveById, flattenComposition } from '../data.js';
|
|
13
|
+
import { getStore, resolveById, flattenComposition, localDay, localToday } from '../data.js';
|
|
14
14
|
|
|
15
15
|
// Which instrument produced a measurement. Mirrors the app's _trMeasInstrument:
|
|
16
16
|
// a measurement's raw `instrument` is usually EMPTY because blank means inherit,
|
|
@@ -1887,7 +1887,7 @@ const get_stability = {
|
|
|
1887
1887
|
// specs (two panels) → no band + `specVaries`, never an intersection.
|
|
1888
1888
|
const specByKey = new Map();
|
|
1889
1889
|
(db.testResults || []).filter(t => sampleIds.has(t.sampleId)).forEach(t => {
|
|
1890
|
-
const dStr = t.testDate || (t.createdAt ?
|
|
1890
|
+
const dStr = t.testDate || (t.createdAt ? localDay(t.createdAt) : null); // 0.6.95: its local day
|
|
1891
1891
|
if (!dStr) return;
|
|
1892
1892
|
const date = new Date(dStr + (t.testTime && /^\d{4}-\d{2}-\d{2}$/.test(dStr) ? 'T' + t.testTime : ''));
|
|
1893
1893
|
if (!Number.isFinite(date.getTime())) return;
|
|
@@ -2068,7 +2068,7 @@ const list_stability_pulls = {
|
|
|
2068
2068
|
const mine = x => !f || x.formula.id === f.id;
|
|
2069
2069
|
const pulls = r.due.filter(x => mine(x) && x.daysUntil <= within);
|
|
2070
2070
|
return {
|
|
2071
|
-
asOf:
|
|
2071
|
+
asOf: args.as_of && /^\d{4}-\d{2}-\d{2}$/.test(args.as_of) ? args.as_of : localToday(), withinDays: within, // 0.6.95: today is the local day
|
|
2072
2072
|
...(f ? { formulation: { uid: f.uid, name: f.name } } : {}),
|
|
2073
2073
|
count: pulls.length, overdue: pulls.filter(x => x.overdue).length, pulls,
|
|
2074
2074
|
later: r.due.filter(x => mine(x) && x.daysUntil > within).length,
|
package/tools/discussions.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// none. Read-only; the server applies project walls and the owner's switch for restricted projects.
|
|
8
8
|
// ============================================================
|
|
9
9
|
|
|
10
|
-
import { getStore } from '../data.js';
|
|
10
|
+
import { getStore, localToday } from '../data.js';
|
|
11
11
|
|
|
12
12
|
const _norm = (s) => String(s == null ? '' : s).toLowerCase();
|
|
13
13
|
const _clampLimit = (n) => Math.min(1000, Math.max(1, n || 100));
|
|
@@ -115,7 +115,7 @@ const list_requests = {
|
|
|
115
115
|
const { db } = getStore();
|
|
116
116
|
const none = _notLive(db); if (none) return none;
|
|
117
117
|
const limit = _clampLimit(args.limit);
|
|
118
|
-
const today =
|
|
118
|
+
const today = localToday(); // 0.6.95: the local day, not UTC
|
|
119
119
|
const active = new Set(['open', 'in_progress', 'blocked']);
|
|
120
120
|
const wantId = _resolveId(args.entity_type, args.entity_id, db);
|
|
121
121
|
const order = { blocked: 0, open: 1, in_progress: 2, done: 3, cancelled: 4 };
|
package/tools/library.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// previously synced into the store but not queryable.
|
|
12
12
|
// ============================================================
|
|
13
13
|
|
|
14
|
-
import { getStore, resolveById } from '../data.js';
|
|
14
|
+
import { getStore, resolveById, localDay } from '../data.js';
|
|
15
15
|
import { calibrationStatus, calibrationHistory } from '../calibration.js';
|
|
16
16
|
import { _evalPassFail, _mcpRepNumber, _mcpMeasType, _resolveSpec, _mcpCondSig, _mcpCondLabel, _mcpCondTags, _mcpParamGroupsOf } from './analytics.js';
|
|
17
17
|
|
|
@@ -54,7 +54,7 @@ function _usageRollup(db, tests, measFilter) {
|
|
|
54
54
|
const sById = new Map((db.samples || []).map(s => [s.id, s]));
|
|
55
55
|
const bById = new Map((db.batches || []).map(b => [b.id, b]));
|
|
56
56
|
const fById = new Map((db.formulations || []).map(f => [f.id, f]));
|
|
57
|
-
const date = t => String(t.testDate || (t.createdAt || '').
|
|
57
|
+
const date = t => String(t.testDate || localDay(t.createdAt) || ''); // 0.6.95: a report with no test date: its local day
|
|
58
58
|
const byF = new Map(); const forms = new Set(), batches = new Set(), samples = new Set(), labs = new Set();
|
|
59
59
|
let readings = 0, fails = 0, withSpec = 0, last = '';
|
|
60
60
|
tests.forEach(t => {
|
package/tools/suppliers.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// names it as the manufacturer — a maker's recall must reach lots bought
|
|
8
8
|
// through a distributor. Read-only, like every tool here.
|
|
9
9
|
// =====================================================================
|
|
10
|
-
import { getStore, resolveById } from '../data.js';
|
|
10
|
+
import { getStore, resolveById, localDay } from '../data.js';
|
|
11
11
|
|
|
12
12
|
const SUFFIX_RE = /\b(inc|incorporated|ltd|limited|llc|gmbh|co|corp|corporation|company|ag|sa|plc|bv|nv|srl|s\.?a\.?|pty)\b\.?$/i;
|
|
13
13
|
function norm(name) {
|
|
@@ -74,7 +74,7 @@ function rowOf(db, sup) {
|
|
|
74
74
|
ingredientCount: refs.ingredients.length, lotCount: refs.lots.length, lotsOnHand: onHandLots,
|
|
75
75
|
onHandValue: onHandValue == null ? null : +onHandValue.toFixed(2), onHandValueCcy: onHandValue == null ? null : valueCcy,
|
|
76
76
|
qualifiedSources: qs.qualified, trialSources: qs.trial, disqualifiedSources: qs.disqualified,
|
|
77
|
-
lastReceived: lastReceived ? lastReceived
|
|
77
|
+
lastReceived: lastReceived ? localDay(lastReceived) : null, // 0.6.95: local day
|
|
78
78
|
_refs: refs,
|
|
79
79
|
};
|
|
80
80
|
}
|