formlab-mcp 0.6.60 → 0.6.61
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/index.js +2 -0
- package/package.json +1 -1
- package/server.json +2 -2
- package/tools/discussions.js +138 -0
- package/vendor/equipment-calibration.js +7 -1
package/README.md
CHANGED
|
@@ -68,6 +68,8 @@ Ask Claude (or another MCP client) things like:
|
|
|
68
68
|
| `list_projects` | Filtered list of projects (the buckets formulations are filed under) + per-project formulation count. Filters: `status`, `name_contains` |
|
|
69
69
|
| `get_project` | Full project record + the formulations filed under it |
|
|
70
70
|
| `list_notebook_entries` | ELN feed — dated authored notes attached to records. Append-only: a withdrawn note is kept with `retracted` = {at, by, reason}. Filters: `entity_type`, `entity_id`, `author`, `text_contains`, `since`, `until`, `retracted` |
|
|
71
|
+
| `list_discussions` | Discussions beside records and work requests (live workspace): threads with their comments, resolved or not; append-only, a retracted comment keeps `retracted` = {at, reason}; `tab` = the record tab it was written on. Filters: `entity_type`, `entity_id`, `author`, `text_contains`, `since`, `open_only`, `flat` |
|
|
72
|
+
| `list_requests` | Work requests REQ-0001 … (Team, live workspace): title, kind, status (blocked with a reason), assignee, asked by, due, late, the linked record. Filters: `status` (or `active`), `assignee`, `kind`, `entity_type`, `entity_id`, `late_only` |
|
|
71
73
|
| `get_notebook_entry` | One notebook entry — full body, author, attachment metadata, resolved linked record, and `retracted` when withdrawn |
|
|
72
74
|
|
|
73
75
|
## Install
|
package/index.js
CHANGED
|
@@ -37,6 +37,7 @@ import * as designspace from './tools/designspace.js';
|
|
|
37
37
|
import * as library from './tools/library.js';
|
|
38
38
|
import * as projects from './tools/projects.js';
|
|
39
39
|
import * as notebook from './tools/notebook.js';
|
|
40
|
+
import * as discussions from './tools/discussions.js';
|
|
40
41
|
import * as batchAnalyze from './tools/batch-analyze.js';
|
|
41
42
|
import * as suppliers from './tools/suppliers.js';
|
|
42
43
|
import * as documents from './tools/documents.js';
|
|
@@ -123,6 +124,7 @@ const TOOLS = [
|
|
|
123
124
|
...Object.values(library.tools),
|
|
124
125
|
...Object.values(projects.tools),
|
|
125
126
|
...Object.values(notebook.tools),
|
|
127
|
+
...Object.values(discussions.tools),
|
|
126
128
|
...Object.values(suppliers.tools),
|
|
127
129
|
...Object.values(documents.tools),
|
|
128
130
|
...Object.values(batchAnalyze.tools),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formlab-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.61",
|
|
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.61",
|
|
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.61",
|
|
12
12
|
"runtimeHint": "npx",
|
|
13
13
|
"transport": {
|
|
14
14
|
"type": "stdio"
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// DISCUSSION + REQUEST TOOLS (FormLab Team / Pro shared workspaces, migrations 0201-0203).
|
|
3
|
+
// - list_discussions: comments beside records (and on work requests), grouped by thread or flat
|
|
4
|
+
// - list_requests: work requests (REQ-0001 …): what was asked of whom, by when, and where it stands
|
|
5
|
+
// A discussion is part of the record's history, not a chat: comments are append-only (a retracted one is kept with
|
|
6
|
+
// retracted = {at, reason} — never cite it as a finding). Only in a live workspace (cloud mode); an export file has
|
|
7
|
+
// none. Read-only; the server applies project walls and the owner's switch for restricted projects.
|
|
8
|
+
// ============================================================
|
|
9
|
+
|
|
10
|
+
import { getStore } from '../data.js';
|
|
11
|
+
|
|
12
|
+
const _norm = (s) => String(s == null ? '' : s).toLowerCase();
|
|
13
|
+
const _clampLimit = (n) => Math.min(1000, Math.max(1, n || 100));
|
|
14
|
+
|
|
15
|
+
const _COLL = {
|
|
16
|
+
formulation: 'formulations', batch: 'batches', sample: 'samples', testResult: 'testResults', project: 'projects',
|
|
17
|
+
ingredient: 'ingredients', equipment: 'equipment', parameter: 'parameters', template: 'templates', lot: 'lots', doeDesign: 'doeDesigns',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function _record(type, id, db) {
|
|
21
|
+
if (type === 'request') {
|
|
22
|
+
const r = (db.requests || []).find(x => x && x.id === id);
|
|
23
|
+
return r ? { uid: r.uid, name: r.title } : null;
|
|
24
|
+
}
|
|
25
|
+
const rec = (db[_COLL[type]] || []).find(x => x && (x.id === id || x.uid === id));
|
|
26
|
+
return rec ? { uid: rec.uid || null, name: rec.name || rec.reportName || rec.title || '' } : null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// A UID or id the caller passed, down to the id the comments carry.
|
|
30
|
+
function _resolveId(type, id, db) {
|
|
31
|
+
if (!id) return null;
|
|
32
|
+
if (type === 'request') { const r = (db.requests || []).find(x => x && (x.id === id || x.uid === id)); return r ? r.id : id; }
|
|
33
|
+
const rec = (db[_COLL[type]] || []).find(x => x && (x.id === id || x.uid === id));
|
|
34
|
+
return rec ? rec.id : id;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _notLive(db) {
|
|
38
|
+
return !Array.isArray(db.discussions) && !Array.isArray(db.requests)
|
|
39
|
+
? { error: 'Discussions and requests are read from a live FormLab workspace (cloud mode). This data source has none.' } : null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const list_discussions = {
|
|
43
|
+
definition: {
|
|
44
|
+
name: 'list_discussions',
|
|
45
|
+
description: 'List discussion comments that sit beside records (formulas, batches, samples, test reports, projects, ingredients, equipment) or work requests — optionally filtered by the record (entity_type + entity_id, UID accepted), author, text, date, or only unresolved threads. Grouped by thread by default (each thread: the record, resolved or not, its comments oldest first); flat=true returns comments newest first. Comments are append-only: a retracted one keeps retracted = {at, reason} — treat it as withdrawn, not as a finding. "tab" says which tab of the record the comment was written on.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
entity_type: { type: 'string', description: 'formulation, batch, sample, testResult, project, ingredient, equipment, or request.' },
|
|
50
|
+
entity_id: { type: 'string', description: 'The record (internal id or UID, e.g. FORM-0012, REQ-0003).' },
|
|
51
|
+
author: { type: 'string', description: 'Case-insensitive substring of the author\'s name.' },
|
|
52
|
+
text_contains: { type: 'string', description: 'Case-insensitive substring of the comment text.' },
|
|
53
|
+
since: { type: 'string', description: 'ISO date/time: only comments at or after it.' },
|
|
54
|
+
open_only: { type: 'boolean', description: 'true = only threads not resolved.' },
|
|
55
|
+
flat: { type: 'boolean', description: 'true = a flat list of comments, newest first, instead of threads.' },
|
|
56
|
+
limit: { type: 'number', description: 'Max threads (or comments when flat), default 100, max 1000.' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
handler: async (args) => {
|
|
61
|
+
const { db } = getStore();
|
|
62
|
+
const none = _notLive(db); if (none) return none;
|
|
63
|
+
const limit = _clampLimit(args.limit);
|
|
64
|
+
const wantId = _resolveId(args.entity_type, args.entity_id, db);
|
|
65
|
+
const sinceMs = args.since ? Date.parse(args.since) : null;
|
|
66
|
+
const all = (db.discussions || []).filter(c => c && (!args.entity_type || c.entityType === args.entity_type) && (!wantId || c.entityId === wantId));
|
|
67
|
+
const threads = new Map();
|
|
68
|
+
all.forEach(c => { const k = `${c.entityType}:${c.entityId}`; if (!threads.has(k)) threads.set(k, []); threads.get(k).push(c); });
|
|
69
|
+
const resolvedOf = (list) => { const last = list.filter(c => c.kind !== 'comment').pop(); return !!(last && last.kind === 'resolve'); };
|
|
70
|
+
const keep = (c) => c.kind === 'comment'
|
|
71
|
+
&& (!args.author || _norm(c.author).includes(_norm(args.author)))
|
|
72
|
+
&& (!args.text_contains || _norm(c.body).includes(_norm(args.text_contains)))
|
|
73
|
+
&& (sinceMs == null || Date.parse(c.at) >= sinceMs);
|
|
74
|
+
const row = (c) => ({ id: c.id, author: c.author, at: c.at, body: c.body, tab: c.tab || null, replyTo: c.replyTo || null,
|
|
75
|
+
retracted: c.retracted || null });
|
|
76
|
+
if (args.flat) {
|
|
77
|
+
const flat = [...threads.values()].filter(l => !args.open_only || !resolvedOf(l)).flat().filter(keep)
|
|
78
|
+
.sort((a, b) => Date.parse(b.at) - Date.parse(a.at));
|
|
79
|
+
return { totalMatching: flat.length, returned: Math.min(flat.length, limit),
|
|
80
|
+
comments: flat.slice(0, limit).map(c => { const rec = _record(c.entityType, c.entityId, db);
|
|
81
|
+
return { ...row(c), entityType: c.entityType, entityId: c.entityId, entityUid: rec ? rec.uid : null, entityName: rec ? rec.name : '' }; }) };
|
|
82
|
+
}
|
|
83
|
+
const out = [...threads.values()].map(list => {
|
|
84
|
+
const comments = list.filter(keep);
|
|
85
|
+
if (!comments.length) return null;
|
|
86
|
+
const c0 = list[0], rec = _record(c0.entityType, c0.entityId, db), resolved = resolvedOf(list);
|
|
87
|
+
if (args.open_only && resolved) return null;
|
|
88
|
+
return { entityType: c0.entityType, entityId: c0.entityId, entityUid: rec ? rec.uid : null, entityName: rec ? rec.name : '',
|
|
89
|
+
resolved, lastAt: list[list.length - 1].at, comments: comments.map(row) };
|
|
90
|
+
}).filter(Boolean).sort((a, b) => Date.parse(b.lastAt) - Date.parse(a.lastAt));
|
|
91
|
+
return { totalMatching: out.length, returned: Math.min(out.length, limit), threads: out.slice(0, limit) };
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const list_requests = {
|
|
96
|
+
definition: {
|
|
97
|
+
name: 'list_requests',
|
|
98
|
+
description: 'List work requests (REQ-0001 …) in a FormLab Team workspace: what was asked of whom, by when, on which record, and where it stands (open, in_progress, blocked with a reason, done, cancelled). Filter by status, assignee (name substring), kind (batch, tests, samples, review, other), the linked record (UID accepted), or late only. Open ones first, then by due date.',
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
status: { type: 'string', description: 'open, in_progress, blocked, done, cancelled; or "active" for open + in_progress + blocked.' },
|
|
103
|
+
assignee: { type: 'string', description: 'Case-insensitive substring of the name of the person it is asked of.' },
|
|
104
|
+
kind: { type: 'string', description: 'batch, tests, samples, review, other.' },
|
|
105
|
+
entity_type: { type: 'string', description: 'The linked record\'s type (formulation, batch, sample, testResult, project).' },
|
|
106
|
+
entity_id: { type: 'string', description: 'The linked record (internal id or UID).' },
|
|
107
|
+
late_only: { type: 'boolean', description: 'true = only active requests past their due date.' },
|
|
108
|
+
limit: { type: 'number', description: 'Max rows (default 100, max 1000).' },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
handler: async (args) => {
|
|
113
|
+
const { db } = getStore();
|
|
114
|
+
const none = _notLive(db); if (none) return none;
|
|
115
|
+
const limit = _clampLimit(args.limit);
|
|
116
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
117
|
+
const active = new Set(['open', 'in_progress', 'blocked']);
|
|
118
|
+
const wantId = _resolveId(args.entity_type, args.entity_id, db);
|
|
119
|
+
const order = { blocked: 0, open: 1, in_progress: 2, done: 3, cancelled: 4 };
|
|
120
|
+
const rows = (db.requests || []).filter(r => r
|
|
121
|
+
&& (!args.status || (args.status === 'active' ? active.has(r.status) : r.status === args.status))
|
|
122
|
+
&& (!args.assignee || _norm(r.assignee).includes(_norm(args.assignee)))
|
|
123
|
+
&& (!args.kind || r.kind === args.kind)
|
|
124
|
+
&& (!args.entity_type || r.entityType === args.entity_type) && (!wantId || r.entityId === wantId)
|
|
125
|
+
&& (!args.late_only || (active.has(r.status) && r.due && r.due < today)))
|
|
126
|
+
.sort((a, b) => (order[a.status] - order[b.status]) || String(a.due || '9999').localeCompare(String(b.due || '9999')));
|
|
127
|
+
return {
|
|
128
|
+
totalMatching: rows.length, returned: Math.min(rows.length, limit),
|
|
129
|
+
requests: rows.slice(0, limit).map(r => { const rec = r.entityType ? _record(r.entityType, r.entityId, db) : null;
|
|
130
|
+
return { uid: r.uid, title: r.title, kind: r.kind, status: r.status, blockedReason: r.blockedReason || null, assignee: r.assignee || null,
|
|
131
|
+
askedBy: r.askedBy || null, due: r.due || null, late: !!(active.has(r.status) && r.due && r.due < today),
|
|
132
|
+
on: rec ? { type: r.entityType, uid: rec.uid, name: rec.name } : null, note: r.note || null,
|
|
133
|
+
createdAt: r.createdAt, closedAt: r.closedAt || null }; }),
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const tools = { list_discussions, list_requests };
|
|
@@ -151,7 +151,7 @@ function eqCalCardHtml(e) {
|
|
|
151
151
|
<span><span style="color:var(--text-muted)">Last</span> <strong>${esc(st.last || '—')}</strong>${st.lastResult ? ` · ${esc(_EQ_CAL_RESULT_LABEL[st.lastResult] || st.lastResult)}` : ''}</span>
|
|
152
152
|
<span><span style="color:var(--text-muted)">Next due</span> <strong>${esc(st.due || '—')}</strong></span>
|
|
153
153
|
<span><span style="color:var(--text-muted)">Interval</span> <strong>${interval ? interval + ' month' + (interval === 1 ? '' : 's') : '—'}</strong></span>
|
|
154
|
-
</div>${st.state === 'failed' && e.status !== 'Out of service' ? `<div style="margin-top:10px;font-size:12.5px;color:var(--dk-red-fg, #b91c1c)">The latest calibration failed. Set the instrument <strong>Out of service</strong> (
|
|
154
|
+
</div>${st.state === 'failed' && e.status !== 'Out of service' ? `<div style="margin-top:10px;font-size:12.5px;color:var(--dk-red-fg, #b91c1c)">The latest calibration failed. Set the instrument <strong>Out of service</strong> (the status beside its name) until it passes again.</div>` : ''}`;
|
|
155
155
|
const rows = hist.map(c => `<tr>
|
|
156
156
|
<td style="font-variant-numeric:tabular-nums">${esc(c.date || '—')}</td>
|
|
157
157
|
<td>${esc(c.by || '—')}</td>
|
|
@@ -199,6 +199,12 @@ function openEqCalLogModal(eqId, calId) {
|
|
|
199
199
|
const e = typeof getEquipment === 'function' ? getEquipment(eqId) : (db.equipment || []).find(x => x.id === eqId);
|
|
200
200
|
if (!e) return;
|
|
201
201
|
const c = calId ? (e.calibrations || []).find(x => x && x.id === calId) : null;
|
|
202
|
+
// EQ1 (0186): a Technician adds calibrations; changing or deleting a logged one stays with "Edit the shared libraries".
|
|
203
|
+
const caps = typeof window !== 'undefined' ? window.flMyCaps : null;
|
|
204
|
+
if (c && Array.isArray(caps) && !caps.includes('library.edit')) {
|
|
205
|
+
toast('Your role can log new calibrations, not change a logged one. Ask a lab manager or a formulator.');
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
202
208
|
const interval = eqCalInterval(e);
|
|
203
209
|
const date = c ? (c.date || '') : _eqCalToday();
|
|
204
210
|
const files = Array.isArray(e.fileAttachments) ? e.fileAttachments : [];
|