@smallwebco/tinypivot-mcp 0.2.9 → 0.2.10

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.9",
3
+ "version": "0.2.10",
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",
package/README.md CHANGED
@@ -128,11 +128,12 @@ Unlock Pro or Team at [tiny-pivot.com/pricing](https://tiny-pivot.com/pricing).
128
128
  ## Environment Variables (Optional)
129
129
 
130
130
  - `TINYPIVOT_LICENSE_KEY` — TinyPivot MCP Pro/Team license key (`TP-MCPP-...` or `TP-MCPT-...`; note that UI Library `TP-PRO*` keys apply to `@smallwebco/tinypivot-react`/`-vue` only)
131
- - `DATABASE_URL` — Optional PostgreSQL connection string for direct read-only `query_postgres` (Pro). Works with **any** database (BigQuery, Snowflake, MySQL, DuckDB, Databricks, SQLite, Postgres) today via CLI/file handoff (`load_file`), stdin pipe, or MCP piping (`load_data`)
131
+ - `DATABASE_URL` — Optional PostgreSQL connection string for direct read-only `query_postgres` (Pro). The tool is only offered to the model when this is set. Works with **any** database (BigQuery, Snowflake, MySQL, DuckDB, Databricks, SQLite, Postgres) today via CLI/file handoff (`load_file`), stdin pipe, or MCP piping (`load_data`)
132
132
  - `TINYPIVOT_ALLOWED_TABLES` — Comma-separated table allowlist for `query_postgres`
133
133
  - `TINYPIVOT_TELEMETRY=0` or `DO_NOT_TRACK=1` — Disable anonymous usage telemetry
134
134
  - `TINYPIVOT_NO_COMPANION=1` — Disable the localhost Companion Data IDE server
135
135
  - `TINYPIVOT_PORT` — Fixed localhost port for the Companion Data IDE server
136
+ - `TINYPIVOT_REPRINT_CARDS` — Set to `0` so the model does not reprint each chart card in a terminal. Saves about 400 output tokens per question; the card stays visible in the Data IDE, the `tui` pane and pi.
136
137
 
137
138
  ## Privacy & Telemetry
138
139
 
@@ -9391,19 +9391,26 @@ function pivotTableCard(dataset, options) {
9391
9391
  function formatDistinctCount(count) {
9392
9392
  return count >= DISTINCT_COUNT_CAP ? `${DISTINCT_COUNT_CAP.toLocaleString("en-US")}+` : String(count);
9393
9393
  }
9394
+ var LISTED_VALUES_MAX = 5;
9395
+ function formatColumnNotes(columns) {
9396
+ const notes = columns.map((column) => {
9397
+ const values = column.distinctCount <= LISTED_VALUES_MAX ? `: ${column.sampleValues.join(", ")}` : ` (${formatDistinctCount(column.distinctCount)} values)`;
9398
+ return `\`${column.name}\` ${column.type}${values}`;
9399
+ });
9400
+ return `Columns: ${notes.join(" \xB7 ") || "none"}`;
9401
+ }
9402
+ var REPRINT_NOTE = "Show the card above to the user verbatim.";
9394
9403
  function formatDatasetSummary(dataset, companionUrl, options = {}) {
9395
- const cols = dataset.columns.map((c) => `- \`${c.name}\` (${c.type}, ${formatDistinctCount(c.distinctCount)} distinct; e.g. ${c.sampleValues.slice(0, 3).join(", ")})`).join("\n");
9396
9404
  const cardOptions = { ...options, companionUrl: options.companionUrl ?? companionUrl };
9397
9405
  const chartBlock = pivotTableCard(dataset, cardOptions) ?? formatTerminalChart(dataset, dataset.chartConfig, cardOptions);
9398
9406
  const rowHeadline = dataset.truncatedForFreeTier ? `**${dataset.rows.length.toLocaleString()} of ${dataset.sourceTotalRows.toLocaleString()} rows (Free tier limit)**` : `**${dataset.rows.length.toLocaleString()} rows**`;
9399
9407
  const parts = [
9400
- `Loaded dataset **${dataset.name}** (\`${dataset.id}\`) \u2014 ${rowHeadline}, ${dataset.columns.length} columns.`,
9401
- `Source: ${dataset.source}`
9408
+ `Loaded **${dataset.name}** (\`${dataset.id}\`): ${rowHeadline}, ${dataset.columns.length} columns.`
9402
9409
  ];
9403
9410
  if (dataset.truncatedForFreeTier) {
9404
9411
  parts.push(
9405
9412
  "",
9406
- `> **Notice (Free tier row limit):** Showing the first **${dataset.rows.length.toLocaleString()} of ${dataset.sourceTotalRows.toLocaleString()} rows**. Charts, pivots, and totals reflect this ${dataset.rows.length.toLocaleString()}-row subset only. Set \`TINYPIVOT_LICENSE_KEY\` for full unlimited rows: https://tiny-pivot.com/pricing`
9413
+ `> **Free tier:** showing the first ${dataset.rows.length.toLocaleString()} of ${dataset.sourceTotalRows.toLocaleString()} rows, so totals cover only those. A license key unlocks every row: https://tiny-pivot.com/pricing`
9407
9414
  );
9408
9415
  }
9409
9416
  const integrityWarning = detectNonAdditiveSumWarning(dataset, dataset.chartConfig);
@@ -9411,18 +9418,13 @@ function formatDatasetSummary(dataset, companionUrl, options = {}) {
9411
9418
  parts.push("", integrityWarning);
9412
9419
  }
9413
9420
  if (chartBlock) {
9414
- const echoNote = companionUrl ? '> **ACTION REQUIRED (Terminal Host \u2014 No Inline GUI):** The user cannot see this chart unless you include the fenced `text` TinyPivot card above **verbatim** in your reply along with the Interactive Data IDE link below. Do not say "it is open in TinyPivot" without printing the card.' : "_Display the fenced TinyPivot card above verbatim when replying in a terminal harness._";
9415
- parts.push(
9416
- "",
9417
- chartBlock,
9418
- "",
9419
- echoNote
9420
- );
9421
- }
9422
- parts.push("", "Columns:", cols || "(no columns)");
9423
- if (companionUrl) {
9424
- parts.push("", `Interactive Data IDE (live-updating): ${companionUrl}`);
9421
+ parts.push("", chartBlock);
9422
+ if (companionUrl && options.reprintNote !== false)
9423
+ parts.push(REPRINT_NOTE);
9425
9424
  }
9425
+ parts.push("", formatColumnNotes(dataset.columns));
9426
+ if (companionUrl && !chartBlock)
9427
+ parts.push(`Data IDE: ${companionUrl}`);
9426
9428
  return parts.join("\n");
9427
9429
  }
9428
9430
  function formatPivotSummary(dataset, config, companionUrl, options = {}) {
@@ -9540,20 +9542,9 @@ function formatPivotSummary(dataset, config, companionUrl, options = {}) {
9540
9542
  tableLines.push("```");
9541
9543
  }
9542
9544
  const headline = dataset.truncatedForFreeTier ? `Pivot on **${dataset.name}** (**first ${dataset.rows.length.toLocaleString()} of ${dataset.sourceTotalRows.toLocaleString()} rows \u2014 Free tier subset**):` : `Pivot on **${dataset.name}** (${dataset.rows.length.toLocaleString()} source rows):`;
9543
- const echoNote = companionUrl ? '> **ACTION REQUIRED (Terminal Host \u2014 No Inline GUI):** The user cannot see this pivot table unless you include the fenced `text` TinyPivot card above **verbatim** in your reply along with the Interactive Data IDE link below. Do not say "it is open in TinyPivot" without printing the card.' : "_Display the fenced TinyPivot table above verbatim when replying in a terminal harness._";
9544
- const out = [
9545
- headline,
9546
- "",
9547
- tableLines.join("\n"),
9548
- "",
9549
- echoNote
9550
- ];
9551
- if (result.rowHeaders.length > maxRows) {
9552
- out.push(`_\u2026and ${result.rowHeaders.length - maxRows} more rows visible interactively in TinyPivot._`);
9553
- }
9554
- if (companionUrl) {
9555
- out.push("", `Interactive Data IDE (live-updating): ${companionUrl}`);
9556
- }
9545
+ const out = [headline, "", tableLines.join("\n")];
9546
+ if (companionUrl && options.reprintNote !== false)
9547
+ out.push(REPRINT_NOTE);
9557
9548
  return out.join("\n");
9558
9549
  }
9559
9550
 
@@ -10551,17 +10542,15 @@ var RULE_START = "<!-- tinypivot:start -->";
10551
10542
  var RULE_END = "<!-- tinypivot:end -->";
10552
10543
  var RULE_TEST_RE = /<!-- tinypivot(?:-mcp)?:start -->[\s\S]*?<!-- tinypivot(?:-mcp)?:end -->/;
10553
10544
  var RULE_REPLACE_RE = /<!-- tinypivot(?:-mcp)?:start -->[\s\S]*?<!-- tinypivot(?:-mcp)?:end -->/g;
10545
+ var RULE_HEADING = "## Charts & pivot tables (TinyPivot MCP)";
10546
+ var RULE_USE = "Use the `tinypivot` MCP server for charts, pivot tables and data exploration instead of drawing them yourself.";
10554
10547
  var TINYPIVOT_CLAUDE_RULE_BLOCK = `${RULE_START}
10555
- ## Default Charts & Pivot Tables (TinyPivot MCP)
10556
- Whenever the user asks for a chart (line, bar, stacked bar, area, pie, scatter), a YoY/MoM comparison, a pivot table, or interactive tabular data exploration, ALWAYS use \`tinypivot\` (\`load_data\` for in-memory rows or \`load_file\` for CSV/TSV/JSON files, passing \`chartConfig\` or \`pivotConfig\` in a single call) INSTEAD of built-in visualization widgets, HTML/SVG/Chart.js/Recharts artifacts, matplotlib scripts, or large Markdown tables. Do not create temp CSVs for <500 in-memory rows.
10557
- TinyPivot is a deterministic presentation & additive-rollup layer: for non-additive shares, rates, margins, or ratios over time (e.g. monthly share %, conversion rate, YoY %), pre-compute exact \`numerator / denominator\` ratios at the target chart grain (1 row per X \xD7 series) in SQL/Python before passing rows to TinyPivot\u2014never sum \`%\` columns across sub-segments and never use \`percentOfTotal\` for within-period share. Pass \`keepExisting: true\` only when comparing multiple datasets in the SAME conversation; use \`clear_datasets\` to reset.
10558
- In terminal harnesses (pi, Claude Code, OpenCode, Codex CLI), there is NO inline GUI widget: ALWAYS include the returned fenced \`text\` TinyPivot chart/table card verbatim AND the localhost Companion IDE URL in your VERY FIRST reply\u2014never say "it is open in TinyPivot" without printing the card.
10548
+ ${RULE_HEADING}
10549
+ ${RULE_USE} In a terminal, show its \`text\` card verbatim with the Data IDE link.
10559
10550
  ${RULE_END}`;
10560
10551
  var TINYPIVOT_PI_RULE_BLOCK = `${RULE_START}
10561
- ## Default Charts & Pivot Tables (TinyPivot MCP)
10562
- Whenever the user asks for a chart (line, bar, stacked bar, area, pie, scatter), a YoY/MoM comparison, a pivot table, or interactive tabular data exploration, ALWAYS use \`tinypivot\` (\`load_data\` for in-memory rows or \`load_file\` for CSV/TSV/JSON files, passing \`chartConfig\` or \`pivotConfig\` in a single call) INSTEAD of built-in visualization widgets, HTML/SVG/Chart.js/Recharts artifacts, matplotlib scripts, or large Markdown tables. Do not create temp CSVs for <500 in-memory rows.
10563
- TinyPivot is a deterministic presentation & additive-rollup layer: for non-additive shares, rates, margins, or ratios over time (e.g. monthly share %, conversion rate, YoY %), pre-compute exact \`numerator / denominator\` ratios at the target chart grain (1 row per X \xD7 series) in SQL/Python before passing rows to TinyPivot\u2014never sum \`%\` columns across sub-segments and never use \`percentOfTotal\` for within-period share. Pass \`keepExisting: true\` only when comparing multiple datasets in the SAME conversation; use \`clear_datasets\` to reset.
10564
- The TinyPivot pi extension automatically renders every TinyPivot chart/pivot card in full 24-bit color right in the terminal UI after the tool call\u2014follow up with 2\u20133 concise analytical takeaways and the live Companion IDE URL (no need to repeat a plain monochrome ASCII box unless the user asks). Users can switch themes anytime with \`/tinypivot-theme\` or \`set_visual_theme\`.
10552
+ ${RULE_HEADING}
10553
+ ${RULE_USE} The TinyPivot pi extension already shows each card, so reply with the takeaways and the Data IDE link. \`/tinypivot-theme\` switches themes.
10565
10554
  ${RULE_END}`;
10566
10555
  function upsertTinyPivotRuleBlock(existing, block = TINYPIVOT_CLAUDE_RULE_BLOCK) {
10567
10556
  if (RULE_TEST_RE.test(existing)) {
@@ -11367,7 +11356,7 @@ import fsSync2 from "fs";
11367
11356
  import os4 from "os";
11368
11357
  import path5 from "path";
11369
11358
  var DEFAULT_TELEMETRY_URL = "https://tiny-pivot.com/api/telemetry";
11370
- var PACKAGE_VERSION = "0.2.9";
11359
+ var PACKAGE_VERSION = "0.2.10";
11371
11360
  function isTelemetryEnabled() {
11372
11361
  if (process.env.TINYPIVOT_TELEMETRY === "0" || process.env.TINYPIVOT_TELEMETRY === "false")
11373
11362
  return false;
@@ -11445,14 +11434,18 @@ function recordTelemetry(ev) {
11445
11434
  // src/server.ts
11446
11435
  var APP_RESOURCE_URI = "ui://tinypivot/app.html";
11447
11436
  var APP_MIME_TYPE = "text/html;profile=mcp-app";
11448
- var TINYPIVOT_MCP_INSTRUCTIONS = [
11449
- "TinyPivot is the user's preferred default chart, pivot table, and interactive data exploration renderer.",
11450
- "Whenever the user asks for a chart (line, bar, stacked bar, area, pie, donut, scatter, bubble, heatmap, radar), a YoY/MoM/period comparison, a pivot table, or interactive tabular exploration, ALWAYS use TinyPivot (`load_data` for in-memory rows or `load_file` for local CSV/TSV/JSON/JSONL files, passing `chartConfig` or `pivotConfig` in a single call) INSTEAD of built-in visualization widgets, HTML/SVG/Chart.js/Recharts artifacts, matplotlib/Python scripts, or large Markdown tables.",
11451
- "TinyPivot is a deterministic presentation & additive-rollup layer (`sum`/`count`/`avg`/`min`/`max`). For non-additive ratios, shares, rates, or margins over time (e.g. monthly TRx share %, conversion rate, margin %, YoY %), you MUST pre-compute exact `numerator / denominator` ratios at the target chart grain (1 row per X \xD7 series) in SQL or Python BEFORE passing rows to TinyPivot \u2014 never sum percentage columns across sub-segments and never use `percentOfTotal` for within-period share.",
11452
- "Do not write throwaway temp CSV files when you already have <500 rows in memory \u2014 call `load_data` directly. Pass `keepExisting: true` only when loading an additional dataset to compare in the SAME conversation; call `clear_datasets` to reset.",
11453
- 'CRITICAL FOR TERMINAL HARNESSES (pi, Claude Code, OpenCode, Codex CLI): When TinyPivot returns a fenced `text` chart or pivot card alongside an Interactive Data IDE URL, this host has NO inline GUI widget. You MUST include that fenced `text` card verbatim AND the Interactive Data IDE link in your VERY FIRST response \u2014 never claim "it is open in TinyPivot" without printing the card.',
11454
- "To change the active visual theme when the user asks, call `set_visual_theme`."
11455
- ].join(" ");
11437
+ var LOAD_DATA_ROW_GUIDE = 50;
11438
+ function buildInstructions({ reprintCards = true } = {}) {
11439
+ const cards = reprintCards ? "In a terminal, show the returned ```text card verbatim with the Data IDE link in your reply, except in pi, whose TinyPivot extension already displays it." : "Do not reprint the ```text card: the user sees it in TinyPivot. Reply with the takeaways and the Data IDE link.";
11440
+ return [
11441
+ "Use TinyPivot for charts, pivot tables, period comparisons and tabular exploration instead of drawing them yourself (HTML, SVG, matplotlib, Markdown tables), passing chartConfig or pivotConfig in the same call.",
11442
+ `For files use load_file, so the rows stay out of your context. Use load_data only for rows you already have, up to about ${LOAD_DATA_ROW_GUIDE}; write larger sets to a file first.`,
11443
+ "Totals are exact. Compute ratios, shares and rates as numerator / denominator, one row per chart point, before loading; never add up percentage columns, and do not use percentOfTotal for a share within a period.",
11444
+ "Use keepExisting: true only to compare datasets in one conversation; clear_datasets resets.",
11445
+ cards
11446
+ ].join(" ");
11447
+ }
11448
+ var TINYPIVOT_MCP_INSTRUCTIONS = buildInstructions();
11456
11449
  var INLINE_PREVIEW_ROW_LIMIT = 200;
11457
11450
  var AGGREGATION_VALUES = [
11458
11451
  "sum",
@@ -11480,28 +11473,27 @@ var CHART_TYPE_VALUES = [
11480
11473
  var CHART_AGG_VALUES = ["sum", "avg", "count", "min", "max"];
11481
11474
  var VIEW_MODE_VALUES = ["grid", "pivot", "chart"];
11482
11475
  var VISUAL_THEME_VALUES = CHART_THEME_IDS;
11483
- var VISUAL_THEME_LIST = CHART_THEME_IDS.join(", ");
11484
11476
  var pivotValueSchema = z.object({
11485
- field: z.string().describe("Numeric or countable column name to aggregate"),
11477
+ field: z.string(),
11486
11478
  aggregation: z.enum(AGGREGATION_VALUES).default("sum")
11487
11479
  });
11488
11480
  var rowFilterSchema = z.object({
11489
- field: z.string().describe("Column to filter on"),
11490
- equals: z.array(z.union([z.string(), z.number(), z.boolean()])).min(1).describe("Keep rows whose value is any of these")
11481
+ field: z.string(),
11482
+ equals: z.array(z.union([z.string(), z.number(), z.boolean()])).min(1).describe("Keep rows matching any of these")
11491
11483
  });
11492
11484
  var pivotConfigSchema = z.object({
11493
- rowFields: z.array(z.string()).default([]).describe("Columns to group as pivot rows"),
11494
- columnFields: z.array(z.string()).default([]).describe("Columns to spread across pivot columns"),
11495
- valueFields: z.array(pivotValueSchema).default([]).describe("Values and aggregations to compute"),
11485
+ rowFields: z.array(z.string()).default([]),
11486
+ columnFields: z.array(z.string()).default([]),
11487
+ valueFields: z.array(pivotValueSchema).default([]),
11496
11488
  showRowTotals: z.boolean().default(true),
11497
11489
  showColumnTotals: z.boolean().default(true)
11498
11490
  });
11499
11491
  var chartConfigSchema = z.object({
11500
11492
  type: z.enum(CHART_TYPE_VALUES).default("bar"),
11501
- xAxisField: z.string().describe("Dimension or temporal column for X-axis / slices"),
11502
- yAxisField: z.string().describe("Numeric measure column for Y-axis / values"),
11503
- aggregation: z.enum(CHART_AGG_VALUES).default("sum").describe("Aggregation for Y-axis values"),
11504
- seriesField: z.string().optional().describe("Optional grouping / stacking dimension column"),
11493
+ xAxisField: z.string().describe("Category or date column"),
11494
+ yAxisField: z.string().describe("Column to aggregate"),
11495
+ aggregation: z.enum(CHART_AGG_VALUES).default("sum"),
11496
+ seriesField: z.string().optional().describe("Column to split into series"),
11505
11497
  title: z.string().optional()
11506
11498
  });
11507
11499
  function extractSessionKey(extra) {
@@ -11555,7 +11547,7 @@ function buildAppPayload(dataset, store, options) {
11555
11547
  const summaryTokens = Math.round(summaryBytes / 4);
11556
11548
  const defaultTurnBypass = dataset.ingestionMode === "direct" ? Math.max(0, dataset.estimatedDatasetTokens - summaryTokens) : 0;
11557
11549
  const turnTokensSaved = options.overrideTurnTokensSaved ?? defaultTurnBypass;
11558
- const sessionSavings = options.recordTurn !== false ? store.recordTurnSavings(turnTokensSaved, options.model) : options.model ? (store.setActiveModel(options.model), store.getSessionSavings()) : store.getSessionSavings();
11550
+ const sessionSavings = options.recordTurn !== false ? store.recordTurnSavings(turnTokensSaved) : store.getSessionSavings();
11559
11551
  const turnUsdSaved = tokensToUsd(turnTokensSaved, sessionSavings.model.ratePerMillion);
11560
11552
  const validMcpKey = isMcpLicenseKey(options.licenseKey) ? options.licenseKey : null;
11561
11553
  const isPro2 = Boolean(validMcpKey || options.demoToken);
@@ -11652,6 +11644,8 @@ function createTinyPivotMcpServer(options = {}) {
11652
11644
  const notifyCompanion = () => {
11653
11645
  options.onStateChanged?.();
11654
11646
  };
11647
+ const reprintCards = options.reprintCards ?? process.env.TINYPIVOT_REPRINT_CARDS !== "0";
11648
+ const cardFormat = { showBranding: !isPro2, reprintNote: reprintCards };
11655
11649
  const postgresConfig = options.postgres ?? (process.env.DATABASE_URL ? {
11656
11650
  connectionString: process.env.DATABASE_URL,
11657
11651
  allowedTables: process.env.TINYPIVOT_ALLOWED_TABLES ? process.env.TINYPIVOT_ALLOWED_TABLES.split(",").map((s) => s.trim()).filter(Boolean) : void 0
@@ -11659,14 +11653,14 @@ function createTinyPivotMcpServer(options = {}) {
11659
11653
  const server = new McpServer(
11660
11654
  {
11661
11655
  name: "tinypivot",
11662
- version: "0.2.9"
11656
+ version: "0.2.10"
11663
11657
  },
11664
11658
  {
11665
11659
  capabilities: {
11666
11660
  resources: {},
11667
11661
  tools: {}
11668
11662
  },
11669
- instructions: TINYPIVOT_MCP_INSTRUCTIONS
11663
+ instructions: buildInstructions({ reprintCards })
11670
11664
  }
11671
11665
  );
11672
11666
  const clientRendersWidget = () => clientSupportsMcpAppsUi(server.server.getClientCapabilities());
@@ -11770,16 +11764,15 @@ function createTinyPivotMcpServer(options = {}) {
11770
11764
  "open_tinypivot",
11771
11765
  {
11772
11766
  title: "Open TinyPivot",
11773
- description: "Open the interactive TinyPivot data grid, pivot table, and chart explorer. All arguments are optional; pass `model` with your active LLM name to accurately dollarize token savings.",
11767
+ description: "Open the TinyPivot Data IDE (grid, pivot, chart). Shows sample data when nothing is loaded.",
11774
11768
  inputSchema: {
11775
- datasetId: z.string().optional().describe("ID of an already-loaded dataset to display"),
11776
- viewMode: z.enum(VIEW_MODE_VALUES).optional().describe("Initial view mode: grid, pivot, or chart"),
11777
- model: z.string().optional().describe('Active LLM model name (e.g. "Gemini 4 Neon", "Claude Opus 5.5", "GPT-5") for dollarized savings'),
11778
- openBrowser: z.boolean().optional().describe("Set true to explicitly start the localhost Companion Data IDE URL even inside MCP Apps-capable hosts")
11769
+ datasetId: z.string().optional(),
11770
+ viewMode: z.enum(VIEW_MODE_VALUES).optional(),
11771
+ openBrowser: z.boolean().optional().describe("Also start the localhost Data IDE in hosts with an inline widget")
11779
11772
  },
11780
11773
  _meta: PANE_UI_META
11781
11774
  },
11782
- async ({ datasetId, viewMode, model, openBrowser }, extra) => {
11775
+ async ({ datasetId, viewMode, openBrowser }, extra) => {
11783
11776
  const sessionKey = extractSessionKey(extra) ?? DEFAULT_SESSION_KEY;
11784
11777
  const ds = store.get(datasetId, sessionKey);
11785
11778
  if (!ds) {
@@ -11794,8 +11787,8 @@ function createTinyPivotMcpServer(options = {}) {
11794
11787
  store.setActive(ds.id, sessionKey);
11795
11788
  }
11796
11789
  const liveCompanionUrl = await resolveCompanionUrlForTool(Boolean(openBrowser));
11797
- const summaryText = formatDatasetSummary(ds, liveCompanionUrl, { showBranding: !isPro2 });
11798
- const payload = buildAppPayload(ds, store, { licenseKey, demoToken, summaryText, model, sessionKey });
11790
+ const summaryText = formatDatasetSummary(ds, liveCompanionUrl, cardFormat);
11791
+ const payload = buildAppPayload(ds, store, { licenseKey, demoToken, summaryText, sessionKey });
11799
11792
  recordTelemetry({
11800
11793
  event: "tool_call",
11801
11794
  tool: "open_tinypivot",
@@ -11812,20 +11805,19 @@ function createTinyPivotMcpServer(options = {}) {
11812
11805
  "load_file",
11813
11806
  {
11814
11807
  title: "Load Data File into TinyPivot",
11815
- description: "Preferred default chart & pivot renderer for local CSV, TSV, JSON, or JSONL files \u2014 use instead of built-in visualization/artifact widgets, HTML/SVG/Chart.js/Recharts artifacts, matplotlib scripts, or large Markdown tables. Deterministic presentation & additive-rollup layer (sum/count/avg/min/max): for non-additive ratios/shares/rates/margins over time (e.g. monthly TRx share %, conversion rate, margin %), pre-compute exact numerator/denominator ratios at chart grain (1 row per X \xD7 series) in SQL/Python before loading \u2014 never sum percentage columns across sub-segments and never use percentOfTotal for within-period share. Loads data with 0 raw rows entering LLM context; pass chartConfig or pivotConfig to render in 1 call, and pass keepExisting: true only when comparing multiple datasets in the same conversation.",
11808
+ description: "Chart or pivot a local CSV, TSV, JSON or JSONL file without reading it: the rows stay out of your context.",
11816
11809
  inputSchema: {
11817
- filePath: z.string().describe("Absolute or relative path to a .csv, .tsv, .json, or .jsonl file"),
11818
- name: z.string().optional().describe("Optional display name for the dataset"),
11819
- where: z.array(rowFilterSchema).optional().describe('Keep only rows that match every filter, e.g. [{"field":"year","equals":[2026]},{"field":"channel","equals":["Partner"]}]. Use this to chart or pivot one segment or period. Filtering runs on disk, so the rows still never enter context.'),
11820
- viewMode: z.enum(VIEW_MODE_VALUES).optional().describe("Initial view mode (default: chart)"),
11821
- pivotConfig: pivotConfigSchema.optional().describe("Optional initial pivot configuration (also derives a matching chart if chartConfig is omitted)"),
11822
- chartConfig: chartConfigSchema.optional().describe("Optional explicit chart configuration (lets you load + configure a specific chart type in one single call)"),
11823
- model: z.string().optional().describe("Active LLM model name for dollarized token savings"),
11824
- keepExisting: z.boolean().optional().describe("Set true to keep previously loaded datasets in this chat switcher (for multi-dataset comparisons in the same conversation). Omit to start clean on shared hosts.")
11810
+ filePath: z.string(),
11811
+ name: z.string().optional(),
11812
+ where: z.array(rowFilterSchema).optional().describe('Keep only matching rows, e.g. [{"field":"year","equals":[2026]}]'),
11813
+ viewMode: z.enum(VIEW_MODE_VALUES).optional(),
11814
+ pivotConfig: pivotConfigSchema.optional(),
11815
+ chartConfig: chartConfigSchema.optional(),
11816
+ keepExisting: z.boolean().optional().describe("Keep earlier datasets loaded, to compare them")
11825
11817
  },
11826
11818
  _meta: INLINE_UI_META
11827
11819
  },
11828
- async ({ filePath, name, where, viewMode, pivotConfig, chartConfig, model, keepExisting }, extra) => {
11820
+ async ({ filePath, name, where, viewMode, pivotConfig, chartConfig, keepExisting }, extra) => {
11829
11821
  try {
11830
11822
  const { sessionKey, keepExisting: shouldKeep } = resolveSessionContext(extra, keepExisting);
11831
11823
  const ds = await store.loadFromFile(filePath, name, { sessionKey, keepExisting: shouldKeep, where });
@@ -11850,8 +11842,8 @@ function createTinyPivotMcpServer(options = {}) {
11850
11842
  }, sessionKey);
11851
11843
  }
11852
11844
  const liveCompanionUrl = await resolveCompanionUrlForTool();
11853
- const summaryText = formatDatasetSummary(ds, liveCompanionUrl, { showBranding: !isPro2 });
11854
- const payload = buildAppPayload(ds, store, { licenseKey, demoToken, summaryText, model, sessionKey });
11845
+ const summaryText = formatDatasetSummary(ds, liveCompanionUrl, cardFormat);
11846
+ const payload = buildAppPayload(ds, store, { licenseKey, demoToken, summaryText, sessionKey });
11855
11847
  recordTelemetry({
11856
11848
  event: "tool_call",
11857
11849
  tool: "load_file",
@@ -11874,20 +11866,19 @@ function createTinyPivotMcpServer(options = {}) {
11874
11866
  "load_data",
11875
11867
  {
11876
11868
  title: "Load JSON Rows into TinyPivot",
11877
- description: "Preferred default chart & pivot renderer for in-memory JSON rows \u2014 use instead of built-in visualization/artifact widgets, HTML/SVG/Chart.js/Recharts artifacts, matplotlib scripts, or large Markdown tables whenever the user asks for a chart (line, bar, stacked bar, area, pie, scatter), YoY/MoM comparison, or pivot table. Deterministic presentation & additive-rollup layer (sum/count/avg/min/max): for non-additive ratios/shares/rates/margins over time (e.g. monthly TRx share %, conversion rate, margin %, YoY %), pre-compute exact numerator/denominator ratios at chart grain (1 row per X \xD7 series) in SQL/Python BEFORE passing rows \u2014 never sum percentage columns across sub-segments and never use percentOfTotal for within-period share. Pass chartConfig or pivotConfig to render in 1 call; pass keepExisting: true only when comparing multiple datasets in the same conversation.",
11869
+ description: "Chart or pivot rows you already have, up to about 50. Every row you pass is billed as output; for more, write a file and use load_file.",
11878
11870
  inputSchema: {
11879
- name: z.string().describe('Human-readable name for the dataset (e.g. "Stripe Revenue Q3")'),
11880
- rows: z.array(z.record(z.string(), z.unknown())).describe("Array of flat row objects"),
11881
- source: z.string().optional().describe('Optional source label (e.g. "stripe-mcp", "api")'),
11882
- viewMode: z.enum(VIEW_MODE_VALUES).optional().describe("Initial view mode (default: chart)"),
11883
- pivotConfig: pivotConfigSchema.optional().describe("Pivot configuration for the dataset (also derives a matching chart if chartConfig is omitted)"),
11871
+ name: z.string(),
11872
+ rows: z.array(z.record(z.string(), z.unknown())),
11873
+ source: z.string().optional(),
11874
+ viewMode: z.enum(VIEW_MODE_VALUES).optional(),
11875
+ pivotConfig: pivotConfigSchema.optional(),
11884
11876
  chartConfig: chartConfigSchema.optional(),
11885
- model: z.string().optional().describe("Active LLM model name for dollarized token savings"),
11886
- keepExisting: z.boolean().optional().describe("Set true to keep previously loaded datasets in this chat switcher (for multi-dataset comparisons in the same conversation). Omit to start clean on shared hosts.")
11877
+ keepExisting: z.boolean().optional().describe("Keep earlier datasets loaded, to compare them")
11887
11878
  },
11888
11879
  _meta: INLINE_UI_META
11889
11880
  },
11890
- async ({ name, rows, source, viewMode, pivotConfig, chartConfig, model, keepExisting }, extra) => {
11881
+ async ({ name, rows, source, viewMode, pivotConfig, chartConfig, keepExisting }, extra) => {
11891
11882
  const { sessionKey, keepExisting: shouldKeep } = resolveSessionContext(extra, keepExisting);
11892
11883
  const normalizedPivot = pivotConfig ? {
11893
11884
  ...pivotConfig,
@@ -11908,8 +11899,8 @@ function createTinyPivotMcpServer(options = {}) {
11908
11899
  keepExisting: shouldKeep
11909
11900
  });
11910
11901
  const liveCompanionUrl = await resolveCompanionUrlForTool();
11911
- const summaryText = formatDatasetSummary(ds, liveCompanionUrl, { showBranding: !isPro2 });
11912
- const payload = buildAppPayload(ds, store, { licenseKey, demoToken, summaryText, model, sessionKey });
11902
+ const summaryText = formatDatasetSummary(ds, liveCompanionUrl, cardFormat);
11903
+ const payload = buildAppPayload(ds, store, { licenseKey, demoToken, summaryText, sessionKey });
11913
11904
  recordTelemetry({
11914
11905
  event: "tool_call",
11915
11906
  tool: "load_data",
@@ -11926,19 +11917,18 @@ function createTinyPivotMcpServer(options = {}) {
11926
11917
  "configure_pivot",
11927
11918
  {
11928
11919
  title: "Configure Pivot Table",
11929
- description: "Compute a deterministic pivot table on a loaded dataset using TinyPivot Core (additive rollups: sum/count/avg/min/max) and update the interactive UI in pivot mode. Note: percentOfTotal divides by the grand total across all cells \u2014 for within-period share/rate/margin ratios over time, pre-compute exact numerator/denominator ratios at the target grain in SQL/Python before loading.",
11920
+ description: "Pivot the active dataset. Aggregations are exact; percentOfTotal divides by the grand total.",
11930
11921
  inputSchema: {
11931
- datasetId: z.string().optional().describe("Dataset ID (defaults to active dataset)"),
11932
- rowFields: z.array(z.string()).default([]).describe("Columns for pivot rows"),
11933
- columnFields: z.array(z.string()).default([]).describe("Columns for pivot columns"),
11934
- valueFields: z.array(pivotValueSchema).min(1).describe("Value columns and aggregation functions"),
11922
+ datasetId: z.string().optional(),
11923
+ rowFields: z.array(z.string()).default([]),
11924
+ columnFields: z.array(z.string()).default([]),
11925
+ valueFields: z.array(pivotValueSchema).min(1),
11935
11926
  showRowTotals: z.boolean().default(true),
11936
- showColumnTotals: z.boolean().default(true),
11937
- model: z.string().optional().describe("Active LLM model name for dollarized token savings")
11927
+ showColumnTotals: z.boolean().default(true)
11938
11928
  },
11939
11929
  _meta: INLINE_UI_META
11940
11930
  },
11941
- async ({ datasetId, rowFields, columnFields, valueFields, showRowTotals, showColumnTotals, model }, extra) => {
11931
+ async ({ datasetId, rowFields, columnFields, valueFields, showRowTotals, showColumnTotals }, extra) => {
11942
11932
  const sessionKey = extractSessionKey(extra) ?? DEFAULT_SESSION_KEY;
11943
11933
  const ds = store.get(datasetId, sessionKey);
11944
11934
  if (!ds) {
@@ -11963,13 +11953,12 @@ function createTinyPivotMcpServer(options = {}) {
11963
11953
  chartConfig: chartConfigFromPivot(fullPivotConfig, ds.name) ?? ds.chartConfig
11964
11954
  }, sessionKey);
11965
11955
  const liveCompanionUrl = await resolveCompanionUrlForTool();
11966
- const summary = formatPivotSummary(ds, fullPivotConfig, liveCompanionUrl, { showBranding: !isPro2 });
11956
+ const summary = formatPivotSummary(ds, fullPivotConfig, liveCompanionUrl, cardFormat);
11967
11957
  const pivotTokensSaved = Math.max(0, ds.estimatedDatasetTokens - Math.round(Buffer.byteLength(summary, "utf8") / 4));
11968
11958
  const payload = buildAppPayload(ds, store, {
11969
11959
  licenseKey,
11970
11960
  demoToken,
11971
11961
  summaryText: summary,
11972
- model,
11973
11962
  overrideTurnTokensSaved: pivotTokensSaved,
11974
11963
  sessionKey
11975
11964
  });
@@ -11989,21 +11978,20 @@ function createTinyPivotMcpServer(options = {}) {
11989
11978
  "configure_chart",
11990
11979
  {
11991
11980
  title: "Configure Chart",
11992
- description: "Switch TinyPivot to Chart Builder mode with the requested chart type, X-axis dimension, Y-axis measure, aggregation (sum/avg/count/min/max), optional series grouping, and optional visual theme preset. For non-additive ratios/shares/rates/margins over time, rows must already be pre-aggregated to 1 row per X \xD7 series with exact numerator/denominator values \u2014 never sum percentage columns across sub-segments.",
11981
+ description: "Chart the active dataset.",
11993
11982
  inputSchema: {
11994
- datasetId: z.string().optional().describe("Dataset ID (defaults to active dataset)"),
11983
+ datasetId: z.string().optional(),
11995
11984
  type: z.enum(CHART_TYPE_VALUES).default("bar"),
11996
11985
  xAxisField: z.string(),
11997
11986
  yAxisField: z.string(),
11998
11987
  aggregation: z.enum(CHART_AGG_VALUES).default("sum"),
11999
11988
  seriesField: z.string().optional(),
12000
11989
  title: z.string().optional(),
12001
- chartTheme: z.enum(VISUAL_THEME_VALUES).optional().describe(`Optional visual theme (${VISUAL_THEME_LIST})`),
12002
- model: z.string().optional().describe("Active LLM model name for dollarized token savings")
11990
+ chartTheme: z.enum(VISUAL_THEME_VALUES).optional()
12003
11991
  },
12004
11992
  _meta: INLINE_UI_META
12005
11993
  },
12006
- async ({ datasetId, type, xAxisField, yAxisField, aggregation, seriesField, title, chartTheme, model }, extra) => {
11994
+ async ({ datasetId, type, xAxisField, yAxisField, aggregation, seriesField, title, chartTheme }, extra) => {
12007
11995
  const sessionKey = extractSessionKey(extra) ?? DEFAULT_SESSION_KEY;
12008
11996
  const ds = store.get(datasetId, sessionKey);
12009
11997
  if (!ds) {
@@ -12039,14 +12027,13 @@ function createTinyPivotMcpServer(options = {}) {
12039
12027
  if (asciiChart)
12040
12028
  summaryParts.push("", asciiChart);
12041
12029
  if (liveCompanionUrl)
12042
- summaryParts.push("", `Interactive Data IDE (live-updating): ${liveCompanionUrl}`);
12030
+ summaryParts.push(`Data IDE: ${liveCompanionUrl}`);
12043
12031
  const summaryText = summaryParts.join("\n");
12044
12032
  const chartTokensSaved = Math.max(0, ds.estimatedDatasetTokens - Math.round(Buffer.byteLength(summaryText, "utf8") / 4));
12045
12033
  const payload = buildAppPayload(ds, store, {
12046
12034
  licenseKey,
12047
12035
  demoToken,
12048
12036
  summaryText,
12049
- model,
12050
12037
  overrideTurnTokensSaved: chartTokensSaved,
12051
12038
  sessionKey
12052
12039
  });
@@ -12062,83 +12049,78 @@ function createTinyPivotMcpServer(options = {}) {
12062
12049
  return dataToolResult(summaryText, payload);
12063
12050
  }
12064
12051
  );
12065
- server.registerTool(
12066
- "query_postgres",
12067
- {
12068
- title: "Query PostgreSQL Directly (Read-Only, Pro)",
12069
- description: "Execute a direct read-only SELECT query against PostgreSQL (DATABASE_URL) with AST validation and stream rows straight into TinyPivot without creating temp CSV files. (For BigQuery, Snowflake, MySQL, DuckDB, or Databricks, run your SQL CLI to a temp file and pass it to load_file, or pipe rows via load_data.)",
12070
- inputSchema: {
12071
- sql: z.string().describe("Read-only PostgreSQL SELECT query"),
12072
- name: z.string().optional().describe("Display name for the query result dataset"),
12073
- viewMode: z.enum(VIEW_MODE_VALUES).optional(),
12074
- pivotConfig: pivotConfigSchema.optional(),
12075
- model: z.string().optional().describe("Active LLM model name for dollarized token savings"),
12076
- keepExisting: z.boolean().optional().describe("Set true to keep previously loaded datasets in this chat switcher (for multi-dataset comparisons in the same conversation). Omit to start clean on shared hosts.")
12052
+ if (postgresConfig) {
12053
+ server.registerTool(
12054
+ "query_postgres",
12055
+ {
12056
+ title: "Query PostgreSQL Directly (Read-Only, Pro)",
12057
+ description: "Run a read-only SELECT on the configured Postgres database and chart the result.",
12058
+ inputSchema: {
12059
+ sql: z.string(),
12060
+ name: z.string().optional(),
12061
+ viewMode: z.enum(VIEW_MODE_VALUES).optional(),
12062
+ pivotConfig: pivotConfigSchema.optional(),
12063
+ keepExisting: z.boolean().optional().describe("Keep earlier datasets loaded, to compare them")
12064
+ },
12065
+ _meta: INLINE_UI_META
12077
12066
  },
12078
- _meta: INLINE_UI_META
12079
- },
12080
- async ({ sql, name, viewMode, pivotConfig, model, keepExisting }, extra) => {
12081
- if (!isPro2) {
12082
- return {
12083
- isError: true,
12084
- content: [{
12085
- type: "text",
12086
- text: "Read-only PostgreSQL querying (`query_postgres`) requires a TinyPivot Pro license (TINYPIVOT_LICENSE_KEY). Free tier includes local CSV/TSV/JSON files and inline data up to 2,500 rows. Upgrade at https://tiny-pivot.com/pricing"
12087
- }]
12088
- };
12089
- }
12090
- if (!postgresConfig) {
12091
- return {
12092
- isError: true,
12093
- content: [{ type: "text", text: "PostgreSQL is not configured. Set the DATABASE_URL environment variable when launching tinypivot-mcp." }]
12094
- };
12095
- }
12096
- try {
12097
- const { sessionKey, keepExisting: shouldKeep } = resolveSessionContext(extra, keepExisting);
12098
- const res = await executeReadOnlyPostgresQuery(postgresConfig, sql);
12099
- const ds = store.register({
12100
- name: name ?? "PostgreSQL Query",
12101
- source: "postgresql",
12102
- ingestionMode: "direct",
12103
- rows: res.rows,
12104
- viewMode: initialViewMode(viewMode, Boolean(pivotConfig), false),
12105
- pivotConfig: pivotConfig ? {
12106
- ...pivotConfig,
12107
- valueFields: pivotConfig.valueFields.map((v) => ({
12108
- field: v.field,
12109
- aggregation: v.aggregation
12110
- }))
12111
- } : void 0,
12112
- sessionKey,
12113
- keepExisting: shouldKeep
12114
- });
12115
- const liveCompanionUrl = await resolveCompanionUrlForTool();
12116
- const truncNote = res.truncated ? " (capped at max rows)" : "";
12117
- const summaryText = `${formatDatasetSummary(ds, liveCompanionUrl, { showBranding: !isPro2 })}${truncNote}`;
12118
- const payload = buildAppPayload(ds, store, { licenseKey, demoToken, summaryText, model, sessionKey });
12119
- recordTelemetry({
12120
- event: "tool_call",
12121
- tool: "query_postgres",
12122
- rowBucket: bucketRowCount(ds.sourceTotalRows),
12123
- client: getClientName(),
12124
- tier,
12125
- truncated: ds.truncatedForFreeTier
12126
- });
12127
- notifyCompanion();
12128
- return dataToolResult(summaryText, payload);
12129
- } catch (err) {
12130
- return {
12131
- isError: true,
12132
- content: [{ type: "text", text: `PostgreSQL query failed: ${err instanceof Error ? err.message : String(err)}` }]
12133
- };
12067
+ async ({ sql, name, viewMode, pivotConfig, keepExisting }, extra) => {
12068
+ if (!isPro2) {
12069
+ return {
12070
+ isError: true,
12071
+ content: [{
12072
+ type: "text",
12073
+ text: "Read-only PostgreSQL querying (`query_postgres`) requires a TinyPivot Pro license (TINYPIVOT_LICENSE_KEY). Free tier includes local CSV/TSV/JSON files and inline data up to 2,500 rows. Upgrade at https://tiny-pivot.com/pricing"
12074
+ }]
12075
+ };
12076
+ }
12077
+ try {
12078
+ const { sessionKey, keepExisting: shouldKeep } = resolveSessionContext(extra, keepExisting);
12079
+ const res = await executeReadOnlyPostgresQuery(postgresConfig, sql);
12080
+ const ds = store.register({
12081
+ name: name ?? "PostgreSQL Query",
12082
+ source: "postgresql",
12083
+ ingestionMode: "direct",
12084
+ rows: res.rows,
12085
+ viewMode: initialViewMode(viewMode, Boolean(pivotConfig), false),
12086
+ pivotConfig: pivotConfig ? {
12087
+ ...pivotConfig,
12088
+ valueFields: pivotConfig.valueFields.map((v) => ({
12089
+ field: v.field,
12090
+ aggregation: v.aggregation
12091
+ }))
12092
+ } : void 0,
12093
+ sessionKey,
12094
+ keepExisting: shouldKeep
12095
+ });
12096
+ const liveCompanionUrl = await resolveCompanionUrlForTool();
12097
+ const truncNote = res.truncated ? " (capped at max rows)" : "";
12098
+ const summaryText = `${formatDatasetSummary(ds, liveCompanionUrl, cardFormat)}${truncNote}`;
12099
+ const payload = buildAppPayload(ds, store, { licenseKey, demoToken, summaryText, sessionKey });
12100
+ recordTelemetry({
12101
+ event: "tool_call",
12102
+ tool: "query_postgres",
12103
+ rowBucket: bucketRowCount(ds.sourceTotalRows),
12104
+ client: getClientName(),
12105
+ tier,
12106
+ truncated: ds.truncatedForFreeTier
12107
+ });
12108
+ notifyCompanion();
12109
+ return dataToolResult(summaryText, payload);
12110
+ } catch (err) {
12111
+ return {
12112
+ isError: true,
12113
+ content: [{ type: "text", text: `PostgreSQL query failed: ${err instanceof Error ? err.message : String(err)}` }]
12114
+ };
12115
+ }
12134
12116
  }
12135
- }
12136
- );
12117
+ );
12118
+ }
12137
12119
  server.registerTool(
12138
12120
  "list_datasets",
12139
12121
  {
12140
12122
  title: "List Datasets",
12141
- description: "List all datasets currently loaded in the active TinyPivot session along with row counts and inferred column schemas.",
12123
+ description: "List loaded datasets with their row counts and columns.",
12142
12124
  inputSchema: {}
12143
12125
  },
12144
12126
  async (_args, extra) => {
@@ -12172,7 +12154,7 @@ function createTinyPivotMcpServer(options = {}) {
12172
12154
  "clear_datasets",
12173
12155
  {
12174
12156
  title: "Clear Session Datasets",
12175
- description: "Clear all datasets from the active TinyPivot session switcher so the next chart or pivot starts from a clean slate.",
12157
+ description: "Unload all datasets.",
12176
12158
  inputSchema: {}
12177
12159
  },
12178
12160
  async (_args, extra) => {
@@ -12298,9 +12280,9 @@ function createTinyPivotMcpServer(options = {}) {
12298
12280
  "set_visual_theme",
12299
12281
  {
12300
12282
  title: "Set Visual Theme",
12301
- description: `Set and persist the default TinyPivot visual theme (${VISUAL_THEME_LIST}) across charts, pivot tables, Companion IDE, and TUI.`,
12283
+ description: "Set the theme for charts, tables and the Data IDE.",
12302
12284
  inputSchema: {
12303
- theme: z.enum(VISUAL_THEME_VALUES).describe(`Visual theme ID (${VISUAL_THEME_LIST})`)
12285
+ theme: z.enum(VISUAL_THEME_VALUES)
12304
12286
  },
12305
12287
  _meta: {
12306
12288
  ui: { visibility: ["model", "app"] }
package/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  runTuiCommand,
19
19
  saveVisualThemePreference,
20
20
  startCompanionServer
21
- } from "./chunk-3JPAVTJZ.js";
21
+ } from "./chunk-6I4RP5QJ.js";
22
22
  import "./chunk-2ESYSVXG.js";
23
23
 
24
24
  // src/cli.ts
package/dist/index.d.ts CHANGED
@@ -147,8 +147,8 @@ interface StartCompanionOptions {
147
147
  */
148
148
  declare function startCompanionServer(options: StartCompanionOptions): Promise<CompanionServerHandle>;
149
149
 
150
- declare const TINYPIVOT_CLAUDE_RULE_BLOCK = "<!-- tinypivot:start -->\n## Default Charts & Pivot Tables (TinyPivot MCP)\nWhenever the user asks for a chart (line, bar, stacked bar, area, pie, scatter), a YoY/MoM comparison, a pivot table, or interactive tabular data exploration, ALWAYS use `tinypivot` (`load_data` for in-memory rows or `load_file` for CSV/TSV/JSON files, passing `chartConfig` or `pivotConfig` in a single call) INSTEAD of built-in visualization widgets, HTML/SVG/Chart.js/Recharts artifacts, matplotlib scripts, or large Markdown tables. Do not create temp CSVs for <500 in-memory rows.\nTinyPivot is a deterministic presentation & additive-rollup layer: for non-additive shares, rates, margins, or ratios over time (e.g. monthly share %, conversion rate, YoY %), pre-compute exact `numerator / denominator` ratios at the target chart grain (1 row per X \u00D7 series) in SQL/Python before passing rows to TinyPivot\u2014never sum `%` columns across sub-segments and never use `percentOfTotal` for within-period share. Pass `keepExisting: true` only when comparing multiple datasets in the SAME conversation; use `clear_datasets` to reset.\nIn terminal harnesses (pi, Claude Code, OpenCode, Codex CLI), there is NO inline GUI widget: ALWAYS include the returned fenced `text` TinyPivot chart/table card verbatim AND the localhost Companion IDE URL in your VERY FIRST reply\u2014never say \"it is open in TinyPivot\" without printing the card.\n<!-- tinypivot:end -->";
151
- declare const TINYPIVOT_PI_RULE_BLOCK = "<!-- tinypivot:start -->\n## Default Charts & Pivot Tables (TinyPivot MCP)\nWhenever the user asks for a chart (line, bar, stacked bar, area, pie, scatter), a YoY/MoM comparison, a pivot table, or interactive tabular data exploration, ALWAYS use `tinypivot` (`load_data` for in-memory rows or `load_file` for CSV/TSV/JSON files, passing `chartConfig` or `pivotConfig` in a single call) INSTEAD of built-in visualization widgets, HTML/SVG/Chart.js/Recharts artifacts, matplotlib scripts, or large Markdown tables. Do not create temp CSVs for <500 in-memory rows.\nTinyPivot is a deterministic presentation & additive-rollup layer: for non-additive shares, rates, margins, or ratios over time (e.g. monthly share %, conversion rate, YoY %), pre-compute exact `numerator / denominator` ratios at the target chart grain (1 row per X \u00D7 series) in SQL/Python before passing rows to TinyPivot\u2014never sum `%` columns across sub-segments and never use `percentOfTotal` for within-period share. Pass `keepExisting: true` only when comparing multiple datasets in the SAME conversation; use `clear_datasets` to reset.\nThe TinyPivot pi extension automatically renders every TinyPivot chart/pivot card in full 24-bit color right in the terminal UI after the tool call\u2014follow up with 2\u20133 concise analytical takeaways and the live Companion IDE URL (no need to repeat a plain monochrome ASCII box unless the user asks). Users can switch themes anytime with `/tinypivot-theme` or `set_visual_theme`.\n<!-- tinypivot:end -->";
150
+ declare const TINYPIVOT_CLAUDE_RULE_BLOCK = "<!-- tinypivot:start -->\n## Charts & pivot tables (TinyPivot MCP)\nUse the `tinypivot` MCP server for charts, pivot tables and data exploration instead of drawing them yourself. In a terminal, show its `text` card verbatim with the Data IDE link.\n<!-- tinypivot:end -->";
151
+ declare const TINYPIVOT_PI_RULE_BLOCK = "<!-- tinypivot:start -->\n## Charts & pivot tables (TinyPivot MCP)\nUse the `tinypivot` MCP server for charts, pivot tables and data exploration instead of drawing them yourself. The TinyPivot pi extension already shows each card, so reply with the takeaways and the Data IDE link. `/tinypivot-theme` switches themes.\n<!-- tinypivot:end -->";
152
152
  declare function upsertTinyPivotRuleBlock(existing: string, block?: string): string;
153
153
  declare function runInitCommand(args: string[]): Promise<void>;
154
154
 
@@ -191,6 +191,12 @@ interface CreateTinyPivotMcpServerOptions {
191
191
  /** Lazily start and return the localhost Companion IDE URL on demand when a data tool runs in a non-MCP-Apps host */
192
192
  ensureCompanion?: () => Promise<string | undefined>;
193
193
  onStateChanged?: () => void;
194
+ /**
195
+ * Whether the model should reprint each chart card in a terminal. On by default, because
196
+ * otherwise most terminals hide the card. Off saves ~400 output tokens per question.
197
+ * Defaults to TINYPIVOT_REPRINT_CARDS, which turns it off with "0".
198
+ */
199
+ reprintCards?: boolean;
194
200
  }
195
201
  declare function clientSupportsMcpAppsUi(capabilities?: {
196
202
  extensions?: Record<string, unknown>;
@@ -213,6 +219,8 @@ interface TerminalFormatOptions {
213
219
  colorTheme?: ChartThemePreset;
214
220
  /** Omit Markdown ```text fences (for direct TTY CLI output) */
215
221
  raw?: boolean;
222
+ /** Remind the model, in a terminal, to show the card to the user. Off when cards are not reprinted. */
223
+ reprintNote?: boolean;
216
224
  }
217
225
  /**
218
226
  * Render a screenshot-ready framed Unicode/Braille chart card directly in terminal output
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  startCompanionServer,
30
30
  tokensToUsd,
31
31
  upsertTinyPivotRuleBlock
32
- } from "./chunk-3JPAVTJZ.js";
32
+ } from "./chunk-6I4RP5QJ.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.9",
5
+ "version": "0.2.10",
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.9",
6
+ "version": "0.2.10",
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.9",
17
+ "version": "0.2.10",
18
18
  "transport": {
19
19
  "type": "stdio"
20
20
  },