@smallwebco/tinypivot-mcp 0.2.4 → 0.2.5

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinypivot",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Interactive Data IDE inside Claude — turn CSV, TSV, JSON, JSONL, API/MCP outputs, and SQL results from any database into interactive charts, deterministic pivot tables, data grids, screenshot-ready terminal cards, and Excel exports.",
5
5
  "author": {
6
6
  "name": "Small Web, LLC",
@@ -8369,6 +8369,19 @@ function flattenRow(input) {
8369
8369
  }
8370
8370
  return out;
8371
8371
  }
8372
+ var DISTINCT_COUNT_CAP = 1e3;
8373
+ function collectDistinct(rows, name) {
8374
+ const distinct = /* @__PURE__ */ new Set();
8375
+ for (const row of rows) {
8376
+ const val = row[name];
8377
+ if (val === null || val === void 0 || val === "")
8378
+ continue;
8379
+ distinct.add(String(val));
8380
+ if (distinct.size >= DISTINCT_COUNT_CAP)
8381
+ break;
8382
+ }
8383
+ return distinct;
8384
+ }
8372
8385
  function inferColumns(rows) {
8373
8386
  if (rows.length === 0)
8374
8387
  return [];
@@ -8385,12 +8398,10 @@ function inferColumns(rows) {
8385
8398
  let boolCount = 0;
8386
8399
  let dateCount = 0;
8387
8400
  let strCount = 0;
8388
- const distinct = /* @__PURE__ */ new Set();
8389
8401
  for (let i = 0; i < sampleLimit; i++) {
8390
8402
  const val = rows[i][name];
8391
8403
  if (val === null || val === void 0 || val === "")
8392
8404
  continue;
8393
- distinct.add(String(val));
8394
8405
  if (typeof val === "number") {
8395
8406
  numCount++;
8396
8407
  } else if (typeof val === "boolean") {
@@ -8413,6 +8424,7 @@ function inferColumns(rows) {
8413
8424
  else
8414
8425
  type = "string";
8415
8426
  }
8427
+ const distinct = collectDistinct(rows, name);
8416
8428
  summaries.push({
8417
8429
  name,
8418
8430
  type,
@@ -9213,8 +9225,11 @@ function formatTerminalChart(dataset, chartConfig, options = {}) {
9213
9225
  const footerRight = `${dataset.rows.length.toLocaleString()} rows \xB7 ${chartKind}`;
9214
9226
  return wrapInCard(title, `Total ${formatCompactNumber(grandTotal)}`, body, footerLeft, footerRight, 66, { palette: pal, raw: options.raw });
9215
9227
  }
9228
+ function formatDistinctCount(count) {
9229
+ return count >= DISTINCT_COUNT_CAP ? `${DISTINCT_COUNT_CAP.toLocaleString("en-US")}+` : String(count);
9230
+ }
9216
9231
  function formatDatasetSummary(dataset, companionUrl, options = {}) {
9217
- const cols = dataset.columns.map((c) => `- \`${c.name}\` (${c.type}, ${c.distinctCount} distinct; e.g. ${c.sampleValues.slice(0, 3).join(", ")})`).join("\n");
9232
+ const cols = dataset.columns.map((c) => `- \`${c.name}\` (${c.type}, ${formatDistinctCount(c.distinctCount)} distinct; e.g. ${c.sampleValues.slice(0, 3).join(", ")})`).join("\n");
9218
9233
  const chartBlock = formatTerminalChart(dataset, dataset.chartConfig, {
9219
9234
  ...options,
9220
9235
  companionUrl: options.companionUrl ?? companionUrl
@@ -11170,7 +11185,7 @@ import fsSync2 from "fs";
11170
11185
  import os4 from "os";
11171
11186
  import path5 from "path";
11172
11187
  var DEFAULT_TELEMETRY_URL = "https://tiny-pivot.com/api/telemetry";
11173
- var PACKAGE_VERSION = "0.2.4";
11188
+ var PACKAGE_VERSION = "0.2.5";
11174
11189
  function isTelemetryEnabled() {
11175
11190
  if (process.env.TINYPIVOT_TELEMETRY === "0" || process.env.TINYPIVOT_TELEMETRY === "false")
11176
11191
  return false;
@@ -11438,7 +11453,7 @@ function createTinyPivotMcpServer(options = {}) {
11438
11453
  const server = new McpServer(
11439
11454
  {
11440
11455
  name: "tinypivot",
11441
- version: "0.2.4"
11456
+ version: "0.2.5"
11442
11457
  },
11443
11458
  {
11444
11459
  capabilities: {
@@ -11448,19 +11463,30 @@ function createTinyPivotMcpServer(options = {}) {
11448
11463
  instructions: TINYPIVOT_MCP_INSTRUCTIONS
11449
11464
  }
11450
11465
  );
11466
+ const clientRendersWidget = () => clientSupportsMcpAppsUi(server.server.getClientCapabilities());
11451
11467
  const resolveCompanionUrlForTool = async (forceCompanion = false) => {
11452
11468
  if (activeCompanionUrl)
11453
11469
  return activeCompanionUrl;
11454
11470
  if (!options.ensureCompanion)
11455
11471
  return void 0;
11456
- if (!forceCompanion && clientSupportsMcpAppsUi(server.server.getClientCapabilities()))
11472
+ if (!forceCompanion && clientRendersWidget())
11457
11473
  return void 0;
11458
11474
  activeCompanionUrl = await options.ensureCompanion();
11459
11475
  return activeCompanionUrl;
11460
11476
  };
11477
+ const dataToolResult = (summaryText, payload) => {
11478
+ const content = [{ type: "text", text: summaryText }];
11479
+ return clientRendersWidget() ? { content, structuredContent: payload } : { content };
11480
+ };
11481
+ const widgetOnlyTools = [];
11482
+ const widgetOnly = (tool) => {
11483
+ widgetOnlyTools.push(tool);
11484
+ };
11461
11485
  let detectedClientName;
11462
11486
  const getClientName = () => detectedClientName ?? server.server.getClientVersion()?.name;
11463
11487
  server.server.oninitialized = () => {
11488
+ if (!clientRendersWidget())
11489
+ widgetOnlyTools.forEach((tool) => tool.disable());
11464
11490
  detectedClientName = server.server.getClientVersion()?.name;
11465
11491
  recordTelemetry({
11466
11492
  event: "server_start",
@@ -11557,10 +11583,7 @@ function createTinyPivotMcpServer(options = {}) {
11557
11583
  truncated: ds.truncatedForFreeTier
11558
11584
  });
11559
11585
  notifyCompanion();
11560
- return {
11561
- content: [{ type: "text", text: summaryText }],
11562
- structuredContent: payload
11563
- };
11586
+ return dataToolResult(summaryText, payload);
11564
11587
  }
11565
11588
  );
11566
11589
  server.registerTool(
@@ -11613,10 +11636,7 @@ function createTinyPivotMcpServer(options = {}) {
11613
11636
  truncated: ds.truncatedForFreeTier
11614
11637
  });
11615
11638
  notifyCompanion();
11616
- return {
11617
- content: [{ type: "text", text: summaryText }],
11618
- structuredContent: payload
11619
- };
11639
+ return dataToolResult(summaryText, payload);
11620
11640
  } catch (err) {
11621
11641
  return {
11622
11642
  isError: true,
@@ -11670,10 +11690,7 @@ function createTinyPivotMcpServer(options = {}) {
11670
11690
  truncated: ds.truncatedForFreeTier
11671
11691
  });
11672
11692
  notifyCompanion();
11673
- return {
11674
- content: [{ type: "text", text: summaryText }],
11675
- structuredContent: payload
11676
- };
11693
+ return dataToolResult(summaryText, payload);
11677
11694
  }
11678
11695
  );
11679
11696
  server.registerTool(
@@ -11734,10 +11751,7 @@ function createTinyPivotMcpServer(options = {}) {
11734
11751
  truncated: ds.truncatedForFreeTier
11735
11752
  });
11736
11753
  notifyCompanion();
11737
- return {
11738
- content: [{ type: "text", text: summary }],
11739
- structuredContent: payload
11740
- };
11754
+ return dataToolResult(summary, payload);
11741
11755
  }
11742
11756
  );
11743
11757
  server.registerTool(
@@ -11808,10 +11822,7 @@ function createTinyPivotMcpServer(options = {}) {
11808
11822
  truncated: ds.truncatedForFreeTier
11809
11823
  });
11810
11824
  notifyCompanion();
11811
- return {
11812
- content: [{ type: "text", text: summaryText }],
11813
- structuredContent: payload
11814
- };
11825
+ return dataToolResult(summaryText, payload);
11815
11826
  }
11816
11827
  );
11817
11828
  server.registerTool(
@@ -11873,10 +11884,7 @@ function createTinyPivotMcpServer(options = {}) {
11873
11884
  truncated: ds.truncatedForFreeTier
11874
11885
  });
11875
11886
  notifyCompanion();
11876
- return {
11877
- content: [{ type: "text", text: summaryText }],
11878
- structuredContent: payload
11879
- };
11887
+ return dataToolResult(summaryText, payload);
11880
11888
  } catch (err) {
11881
11889
  return {
11882
11890
  isError: true,
@@ -11918,7 +11926,7 @@ function createTinyPivotMcpServer(options = {}) {
11918
11926
  };
11919
11927
  }
11920
11928
  );
11921
- server.registerTool(
11929
+ widgetOnly(server.registerTool(
11922
11930
  "fetch_dataset_rows",
11923
11931
  {
11924
11932
  title: "Fetch Dataset Rows (App Internal)",
@@ -11976,8 +11984,8 @@ function createTinyPivotMcpServer(options = {}) {
11976
11984
  }
11977
11985
  };
11978
11986
  }
11979
- );
11980
- server.registerTool(
11987
+ ));
11988
+ widgetOnly(server.registerTool(
11981
11989
  "set_session_model",
11982
11990
  {
11983
11991
  title: "Set Active LLM Model (App Internal)",
@@ -11996,8 +12004,8 @@ function createTinyPivotMcpServer(options = {}) {
11996
12004
  structuredContent: { session }
11997
12005
  };
11998
12006
  }
11999
- );
12000
- server.registerTool(
12007
+ ));
12008
+ widgetOnly(server.registerTool(
12001
12009
  "record_local_action",
12002
12010
  {
12003
12011
  title: "Record Local 0-Token Action (App Internal)",
@@ -12018,7 +12026,7 @@ function createTinyPivotMcpServer(options = {}) {
12018
12026
  }
12019
12027
  };
12020
12028
  }
12021
- );
12029
+ ));
12022
12030
  server.registerTool(
12023
12031
  "set_visual_theme",
12024
12032
  {
@@ -12046,7 +12054,7 @@ function createTinyPivotMcpServer(options = {}) {
12046
12054
  };
12047
12055
  }
12048
12056
  );
12049
- server.registerTool(
12057
+ widgetOnly(server.registerTool(
12050
12058
  "get_datasets_state",
12051
12059
  {
12052
12060
  title: "Get Datasets State (App Internal)",
@@ -12061,7 +12069,7 @@ function createTinyPivotMcpServer(options = {}) {
12061
12069
  datasets: store.listMetadata()
12062
12070
  }
12063
12071
  })
12064
- );
12072
+ ));
12065
12073
  return { server, store };
12066
12074
  }
12067
12075
 
package/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  runTuiCommand,
19
19
  saveVisualThemePreference,
20
20
  startCompanionServer
21
- } from "./chunk-7FMLMEMI.js";
21
+ } from "./chunk-25EEYMCA.js";
22
22
  import "./chunk-2ESYSVXG.js";
