@speakai/mcp-server 1.14.0 → 1.16.0

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.
Files changed (2) hide show
  1. package/dist/index.js +431 -135
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1402,6 +1402,42 @@ function register(server, client) {
1402
1402
  }
1403
1403
  }
1404
1404
  );
1405
+ registerSpeakTool(
1406
+ server,
1407
+ "update_transcription",
1408
+ "Edit the official transcript text of a single media file by finding and replacing text. Replaces every occurrence of the original text with the replacement (leave replacement empty to delete the text) and reports how many occurrences were replaced. Use update_transcript_speakers to rename speaker labels instead.",
1409
+ {
1410
+ mediaId: import_zod2.z.string().min(1).describe("Unique identifier of the media file"),
1411
+ original: import_zod2.z.string().min(1).describe("Text to find in the transcript"),
1412
+ replacement: import_zod2.z.string().describe("Text to replace it with (empty string deletes the matched text)"),
1413
+ caseSensitive: import_zod2.z.boolean().optional().describe("Match case exactly when finding the original text")
1414
+ },
1415
+ {
1416
+ title: "Update Transcription Text",
1417
+ readOnlyHint: false,
1418
+ destructiveHint: true,
1419
+ idempotentHint: false,
1420
+ openWorldHint: false
1421
+ },
1422
+ async ({ mediaId, original, replacement, caseSensitive }) => {
1423
+ try {
1424
+ const result = await api.put(
1425
+ `/v1/media/transcript/${mediaId}/replace`,
1426
+ { original, replacement, caseSensitive }
1427
+ );
1428
+ return {
1429
+ content: [
1430
+ { type: "text", text: JSON.stringify(result.data, null, 2) }
1431
+ ]
1432
+ };
1433
+ } catch (err) {
1434
+ return {
1435
+ content: [{ type: "text", text: `Error: ${formatAxiosError(err)}` }],
1436
+ isError: true
1437
+ };
1438
+ }
1439
+ }
1440
+ );
1405
1441
  registerSpeakTool(
1406
1442
  server,
1407
1443
  "get_media_status",
@@ -5359,32 +5395,114 @@ var init_users = __esm({
5359
5395
  });
5360
5396
 
5361
5397
  // src/tools/dashboard-widgets.ts
5362
- function buildDashboardWidgets(items) {
5363
- let y = 0;
5398
+ function defaultWidgetConfig(type) {
5399
+ switch (type) {
5400
+ case "narrative":
5401
+ return { focus: "Summarize the key takeaways from this data." };
5402
+ case "stat-cards":
5403
+ return {
5404
+ tiles: [
5405
+ { metric: { kind: "builtin", name: "mediaCount" }, label: "Media files" },
5406
+ { metric: { kind: "builtin", name: "totalDuration" }, label: "Total duration" },
5407
+ { metric: { kind: "builtin", name: "wordCount" }, label: "Total words" },
5408
+ { metric: { kind: "builtin", name: "speakerCount" }, label: "Unique speakers" }
5409
+ ]
5410
+ };
5411
+ case "metric-chart":
5412
+ return {
5413
+ mark: "bar",
5414
+ metric: { kind: "builtin", name: "mediaCount" },
5415
+ groupBy: { kind: "folder" }
5416
+ };
5417
+ case "table":
5418
+ return {
5419
+ rowsAre: "groups",
5420
+ groupBy: { kind: "folder" },
5421
+ columns: [
5422
+ { header: "Recordings", metric: { kind: "builtin", name: "mediaCount" } },
5423
+ { header: "Duration", metric: { kind: "builtin", name: "totalDuration" } }
5424
+ ],
5425
+ sort: { column: "Recordings", dir: "desc" }
5426
+ };
5427
+ case "comparison":
5428
+ return {
5429
+ dimension: "folder",
5430
+ a: {},
5431
+ b: {},
5432
+ metrics: [{ kind: "builtin", name: "mediaCount" }]
5433
+ };
5434
+ case "field-distribution":
5435
+ throw new Error(
5436
+ 'field-distribution requires config.fieldName (a custom field NAME \u2014 not id \u2014 from list_fields), plus measure ("count" | "percent") and chartType ("bar" | "donut").'
5437
+ );
5438
+ case "sentiment-trend":
5439
+ return { granularity: "week" };
5440
+ case "themes":
5441
+ return { limit: 10 };
5442
+ case "people":
5443
+ return { metrics: [{ kind: "builtin", name: "mediaCount" }], limit: 10 };
5444
+ case "team-activity":
5445
+ return { metrics: ["uploads", "minutes", "lastActive"] };
5446
+ case "notes":
5447
+ return { content: "Add notes or context for this dashboard." };
5448
+ }
5449
+ }
5450
+ function buildDashboardWidgets(items, sections = []) {
5451
+ for (const item of items) {
5452
+ if (item.id !== void 0 && !KEBAB_ID.test(item.id)) {
5453
+ throw new Error(
5454
+ `widget id "${item.id}" must be kebab-case (lowercase letters, digits, single dashes)`
5455
+ );
5456
+ }
5457
+ }
5458
+ const widgets = items.map((item) => makeWidget(item));
5459
+ const referenced = new Set(sections.flatMap((s) => s.widgetIds));
5460
+ const known = new Set(widgets.map((w) => w.id));
5461
+ for (const wid of referenced) {
5462
+ if (!known.has(wid)) {
5463
+ throw new Error(
5464
+ `section widgetIds reference unknown widget id "${wid}". Give each sectioned widget an explicit kebab-case \`id\` and list that id in the section.`
5465
+ );
5466
+ }
5467
+ }
5468
+ const sectionOf = /* @__PURE__ */ new Map();
5469
+ sections.forEach((s, i) => s.widgetIds.forEach((wid) => sectionOf.set(wid, i)));
5470
+ const groups = [widgets.filter((w) => !sectionOf.has(w.id))];
5471
+ sections.forEach(
5472
+ (_, i) => groups.push(widgets.filter((w) => sectionOf.get(w.id) === i))
5473
+ );
5474
+ for (const group of groups) {
5475
+ layoutGroup(group);
5476
+ }
5477
+ return widgets;
5478
+ }
5479
+ function layoutGroup(group) {
5480
+ let y = group.reduce(
5481
+ (bottom, w) => isAutoLayout(w) ? bottom : Math.max(bottom, w.layout.y + w.layout.h),
5482
+ 0
5483
+ );
5364
5484
  let rowX = 0;
5365
5485
  let rowH = 0;
5366
- return items.map((item) => {
5367
- const meta = WIDGET_META[item.type];
5486
+ for (const widget of group) {
5487
+ if (!isAutoLayout(widget)) continue;
5488
+ const meta = WIDGET_META[widget.type];
5368
5489
  const full = meta.w >= GRID_COLS;
5369
- let x;
5370
5490
  if (full) {
5371
5491
  if (rowX !== 0) {
5372
5492
  y += rowH;
5373
5493
  rowX = 0;
5374
5494
  rowH = 0;
5375
5495
  }
5376
- x = 0;
5377
- const widget2 = makeWidget(item, x, y);
5496
+ widget.layout = { x: 0, y, w: meta.w, h: meta.h };
5378
5497
  y += meta.h;
5379
- return widget2;
5498
+ continue;
5380
5499
  }
5381
5500
  if (rowX + meta.w > GRID_COLS) {
5382
5501
  y += rowH;
5383
5502
  rowX = 0;
5384
5503
  rowH = 0;
5385
5504
  }
5386
- x = rowX;
5387
- const widget = makeWidget(item, x, y);
5505
+ widget.layout = { x: rowX, y, w: meta.w, h: meta.h };
5388
5506
  rowX += meta.w;
5389
5507
  rowH = Math.max(rowH, meta.h);
5390
5508
  if (rowX >= GRID_COLS) {
@@ -5392,151 +5510,233 @@ function buildDashboardWidgets(items) {
5392
5510
  rowX = 0;
5393
5511
  rowH = 0;
5394
5512
  }
5395
- return widget;
5396
- });
5513
+ }
5397
5514
  }
5398
- function makeWidget(item, x, y) {
5515
+ function isAutoLayout(widget) {
5516
+ return widget.layout.w === 0;
5517
+ }
5518
+ function makeWidget(item) {
5399
5519
  const meta = WIDGET_META[item.type];
5400
- return {
5401
- id: (0, import_crypto.randomUUID)(),
5520
+ const widget = {
5521
+ id: item.id ?? (0, import_crypto.randomUUID)(),
5402
5522
  type: item.type,
5403
5523
  title: item.title ?? meta.titleDefault,
5404
- config: item.config ?? {},
5405
- layout: { x, y, w: meta.w, h: meta.h, minW: meta.minW, minH: meta.minH }
5524
+ config: item.config ?? defaultWidgetConfig(item.type),
5525
+ layout: item.layout ? { x: item.layout.x, y: item.layout.y, w: item.layout.w, h: item.layout.h } : { ...AUTO_LAYOUT }
5406
5526
  };
5527
+ if (item.binding && Object.keys(item.binding).length > 0) {
5528
+ widget.binding = item.binding;
5529
+ }
5530
+ return widget;
5407
5531
  }
5408
- var import_crypto, GRID_COLS, WIDGET_TYPES, WIDGET_META, WIDGET_CATALOG, COMMON_WIDGET_CONFIG, DASHBOARD_EXAMPLES;
5532
+ var import_crypto, GRID_COLS, WIDGET_TYPES, DATE_RANGE_PRESETS, WIDGET_META, KEBAB_ID, AUTO_LAYOUT, WIDGET_CATALOG, SPEC_VOCABULARY, DESIGN_RULES, DASHBOARD_EXAMPLES;
5409
5533
  var init_dashboard_widgets = __esm({
5410
5534
  "src/tools/dashboard-widgets.ts"() {
5411
5535
  "use strict";
5412
5536
  import_crypto = require("crypto");
5413
5537
  GRID_COLS = 12;
5414
5538
  WIDGET_TYPES = [
5539
+ "narrative",
5415
5540
  "stat-cards",
5416
- "sentiment",
5417
- "media-list",
5541
+ "metric-chart",
5542
+ "table",
5543
+ "comparison",
5418
5544
  "field-distribution",
5419
- "upload-timeline",
5545
+ "sentiment-trend",
5420
5546
  "themes",
5421
- "team-activity",
5422
- "kpi-trend",
5423
- "field-metric",
5424
- "metric-group",
5425
- "notes",
5426
5547
  "people",
5427
- "comparison",
5428
- "sentiment-trend"
5548
+ "team-activity",
5549
+ "notes"
5550
+ ];
5551
+ DATE_RANGE_PRESETS = [
5552
+ "last7days",
5553
+ "last30days",
5554
+ "last3months",
5555
+ "yearToDate",
5556
+ "allTime"
5429
5557
  ];
5430
5558
  WIDGET_META = {
5431
- "stat-cards": { w: GRID_COLS, h: 3, minW: 4, minH: 2, titleDefault: "Usage overview" },
5432
- sentiment: { w: 6, h: 4, minW: 3, minH: 3, titleDefault: "Sentiment" },
5433
- "media-list": { w: GRID_COLS, h: 4, minW: 4, minH: 3, titleDefault: "Recent media" },
5434
- "field-distribution": { w: 6, h: 4, minW: 3, minH: 3, titleDefault: "Field breakdown" },
5435
- "upload-timeline": { w: 6, h: 4, minW: 3, minH: 3, titleDefault: "Uploads over time" },
5436
- themes: { w: 6, h: 4, minW: 3, minH: 3, titleDefault: "Themes" },
5437
- "team-activity": { w: 6, h: 4, minW: 3, minH: 3, titleDefault: "Team activity" },
5438
- "kpi-trend": { w: 3, h: 2, minW: 2, minH: 2, titleDefault: "Total files" },
5439
- "field-metric": { w: 3, h: 2, minW: 2, minH: 2, titleDefault: "Field metric" },
5440
- "metric-group": { w: 6, h: 2, minW: 3, minH: 2, titleDefault: "Metrics" },
5441
- notes: { w: GRID_COLS, h: 2, minW: 2, minH: 1, titleDefault: "Note" },
5442
- people: { w: 6, h: 4, minW: 3, minH: 3, titleDefault: "People" },
5443
- comparison: { w: 6, h: 3, minW: 3, minH: 2, titleDefault: "Comparison" },
5444
- "sentiment-trend": { w: 6, h: 4, minW: 3, minH: 3, titleDefault: "Sentiment over time" }
5559
+ narrative: { w: GRID_COLS, h: 3, titleDefault: "Insights" },
5560
+ "stat-cards": { w: GRID_COLS, h: 3, titleDefault: "Usage overview" },
5561
+ "metric-chart": { w: 6, h: 4, titleDefault: "Metric chart" },
5562
+ table: { w: GRID_COLS, h: 4, titleDefault: "Table" },
5563
+ comparison: { w: 6, h: 3, titleDefault: "Comparison" },
5564
+ "field-distribution": { w: 6, h: 4, titleDefault: "Field breakdown" },
5565
+ "sentiment-trend": { w: 6, h: 4, titleDefault: "Sentiment over time" },
5566
+ themes: { w: 6, h: 4, titleDefault: "Themes" },
5567
+ people: { w: 6, h: 4, titleDefault: "People" },
5568
+ "team-activity": { w: 6, h: 4, titleDefault: "Team activity" },
5569
+ notes: { w: GRID_COLS, h: 2, titleDefault: "Note" }
5445
5570
  };
5571
+ KEBAB_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
5572
+ AUTO_LAYOUT = { x: 0, y: 0, w: 0, h: 0 };
5446
5573
  WIDGET_CATALOG = [
5574
+ {
5575
+ type: "narrative",
5576
+ purpose: "AI-written insight narrative for the scope (full width).",
5577
+ config: 'focus: string (1-400 chars) \u2014 what the narrative should analyse, e.g. "Summarize the key objections raised in these calls." The server generates the text.'
5578
+ },
5447
5579
  {
5448
5580
  type: "stat-cards",
5449
- purpose: "Headline totals for the scope (full width).",
5450
- config: 'metrics?: string[] \u2014 any of "media", "storage", "words", "speakers", "duration", "sentiment"'
5581
+ purpose: "Headline stat tiles for the scope (full width).",
5582
+ config: "tiles: Array<{ metric: Metric, label: string (<=40), caption?: string (<=80), thresholds?: Threshold[] }> (1-6 tiles). See metricGrammar for the Metric shape."
5451
5583
  },
5452
- { type: "sentiment", purpose: "Sentiment distribution + representative sentences.", config: "none" },
5453
- { type: "media-list", purpose: "Most recent media in scope (full width).", config: "none" },
5454
5584
  {
5455
- type: "field-distribution",
5456
- purpose: "Value-frequency breakdown for one custom field.",
5457
- config: 'fieldId: string (a custom field id from list_fields); measure?: "count" | "words" | "duration" | "avg:<numericFieldId>" | "sum:<numericFieldId>"'
5585
+ type: "metric-chart",
5586
+ purpose: "The chart workhorse: one metric, optionally grouped and split into series.",
5587
+ config: 'mark: "line" | "bar" | "area" | "donut" | "stacked-bar"; metric: Metric; groupBy?: GroupBy; series?: GroupBy (2nd dimension, e.g. one line per person); sort?: "value-desc" | "value-asc" | "label"; limit?: number (1-100); thresholds?: Threshold[]'
5458
5588
  },
5459
- { type: "upload-timeline", purpose: "Uploads over time per media type.", config: "none" },
5460
- { type: "themes", purpose: "Dominant theme clusters.", config: 'chartType?: "cloud" | "bar"' },
5461
- { type: "team-activity", purpose: "Activity by team member.", config: "none" },
5462
5589
  {
5463
- type: "kpi-trend",
5464
- purpose: "A KPI with period-over-period delta.",
5465
- config: 'metrics?: string[] \u2014 any of "totalFiles", "totalDurationSeconds", "totalWords", "uniqueSpeakers"'
5590
+ type: "table",
5591
+ purpose: "Tabular records or grouped aggregates (full width).",
5592
+ config: 'rowsAre: "records" | "groups"; groupBy?: GroupBy (required when rowsAre="groups", forbidden when "records"); columns: Array<{ header: string (<=40, unique), field: string } | { header: string, metric: Metric }> (1-12; a column is EITHER a raw field OR a metric, never both; thresholds? allowed on both forms); sort?: { column: <one of the headers>, dir: "asc" | "desc" }; limit?: number (1-500); searchable?: boolean; rowClick?: "openMedia" | "none"'
5466
5593
  },
5467
5594
  {
5468
- type: "field-metric",
5469
- purpose: "A single custom field's aggregate, with a period-over-period delta.",
5470
- config: 'fieldId: string (custom field id from list_fields); aggregator: "sum" | "avg" | "min" | "max" | "count"'
5595
+ type: "comparison",
5596
+ purpose: "Side-by-side A/B comparison of the same metrics across two scopes.",
5597
+ config: 'dimension: "folder" | "time" | "fieldValue"; a: Binding; b: Binding (the two sides \u2014 see binding; {} inherits the dashboard scope); metrics: Metric[] (1-6)'
5471
5598
  },
5472
5599
  {
5473
- type: "metric-group",
5474
- purpose: "A scorecard of several field metrics in one card.",
5475
- config: 'metrics: Array<{ fieldId: string, op: "sum"|"avg"|"min"|"max"|"count", label?: string }> (note the per-item key is `op`, not `aggregator`)'
5600
+ type: "field-distribution",
5601
+ purpose: "Value-frequency breakdown for one custom field.",
5602
+ config: 'fieldName: string \u2014 the custom field NAME (not id) from list_fields; measure: "count" | "percent"; chartType: "bar" | "donut". All three keys are required.'
5476
5603
  },
5477
5604
  {
5478
- type: "notes",
5479
- purpose: "Free-text note/context block (full width).",
5480
- config: "heading?: string; content?: string"
5605
+ type: "sentiment-trend",
5606
+ purpose: "Sentiment over time.",
5607
+ config: 'granularity: "day" | "week" | "month" (required)'
5481
5608
  },
5482
- { type: "people", purpose: "Speaker/people breakdown.", config: "none" },
5483
5609
  {
5484
- type: "comparison",
5485
- purpose: "Period-over-period comparison of KPIs.",
5486
- config: 'metrics?: string[] \u2014 any of "totalFiles", "totalDurationSeconds", "totalWords", "uniqueSpeakers"'
5610
+ type: "themes",
5611
+ purpose: "Dominant theme clusters.",
5612
+ config: "limit: number (1-50, required)"
5487
5613
  },
5488
- { type: "sentiment-trend", purpose: "Sentiment over time.", config: "none" }
5489
- ];
5490
- COMMON_WIDGET_CONFIG = [
5491
5614
  {
5492
- key: "accentColor",
5493
- appliesTo: "any widget",
5494
- description: 'Hex color for the widget accent, e.g. "#6366F1". Omit for the default.'
5615
+ type: "people",
5616
+ purpose: "Speaker/people breakdown ranked by metrics.",
5617
+ config: "metrics: Metric[] (1-6, required); limit: number (1-100, required)"
5495
5618
  },
5496
5619
  {
5497
- key: "scopeOverride",
5498
- appliesTo: "any widget except notes",
5499
- description: "Override the dashboard's scope for just this widget: { datePreset: string, folderId: string }. Omit to inherit the dashboard scope."
5620
+ type: "team-activity",
5621
+ purpose: `Activity by team member. ONLY valid when the effective source is {type:"team"} (dashboard source or the widget's binding.source).`,
5622
+ config: 'metrics: Array<"uploads" | "minutes" | "meetings" | "chatUsage" | "lastActive"> (1-5, required)'
5623
+ },
5624
+ {
5625
+ type: "notes",
5626
+ purpose: "Free-text note/context block (full width).",
5627
+ config: "content: string (1-4000 chars, required)"
5500
5628
  }
5501
5629
  ];
5630
+ SPEC_VOCABULARY = {
5631
+ metricGrammar: {
5632
+ builtin: '{ kind: "builtin", name: "mediaCount" | "totalDuration" | "avgSentiment" | "speakerCount" | "wordCount", filter?: Filter }',
5633
+ field: '{ kind: "field", fieldName: string (custom field NAME from list_fields), agg: "sum" | "avg" | "min" | "max" | "median" | "count" | "countDistinct", filter?: Filter } \u2014 sum/avg/median/min/max require a number or currency field',
5634
+ expr: '{ kind: "expr", expr: <one of the four ops>, filter?: Filter }. Ops (operands are builtin/field metrics, never nested exprs): { op: "ratio", numerator: Metric, denominator: Metric } | { op: "diff", a: Metric, b: Metric } | { op: "delta", metric: Metric, over: "first-to-last" | "prev-period" } | { op: "rank", metric: Metric, direction: "desc" | "asc" }'
5635
+ },
5636
+ groupBy: '{ kind: "field", fieldName } (non-date fields) | { kind: "time", fieldName, granularity: "record" | "day" | "week" | "month" | "quarter" } (date/datetime fields only) | { kind: "folder" } | { kind: "speaker" }',
5637
+ binding: "Per-widget scope override, set as `binding` on any widget (omit a key to inherit the dashboard's value): { source?: Source, dateRange?: { preset }, filter?: Filter }",
5638
+ filter: 'Predicate tree: { field, op: "eq" | "neq" | "in" | "gt" | "gte" | "lt" | "lte" | "exists" | "notExists", value? } (op "in" takes an array value; "exists"/"notExists" take none) \u2014 or { and: Filter[] } / { or: Filter[] } (1-10 branches, max depth 5)',
5639
+ thresholds: 'Color bands for stat tiles, chart marks, and table columns (max 8): { when: { op: "gte" | "gt" | "lt" | "lte", value: number } | { op: "between", value: [low, high] }, status: "good" | "warn" | "critical" | "neutral", label?: string (<=40) }',
5640
+ source: 'Dashboard data source: { type: "folders", folderIds: string[] (1-50) } | { type: "team" } | { type: "workspace" }',
5641
+ dateRangePresets: DATE_RANGE_PRESETS,
5642
+ sections: "Optional named groups of widgets rendered as tabs/sections (max 12): { id: kebab-case string, title: string (<=24), icon: kebab-case lucide icon name, widgetIds: string[] (<=24) }. Widget ids in sections must match explicit `id`s you set on the widgets; a widget may appear in at most one section; widgets in no section form the implicit Overview group."
5643
+ };
5644
+ DESIGN_RULES = [
5645
+ "Lead with a narrative widget: on a new dashboard, make it the first widget of the first section \u2014 it is the headline insight.",
5646
+ 'Sections group widgets by the QUESTION they answer (e.g. "How is pipeline trending?"), not by widget type.',
5647
+ "Layout must never overlap within a section; side-by-side is x:0,w:6 and x:6,w:6, and y restarts at 0 in each section. Omit `layout` and the auto-layout guarantees this \u2014 only pass explicit layout when you need a non-default arrangement.",
5648
+ "Don't pad \u2014 every widget earns its place. Aim for 4-16 widgets on a full build.",
5649
+ "If something can't be computed by the widget catalog, put it in a narrative widget's focus instead of faking it with the wrong widget."
5650
+ ];
5502
5651
  DASHBOARD_EXAMPLES = [
5503
5652
  {
5504
5653
  name: "Sales calls overview",
5505
5654
  payload: {
5506
5655
  title: "Customer Calls Overview",
5507
- folderScope: ["<folderId>"],
5656
+ description: "Volume, sentiment, and themes for closed-won calls",
5657
+ source: { type: "folders", folderIds: ["<folderId>"] },
5508
5658
  dateRange: { preset: "last30days" },
5509
- filters: { filterList: [{ fieldName: "Stage", fieldOperator: "is", fieldValue: ["Closed Won"] }] },
5510
5659
  widgets: [
5511
- { type: "stat-cards", config: { metrics: ["media", "words", "speakers"] } },
5512
- { type: "sentiment", config: { accentColor: "#6366F1" } },
5513
- { type: "field-distribution", title: "Deals by stage", config: { fieldId: "<fieldId>", measure: "count" } },
5514
- { type: "themes", config: { chartType: "bar" } },
5515
- { type: "media-list" }
5660
+ { type: "narrative", config: { focus: "Summarize the key wins and objections in these calls." } },
5661
+ { type: "stat-cards" },
5662
+ {
5663
+ type: "metric-chart",
5664
+ title: "Calls per week",
5665
+ config: {
5666
+ mark: "line",
5667
+ metric: { kind: "builtin", name: "mediaCount" },
5668
+ groupBy: { kind: "time", fieldName: "createdAt", granularity: "week" }
5669
+ }
5670
+ },
5671
+ {
5672
+ type: "field-distribution",
5673
+ title: "Deals by stage",
5674
+ config: { fieldName: "Stage", measure: "count", chartType: "bar" }
5675
+ },
5676
+ { type: "themes", config: { limit: 10 } },
5677
+ { type: "sentiment-trend", config: { granularity: "week" } }
5516
5678
  ]
5517
5679
  }
5518
5680
  },
5519
5681
  {
5520
- name: "Field-metrics scorecard (new widgets)",
5682
+ name: "Sectioned revenue dashboard (explicit widget ids + sections)",
5521
5683
  payload: {
5522
5684
  title: "Deal Metrics",
5523
- folderScope: ["<folderId>"],
5524
- dateRange: { preset: "thisQuarter" },
5685
+ source: { type: "workspace" },
5686
+ dateRange: { preset: "last3months" },
5525
5687
  widgets: [
5526
- { type: "kpi-trend", title: "Total calls", config: { metrics: ["totalFiles"] } },
5527
- { type: "field-metric", title: "Avg deal size", config: { fieldId: "<dealSizeFieldId>", aggregator: "avg" } },
5528
5688
  {
5529
- type: "metric-group",
5689
+ id: "pipeline-stats",
5690
+ type: "stat-cards",
5530
5691
  title: "Pipeline",
5531
5692
  config: {
5532
- metrics: [
5533
- { fieldId: "<dealSizeFieldId>", op: "sum", label: "Total pipeline" },
5534
- { fieldId: "<dealSizeFieldId>", op: "max", label: "Largest deal" }
5693
+ tiles: [
5694
+ { metric: { kind: "field", fieldName: "Deal Size", agg: "sum" }, label: "Total pipeline" },
5695
+ { metric: { kind: "field", fieldName: "Deal Size", agg: "max" }, label: "Largest deal" },
5696
+ {
5697
+ metric: {
5698
+ kind: "expr",
5699
+ expr: {
5700
+ op: "ratio",
5701
+ numerator: { kind: "field", fieldName: "Deal Size", agg: "sum" },
5702
+ denominator: { kind: "builtin", name: "mediaCount" }
5703
+ }
5704
+ },
5705
+ label: "Revenue per call",
5706
+ thresholds: [{ when: { op: "gte", value: 5e3 }, status: "good" }]
5707
+ }
5535
5708
  ]
5536
5709
  }
5537
5710
  },
5538
- // Per-widget scope override: this card ignores the dashboard scope.
5539
- { type: "field-metric", title: "EMEA avg", config: { fieldId: "<dealSizeFieldId>", aggregator: "avg", scopeOverride: { datePreset: "last7days", folderId: "<emeaFolderId>" } } }
5711
+ {
5712
+ id: "deals-table",
5713
+ type: "table",
5714
+ title: "Deals by folder",
5715
+ config: {
5716
+ rowsAre: "groups",
5717
+ groupBy: { kind: "folder" },
5718
+ columns: [
5719
+ { header: "Calls", metric: { kind: "builtin", name: "mediaCount" } },
5720
+ { header: "Pipeline", metric: { kind: "field", fieldName: "Deal Size", agg: "sum" } }
5721
+ ],
5722
+ sort: { column: "Pipeline", dir: "desc" }
5723
+ }
5724
+ },
5725
+ {
5726
+ id: "emea-vs-na",
5727
+ type: "comparison",
5728
+ title: "EMEA vs NA",
5729
+ config: {
5730
+ dimension: "folder",
5731
+ a: { source: { type: "folders", folderIds: ["<emeaFolderId>"] } },
5732
+ b: { source: { type: "folders", folderIds: ["<naFolderId>"] } },
5733
+ metrics: [{ kind: "builtin", name: "mediaCount" }]
5734
+ }
5735
+ }
5736
+ ],
5737
+ sections: [
5738
+ { id: "revenue", title: "Revenue", icon: "dollar-sign", widgetIds: ["pipeline-stats", "deals-table"] },
5739
+ { id: "regions", title: "Regions", icon: "globe", widgetIds: ["emea-vs-na"] }
5540
5740
  ]
5541
5741
  }
5542
5742
  }
@@ -5549,18 +5749,41 @@ var dashboards_exports = {};
5549
5749
  __export(dashboards_exports, {
5550
5750
  register: () => register16
5551
5751
  });
5552
- function withBuiltWidgets(body) {
5553
- if (Array.isArray(body.widgets)) {
5554
- return { ...body, widgets: buildDashboardWidgets(body.widgets) };
5752
+ function buildSource(source) {
5753
+ if (source.type === "folders") {
5754
+ if (!source.folderIds?.length) {
5755
+ throw new Error('source.type "folders" requires source.folderIds (1-50 folder ids)');
5756
+ }
5757
+ return { type: "folders", folderIds: source.folderIds };
5555
5758
  }
5556
- return body;
5759
+ return { type: source.type };
5760
+ }
5761
+ function buildSpec(input) {
5762
+ const sections = input.sections ?? [];
5763
+ const spec = {
5764
+ title: input.title,
5765
+ source: buildSource(input.source ?? { type: "workspace" }),
5766
+ dateRange: input.dateRange ?? { preset: "last30days" },
5767
+ sections,
5768
+ widgets: buildDashboardWidgets(input.widgets ?? [], sections)
5769
+ };
5770
+ if (input.description !== void 0) spec.description = input.description;
5771
+ return spec;
5772
+ }
5773
+ function pickMetadata(body) {
5774
+ const out = {};
5775
+ if (body.icon !== void 0) out.icon = body.icon;
5776
+ if (body.assignTo !== void 0) out.assignTo = body.assignTo;
5777
+ if (body.filters !== void 0) out.filters = body.filters;
5778
+ if (body.isDefault !== void 0) out.isDefault = body.isDefault;
5779
+ return out;
5557
5780
  }
5558
5781
  function register16(server, client) {
5559
5782
  const api = client ?? speakClient;
5560
5783
  registerSpeakTool(
5561
5784
  server,
5562
5785
  "list_dashboards",
5563
- "List all analytics dashboards the caller can access, including share state.",
5786
+ "List all analytics dashboards the caller can access, including share state and each dashboard's current `revision` (needed for update_dashboard).",
5564
5787
  {},
5565
5788
  {
5566
5789
  title: "List Dashboards",
@@ -5586,7 +5809,7 @@ function register16(server, client) {
5586
5809
  registerSpeakTool(
5587
5810
  server,
5588
5811
  "get_dashboard",
5589
- "Get a single dashboard's full config (widgets, filters, date range, folder scope).",
5812
+ "Get a single dashboard's full spec: title, description, source, date range, sections, widgets, and the current `revision` (pass that revision back to update_dashboard).",
5590
5813
  {
5591
5814
  dashboardId: import_zod17.z.string().min(1).describe("Dashboard business id (the dashboardId field from list_dashboards, not the Mongo _id)")
5592
5815
  },
@@ -5614,7 +5837,7 @@ function register16(server, client) {
5614
5837
  registerSpeakTool(
5615
5838
  server,
5616
5839
  "list_dashboard_widgets",
5617
- "Discovery + how-to helper for building and customizing dashboards. Returns every widget type with what it shows and the exact `config` keys it accepts (metrics, fieldId, aggregator, chartType, accentColor, scopeOverride, \u2026), the config that applies to all widgets, two complete worked example payloads (including the field-metric and metric-group cards), and tips for managing dashboards. Call this before create_dashboard / update_dashboard.",
5840
+ "Discovery + how-to helper for building and customizing dashboards. Returns every widget type with what it shows and the exact strict `config` shape it accepts, the shared vocabulary (metric grammar, groupBy, per-widget binding, filters, thresholds, sources, date-range presets, sections), design rules for composing a dashboard that reads well, two complete worked example payloads, and tips for managing dashboards. Call this before create_dashboard / update_dashboard.",
5618
5841
  {},
5619
5842
  {
5620
5843
  title: "List Dashboard Widgets",
@@ -5626,16 +5849,17 @@ function register16(server, client) {
5626
5849
  async () => {
5627
5850
  const data = {
5628
5851
  widgets: WIDGET_CATALOG,
5629
- commonConfig: COMMON_WIDGET_CONFIG,
5852
+ vocabulary: SPEC_VOCABULARY,
5853
+ designRules: DESIGN_RULES,
5630
5854
  notes: [
5631
5855
  "Pass widgets to create_dashboard as a simple ordered list; ids and grid layout are computed for you.",
5632
- "Field-driven widgets (field-distribution, field-metric, metric-group) need custom field ids from list_fields in their config.",
5633
- "field-metric uses config.aggregator; metric-group items use the key `op` (both: sum|avg|min|max|count).",
5634
- "accentColor (hex) and scopeOverride ({datePreset, folderId}) can be set on any widget's config to customize it.",
5635
- "Most other widgets render on sensible defaults with no config."
5856
+ "Widget configs are STRICT: unknown keys are rejected. Metrics reference custom fields by NAME (list_fields), not id.",
5857
+ "field-distribution requires config.fieldName; most other widgets render on valid defaults with no config.",
5858
+ `team-activity is only valid when the dashboard source (or the widget's binding.source) is {type:"team"}.`,
5859
+ "To group widgets into sections, give each sectioned widget an explicit kebab-case `id` and reference those ids in sections[].widgetIds."
5636
5860
  ],
5637
5861
  managing: [
5638
- "To customize an existing dashboard, call get_dashboard, edit the widgets array, and send the full array to update_dashboard (widgets are replaced, not merged).",
5862
+ "To edit an existing dashboard, call get_dashboard, modify the widgets/sections, and send the FULL spec to update_dashboard including the `revision` you loaded (widgets are replaced, not merged).",
5639
5863
  "To start from a working layout, duplicate_dashboard a good one, then update_dashboard to tweak it.",
5640
5864
  "share_dashboard returns a public token; chain it after the dashboard is built."
5641
5865
  ],
@@ -5647,10 +5871,11 @@ function register16(server, client) {
5647
5871
  registerSpeakTool(
5648
5872
  server,
5649
5873
  "create_dashboard",
5650
- "Create an analytics dashboard. Only `title` is required. Add widgets by listing their types (the MCP assigns ids and lays them out automatically) and scope with folderScope, dateRange, and filters. Call list_dashboard_widgets first to see the available widget types and their config keys, plus a full example.",
5874
+ `Create an analytics dashboard. Only \`title\` is required \u2014 source defaults to the whole workspace and dateRange to last30days. Add widgets by listing their types (the MCP assigns ids and lays them out automatically), scope with source ({type:"folders",folderIds} | {type:"team"} | {type:"workspace"}) and dateRange ({preset}), and optionally group widgets into sections. Design guidance: lead with a narrative widget as the first widget; group sections by the QUESTION they answer, not by widget type; don't pad \u2014 every widget earns its place (aim for 4-16 widgets on a full build); if something can't be expressed by the widget catalog, put it in a narrative widget's focus instead of faking it. Call list_dashboard_widgets first for the widget catalog, config vocabulary, design rules, and full examples.`,
5651
5875
  {
5652
- title: import_zod17.z.string().min(1).max(200).describe("Dashboard name (the only required field)"),
5653
- ...writeFields
5876
+ title: import_zod17.z.string().min(1).max(60).describe("Dashboard name, max 60 chars (the only required field)"),
5877
+ ...specFields,
5878
+ ...metadataFields
5654
5879
  },
5655
5880
  {
5656
5881
  title: "Create Dashboard",
@@ -5659,9 +5884,20 @@ function register16(server, client) {
5659
5884
  idempotentHint: false,
5660
5885
  openWorldHint: false
5661
5886
  },
5662
- async (body) => {
5887
+ async ({ title, description, source, dateRange, sections, widgets, ...metadata }) => {
5663
5888
  try {
5664
- const result = await api.post("/v1/dashboards", withBuiltWidgets(body));
5889
+ const body = {
5890
+ spec: buildSpec({
5891
+ title,
5892
+ description,
5893
+ source,
5894
+ dateRange,
5895
+ sections,
5896
+ widgets
5897
+ }),
5898
+ ...pickMetadata(metadata)
5899
+ };
5900
+ const result = await api.post("/v1/dashboards", body);
5665
5901
  return {
5666
5902
  content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
5667
5903
  };
@@ -5676,22 +5912,49 @@ function register16(server, client) {
5676
5912
  registerSpeakTool(
5677
5913
  server,
5678
5914
  "update_dashboard",
5679
- "Update a dashboard. Only the fields you pass are changed (partial update). NOTE: passing `widgets` replaces the entire widget set \u2014 fetch the dashboard first if you want to preserve existing widgets.",
5915
+ "Update a dashboard. Two modes. (1) Metadata-only: pass just icon/assignTo/filters/isDefault \u2014 no spec fields, no revision needed. (2) Spec update: pass the FULL spec \u2014 title, source, dateRange, sections, widgets \u2014 plus `revision`. Widgets and sections are REPLACED, not merged, so call get_dashboard first and resend everything you want to keep. `revision` is the optimistic-concurrency token from get_dashboard/list_dashboards: the server accepts the write only if it still matches, then increments it. A 409 conflict means another writer saved first \u2014 re-fetch with get_dashboard, rebuild your changes on the fresh spec, and retry with the new revision.",
5680
5916
  {
5681
5917
  dashboardId: import_zod17.z.string().min(1).describe("Dashboard business id"),
5682
- title: import_zod17.z.string().min(1).max(200).optional().describe("New dashboard name"),
5683
- ...writeFields
5918
+ title: import_zod17.z.string().min(1).max(60).optional().describe("Dashboard name \u2014 required (with revision) when updating the spec"),
5919
+ revision: import_zod17.z.number().int().nonnegative().optional().describe(
5920
+ "The revision loaded from get_dashboard. Required for spec updates; mismatch returns a 409 conflict."
5921
+ ),
5922
+ ...specFields,
5923
+ ...metadataFields
5684
5924
  },
5685
5925
  {
5686
5926
  title: "Update Dashboard",
5687
5927
  readOnlyHint: false,
5688
5928
  destructiveHint: true,
5689
- idempotentHint: true,
5929
+ idempotentHint: false,
5690
5930
  openWorldHint: false
5691
5931
  },
5692
- async ({ dashboardId, ...body }) => {
5932
+ async ({ dashboardId, title, revision, description, source, dateRange, sections, widgets, ...metadata }) => {
5693
5933
  try {
5694
- const result = await api.put(`/v1/dashboards/${dashboardId}`, withBuiltWidgets(body));
5934
+ const specTouched = title !== void 0 || description !== void 0 || source !== void 0 || dateRange !== void 0 || sections !== void 0 || widgets !== void 0;
5935
+ const body = pickMetadata(metadata);
5936
+ if (specTouched) {
5937
+ if (title === void 0 || revision === void 0) {
5938
+ throw new Error(
5939
+ "Spec updates replace the whole spec: call get_dashboard first, then pass the FULL spec (title, source, dateRange, sections, widgets) together with the loaded `revision`."
5940
+ );
5941
+ }
5942
+ body.spec = {
5943
+ ...buildSpec({
5944
+ title,
5945
+ description,
5946
+ source,
5947
+ dateRange,
5948
+ sections,
5949
+ widgets
5950
+ }),
5951
+ revision
5952
+ };
5953
+ }
5954
+ if (Object.keys(body).length === 0) {
5955
+ throw new Error("Nothing to update: pass spec fields (with revision) or metadata fields.");
5956
+ }
5957
+ const result = await api.put(`/v1/dashboards/${dashboardId}`, body);
5695
5958
  return {
5696
5959
  content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }]
5697
5960
  };
@@ -5734,7 +5997,7 @@ function register16(server, client) {
5734
5997
  registerSpeakTool(
5735
5998
  server,
5736
5999
  "duplicate_dashboard",
5737
- 'Clone an existing dashboard. The copy gets fresh widget ids, a "<name> (copy)" title, and cleared sharing. Ideal for cloning a fully-configured dashboard, then tweaking it via update_dashboard.',
6000
+ 'Clone an existing dashboard. The copy gets fresh widget ids, a "<name> (copy)" title, cleared sharing, and its revision reset to 0. Ideal for cloning a fully-configured dashboard, then tweaking it via update_dashboard.',
5738
6001
  {
5739
6002
  dashboardId: import_zod17.z.string().min(1).describe("Source dashboard business id to clone")
5740
6003
  },
@@ -5814,7 +6077,7 @@ function register16(server, client) {
5814
6077
  }
5815
6078
  );
5816
6079
  }
5817
- var import_zod17, FILTER_LIST_DESCRIPTION, widgetInputSchema, writeFields, SPEAKERS_FILTER_SCHEMA;
6080
+ var import_zod17, FILTER_LIST_DESCRIPTION, widgetInputSchema, sectionInputSchema, sourceInputSchema, dateRangeInputSchema, metadataFields, specFields, SPEAKERS_FILTER_SCHEMA;
5818
6081
  var init_dashboards = __esm({
5819
6082
  "src/tools/dashboards.ts"() {
5820
6083
  "use strict";
@@ -5825,29 +6088,61 @@ var init_dashboards = __esm({
5825
6088
  FILTER_LIST_DESCRIPTION = "Field filters. filters.filterList is an array of { fieldName, fieldOperator?, fieldValue?: string[], fieldCondition? }. Other keys pass through but only filterList is enforced.";
5826
6089
  widgetInputSchema = import_zod17.z.object({
5827
6090
  type: import_zod17.z.enum(WIDGET_TYPES).describe(
5828
- "Widget type: stat-cards | sentiment | media-list | field-distribution | upload-timeline | themes | team-activity | kpi-trend | field-metric | metric-group | notes | people | comparison | sentiment-trend"
6091
+ "Widget type: narrative | stat-cards | metric-chart | table | comparison | field-distribution | sentiment-trend | themes | people | team-activity | notes"
5829
6092
  ),
5830
- title: import_zod17.z.string().max(200).optional().describe("Widget title (defaults to a per-type label)"),
6093
+ id: import_zod17.z.string().max(64).optional().describe(
6094
+ "Optional explicit widget id (kebab-case). Required if you reference the widget from sections[].widgetIds; auto-generated otherwise."
6095
+ ),
6096
+ title: import_zod17.z.string().min(1).max(40).optional().describe("Widget title, max 40 chars (defaults to a per-type label)"),
5831
6097
  config: import_zod17.z.record(import_zod17.z.unknown()).optional().describe(
5832
- "Optional render settings. Per-type: fieldId+measure (field-distribution), fieldId+aggregator (field-metric), metrics list (stat-cards, kpi-trend, comparison, metric-group), chartType (themes), heading+content (notes). Any widget also accepts accentColor (hex) and scopeOverride ({datePreset, folderId}). Call list_dashboard_widgets for the full catalog + examples. Leave empty for sensible defaults."
6098
+ "Per-type config (STRICT \u2014 unknown keys are rejected). metric-chart: mark (line|bar|area|donut|stacked-bar) + metric + groupBy/series + thresholds; table: rowsAre + columns [{header, field|metric}]; stat-cards: tiles; field-distribution: fieldName+measure+chartType (required); narrative: focus; notes: content. Call list_dashboard_widgets for the full per-type vocabulary + metric/filter grammar. Omit for a sensible valid default (except field-distribution, which needs fieldName)."
6099
+ ),
6100
+ binding: import_zod17.z.record(import_zod17.z.unknown()).optional().describe(
6101
+ "Per-widget scope override: { source?, dateRange?: {preset}, filter? }. Omit any key to inherit the dashboard's value."
6102
+ ),
6103
+ layout: import_zod17.z.object({
6104
+ x: import_zod17.z.number().int().min(0).max(11),
6105
+ y: import_zod17.z.number().int().min(0).max(200),
6106
+ w: import_zod17.z.number().int().min(1).max(12),
6107
+ h: import_zod17.z.number().int().min(1).max(40)
6108
+ }).optional().describe(
6109
+ "Explicit 12-column grid position. Omit to auto-place two-per-row like the UI. Widgets must not overlap within a section group."
5833
6110
  )
5834
6111
  });
5835
- writeFields = {
5836
- description: import_zod17.z.string().max(2e3).optional().describe("Dashboard description"),
6112
+ sectionInputSchema = import_zod17.z.object({
6113
+ id: import_zod17.z.string().min(1).max(64).describe("Section id (kebab-case)"),
6114
+ title: import_zod17.z.string().min(1).max(24).describe("Section title, max 24 chars"),
6115
+ icon: import_zod17.z.string().min(1).max(40).describe('Kebab-case lucide icon name, e.g. "dollar-sign"'),
6116
+ widgetIds: import_zod17.z.array(import_zod17.z.string().max(64)).max(24).describe("Widget ids in this section \u2014 must match explicit `id`s set on widgets[]")
6117
+ });
6118
+ sourceInputSchema = import_zod17.z.object({
6119
+ type: import_zod17.z.enum(["folders", "team", "workspace"]).describe(
6120
+ "folders = specific folder ids; team = the caller's team scope; workspace = everything accessible"
6121
+ ),
6122
+ folderIds: import_zod17.z.array(import_zod17.z.string().min(1).max(64)).min(1).max(50).optional().describe('Folder ids \u2014 required when type is "folders", forbidden otherwise')
6123
+ }).describe(
6124
+ 'Data source: {type:"folders", folderIds:[...]} | {type:"team"} | {type:"workspace"}'
6125
+ );
6126
+ dateRangeInputSchema = import_zod17.z.object({
6127
+ preset: import_zod17.z.enum(DATE_RANGE_PRESETS).describe("One of: last7days | last30days | last3months | yearToDate | allTime")
6128
+ }).describe("Date range \u2014 strict preset only, no free-form start/end dates");
6129
+ metadataFields = {
5837
6130
  icon: import_zod17.z.string().max(200).optional().describe("Icon identifier"),
5838
- folderScope: import_zod17.z.array(import_zod17.z.string().max(100)).max(100).optional().describe("Folder ids to scope analytics to. Empty/omitted = all accessible folders."),
5839
6131
  assignTo: import_zod17.z.array(import_zod17.z.string()).max(100).optional().describe('User ids, or group ids in the "<groupId> (G)" convention, to share view access with'),
5840
- dateRange: import_zod17.z.object({
5841
- preset: import_zod17.z.string().max(50).optional(),
5842
- startDate: import_zod17.z.string().optional(),
5843
- endDate: import_zod17.z.string().optional()
5844
- }).optional().describe("Date range: { preset?, startDate?, endDate? }"),
5845
6132
  filters: import_zod17.z.record(import_zod17.z.unknown()).optional().describe(FILTER_LIST_DESCRIPTION),
5846
- widgets: import_zod17.z.array(widgetInputSchema).max(50).optional().describe(
5847
- "Widgets to place on the dashboard, in order. The MCP assigns ids and computes a tidy two-per-row grid layout matching the Speak UI. Just list the widget types you want."
5848
- ),
5849
6133
  isDefault: import_zod17.z.boolean().optional().describe("Make this the company default dashboard")
5850
6134
  };
6135
+ specFields = {
6136
+ description: import_zod17.z.string().max(280).optional().describe("Dashboard description, max 280 chars"),
6137
+ source: sourceInputSchema.optional(),
6138
+ dateRange: dateRangeInputSchema.optional(),
6139
+ sections: import_zod17.z.array(sectionInputSchema).max(12).optional().describe(
6140
+ "Optional named widget groups (tabs). Each references widgets by their explicit ids; widgets in no section form the implicit Overview group."
6141
+ ),
6142
+ widgets: import_zod17.z.array(widgetInputSchema).max(24).optional().describe(
6143
+ "Widgets to place on the dashboard, in order (max 24). The MCP assigns ids and computes a tidy two-per-row grid layout matching the Speak UI unless you pass explicit id/layout."
6144
+ )
6145
+ };
5851
6146
  SPEAKERS_FILTER_SCHEMA = {
5852
6147
  folderScope: import_zod17.z.array(import_zod17.z.string().max(100)).max(100).optional().describe("Folder ids to scope to"),
5853
6148
  startDate: import_zod17.z.string().optional().describe("ISO start date"),
@@ -6212,6 +6507,7 @@ var init_tool_names = __esm({
6212
6507
  "get_captions",
6213
6508
  "list_supported_languages",
6214
6509
  "update_transcript_speakers",
6510
+ "update_transcription",
6215
6511
  "bulk_update_transcript_speakers",
6216
6512
  "bulk_move_media",
6217
6513
  // meeting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speakai/mcp-server",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "mcpName": "io.github.speakai/mcp-server",
5
5
  "description": "Official Speak AI MCP Server — capture meetings, search thousands of recordings, run async voice and video surveys, create clips, and automate workflows from your AI assistant.",
6
6
  "homepage": "https://mcp.speakai.co",