formlab-mcp 0.6.78 → 0.6.80

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/cloud.js CHANGED
@@ -47,8 +47,15 @@ async function _fetchDb({ url, anonKey, token }) {
47
47
  }
48
48
  let body = null;
49
49
  try { body = await res.json(); } catch { /* non-JSON error page */ }
50
+ if (res.status === 429) {
51
+ const e = new Error('the MCP endpoint asks for a short wait between full reads');
52
+ e.tooSoon = true;
53
+ throw e;
54
+ }
50
55
  if (res.status === 401) {
51
- throw new Error('the MCP token was rejected: it is missing, revoked or malformed, or the workspace owner has turned off AI tools for members. Reconnect from FormLab → Settings → Account → AI tools (MCP) → Connect, and paste the new FORMLAB_MCP_TOKEN.');
56
+ const e = new Error('the MCP token was rejected: it is missing, revoked or malformed, or the workspace owner has turned off AI tools for members. Reconnect from FormLab → Settings → Account → AI tools (MCP) → Connect, and paste the new FORMLAB_MCP_TOKEN.');
57
+ e.revoked = true;
58
+ throw e;
52
59
  }
53
60
  if (!res.ok || !body || body.ok !== true || !body.db) {
54
61
  throw new Error(`MCP endpoint error (HTTP ${res.status})${body && body.error ? ': ' + body.error : ''}`);
@@ -84,6 +91,8 @@ export async function startCloud({ url, anonKey, token, refreshSeconds = 300, on
84
91
  if (now() - loadedAt < maxAgeMs) return false;
85
92
  if (!inflight) {
86
93
  inflight = refresh().then(() => true, (e) => {
94
+ // Token ended (revoked, expired, the person left): the copy goes too, so nothing keeps answering from it.
95
+ if (e && e.revoked) { setStoreFromDb({}, { source: 'cloud', workspaceId, schemaName: 'formlab-live', loadedAt: new Date(now()).toISOString() }); loadedAt = now(); }
87
96
  process.stderr.write(`[formlab-mcp] cloud refresh failed, answering from the copy loaded ${Math.round((now() - loadedAt) / 1000)} s ago: ${e.message}\n`);
88
97
  return false;
89
98
  }).finally(() => { inflight = null; });
@@ -91,6 +100,8 @@ export async function startCloud({ url, anonKey, token, refreshSeconds = 300, on
91
100
  return inflight;
92
101
  };
93
102
 
94
- await refresh(); // initial load before tools accept calls (and an early, clear error for a bad token)
103
+ // A second copy started moments ago (Claude Desktop and Code): the endpoint asks for a short wait, once.
104
+ try { await refresh(); } catch (e) { if (!e.tooSoon) throw e; await new Promise((r) => setTimeout(r, 11000)); await refresh(); }
105
+ // initial load before tools accept calls (and an early, clear error for a bad token)
95
106
  return { workspaceId, refresh, ensureFresh, stop: () => {} };
96
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formlab-mcp",
3
- "version": "0.6.78",
3
+ "version": "0.6.80",
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.78",
5
+ "version": "0.6.80",
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.78",
11
+ "version": "0.6.80",
12
12
  "runtimeHint": "npx",
13
13
  "transport": {
14
14
  "type": "stdio"
@@ -685,6 +685,11 @@ function _mcpFlattenReadings(tests, indexes, paramFilter) {
685
685
  if (!parameter) continue;
686
686
  if (paramFilter && !norm(parameter).includes(norm(paramFilter))) continue;
687
687
  const type = _mcpMeasType(m);
688
+ // A reading left blank is not a reading (the app's _taBlankReading, 54e):
689
+ // kept, a blank in the newest report showed as an empty latest cell.
690
+ if (type === 'time_series' ? !(Array.isArray(m.points) && m.points.length)
691
+ : type === 'distribution' ? !(Array.isArray(m.bins) && m.bins.length)
692
+ : String(m.value == null ? '' : m.value).trim() === '') continue;
688
693
  const row = { test: t, sample: samp, formulation, parameter, numeric: _mcpRepNumber(m), value: m.value, unit: m.unit || '', pf: _evalPassFail(m, t.templateId), m,
689
694
  type, rank: type === 'ordinal' ? _mcpRepNumber(m, { ordinal: 'rank' }) : null };
690
695
  const key = (t.id || t.uid) + '|' + parameter + '|' + _mcpCondSig(m);