23
23
 
24
24
  // src/cli.ts
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  startCompanionServer,
30
30
  tokensToUsd,
31
31
  upsertTinyPivotRuleBlock
32
- } from "./chunk-7FMLMEMI.js";
32
+ } from "./chunk-25EEYMCA.js";
33
33
  import "./chunk-2ESYSVXG.js";
34
34
  export {
35
35
  APP_MIME_TYPE,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@smallwebco/tinypivot-mcp",
3
3
  "mcpName": "io.github.Small-Web-Co/tinypivot",
4
4
  "type": "module",
5
- "version": "0.2.4",
5
+ "version": "0.2.5",
6
6
  "description": "TinyPivot MCP Server, Interactive MCP App & Claude Plugin — turn CSV, JSON, API/MCP outputs, and queries from any database into interactive charts, pivot tables, terminal cards, live TUI, drill-through, and Excel exports inside AI agents.",
7
7
  "author": "Small Web, LLC",
8
8
  "license": "MIT",
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.Small-Web-Co/tinypivot",
4
4
  "title": "TinyPivot — Interactive Data IDE for AI Agents",
5
5
  "description": "Interactive charts, pivot tables, terminal cards, live TUI, and Excel export inside AI agents.",
6
- "version": "0.2.4",
6
+ "version": "0.2.5",
7
7
  "websiteUrl": "https://tiny-pivot.com",
8
8
  "repository": {
9
9
  "url": "https://github.com/Small-Web-Co/tinypivot",
@@ -14,7 +14,7 @@
14
14
  {
15
15
  "registryType": "npm",
16
16
  "identifier": "@smallwebco/tinypivot-mcp",
17
- "version": "0.2.4",
17
+ "version": "0.2.5",
18
18
  "transport": {
19
19
  "type": "stdio"
20
20
  },