farseer-cli 1.14.1 → 1.15.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 (69) hide show
  1. package/dist/commands/config.js +4 -3
  2. package/dist/commands/config.js.map +2 -2
  3. package/dist/commands/install.js +5 -0
  4. package/dist/commands/install.js.map +2 -2
  5. package/dist/commands/login.js +2 -2
  6. package/dist/commands/login.js.map +2 -2
  7. package/dist/commands/pull.js +9 -3
  8. package/dist/commands/pull.js.map +2 -2
  9. package/dist/commands/run.js +9 -0
  10. package/dist/commands/run.js.map +2 -2
  11. package/dist/index.js +7 -2
  12. package/dist/index.js.map +2 -2
  13. package/dist/mcp/tools/appTools.js.map +2 -2
  14. package/dist/mcp/tools/authTools.js +5 -3
  15. package/dist/mcp/tools/authTools.js.map +2 -2
  16. package/dist/mcp/tools/cellTools.js +3 -2
  17. package/dist/mcp/tools/cellTools.js.map +2 -2
  18. package/dist/mcp/tools/dashboardTools.js +23 -18
  19. package/dist/mcp/tools/dashboardTools.js.map +2 -2
  20. package/dist/mcp/tools/dataTools.js +13 -11
  21. package/dist/mcp/tools/dataTools.js.map +2 -2
  22. package/dist/mcp/tools/folderTools.js +5 -4
  23. package/dist/mcp/tools/folderTools.js.map +2 -2
  24. package/dist/mcp/tools/modelTools.js +27 -17
  25. package/dist/mcp/tools/modelTools.js.map +2 -2
  26. package/dist/mcp/tools/pipelineContract.js +5 -2
  27. package/dist/mcp/tools/pipelineContract.js.map +2 -2
  28. package/dist/mcp/tools/runTools.js +8 -3
  29. package/dist/mcp/tools/runTools.js.map +2 -2
  30. package/dist/mcp/tools/sheetTools.js +21 -17
  31. package/dist/mcp/tools/sheetTools.js.map +2 -2
  32. package/dist/mcp/tools/syncTools.js +11 -5
  33. package/dist/mcp/tools/syncTools.js.map +2 -2
  34. package/dist/mcp/utils/registerTool.js +32 -0
  35. package/dist/mcp/utils/registerTool.js.map +7 -0
  36. package/dist/pipeline/generated-reference.json +3 -3
  37. package/dist/pipeline/operations.js +4 -1
  38. package/dist/pipeline/operations.js.map +2 -2
  39. package/dist/pipeline/query.js +58 -40
  40. package/dist/pipeline/query.js.map +2 -2
  41. package/dist/pipeline/queryDownloads.js +72 -0
  42. package/dist/pipeline/queryDownloads.js.map +7 -0
  43. package/dist/pipeline/queryWorker.js +8 -31
  44. package/dist/pipeline/queryWorker.js.map +2 -2
  45. package/dist/pipeline/readiness.js +15 -8
  46. package/dist/pipeline/readiness.js.map +2 -2
  47. package/dist/pipeline/reference.js +2 -1
  48. package/dist/pipeline/reference.js.map +2 -2
  49. package/dist/pipeline/runtime.js +4 -3
  50. package/dist/pipeline/runtime.js.map +2 -2
  51. package/dist/pipeline/service.js +110 -50
  52. package/dist/pipeline/service.js.map +2 -2
  53. package/dist/services/appSyncService.js.map +1 -1
  54. package/dist/services/configService.js +11 -4
  55. package/dist/services/configService.js.map +2 -2
  56. package/dist/services/farseerService.js +23 -0
  57. package/dist/services/farseerService.js.map +2 -2
  58. package/dist/services/modelExport.js.map +1 -1
  59. package/dist/utils/agentSandbox.js +35 -0
  60. package/dist/utils/agentSandbox.js.map +7 -0
  61. package/dist/utils/constants.js +4 -7
  62. package/dist/utils/constants.js.map +2 -2
  63. package/dist/utils/packageManager.js +40 -11
  64. package/dist/utils/packageManager.js.map +2 -2
  65. package/dist/utils/updateCheck.js +4 -2
  66. package/dist/utils/updateCheck.js.map +2 -2
  67. package/docs/pipeline-client-guide.md +4 -4
  68. package/package.json +2 -2
  69. package/skills/pipeline-authoring/SKILL.md +5 -5
@@ -31,6 +31,7 @@ __export(dashboardTools_exports, {
31
31
  registerDashboardTools: () => registerDashboardTools
32
32
  });
33
33
  module.exports = __toCommonJS(dashboardTools_exports);
34
+ var import_registerTool = require("../utils/registerTool");
34
35
  var import_zod = require("zod");
35
36
  var farseer = __toESM(require("farseer-client"));
36
37
  var import_session = require("../utils/session");
@@ -139,7 +140,8 @@ const duplicateDashboardSchema = {
139
140
  folderPath: import_zod.z.array(import_zod.z.string()).optional().describe('Target folder path as array (e.g., ["Dashboards", "Reports"]). Alternative to folderId.')
140
141
  };
141
142
  function registerDashboardTools(server) {
142
- server.tool(
143
+ (0, import_registerTool.registerTool)(
144
+ server,
143
145
  "farseer_list_dashboards",
144
146
  `List all dashboards in a Farseer tenant.
145
147
 
@@ -178,7 +180,8 @@ Set includeFolderPath=true to also show the folder path for each dashboard
178
180
  }
179
181
  }
180
182
  );
181
- server.tool(
183
+ (0, import_registerTool.registerTool)(
184
+ server,
182
185
  "farseer_get_dashboard",
183
186
  `Get detailed information about a specific dashboard.
184
187
 
@@ -222,7 +225,8 @@ Accepts either a dashboard name or numeric ID.`,
222
225
  }
223
226
  }
224
227
  );
225
- server.tool(
228
+ (0, import_registerTool.registerTool)(
229
+ server,
226
230
  "farseer_list_tiles",
227
231
  `List all tiles for a dashboard with their types, positions, and sheet IDs.
228
232
 
@@ -265,7 +269,8 @@ Accepts either a dashboard name or numeric ID.`,
265
269
  }
266
270
  }
267
271
  );
268
- server.tool(
272
+ (0, import_registerTool.registerTool)(
273
+ server,
269
274
  "farseer_get_tile",
270
275
  `Get the full configuration of a specific tile.
271
276
 
@@ -278,7 +283,6 @@ with farseer_update_tile.
278
283
 
279
284
  Accepts either a dashboard name or numeric ID.`,
280
285
  getTileSchema,
281
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
282
286
  async (params) => {
283
287
  const gate = await (0, import_session.requireSession)();
284
288
  if (!gate.ok) return gate.response;
@@ -303,7 +307,8 @@ Accepts either a dashboard name or numeric ID.`,
303
307
  }
304
308
  }
305
309
  );
306
- server.tool(
310
+ (0, import_registerTool.registerTool)(
311
+ server,
307
312
  "farseer_create_tile",
308
313
  `Create a new tile on a dashboard.
309
314
 
@@ -320,7 +325,6 @@ Grid placements use a responsive grid system:
320
325
 
321
326
  Style options: showBackground, backgroundColor, showBorder, borderColor, hasShadow, showSubtitle, showFootnotes.`,
322
327
  createTileSchema,
323
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
324
328
  async (params) => {
325
329
  const gate = await (0, import_session.requireSession)();
326
330
  if (!gate.ok) return gate.response;
@@ -365,7 +369,8 @@ Style options: showBackground, backgroundColor, showBorder, borderColor, hasShad
365
369
  }
366
370
  }
367
371
  );
368
- server.tool(
372
+ (0, import_registerTool.registerTool)(
373
+ server,
369
374
  "farseer_update_tile",
370
375
  `Update an existing tile on a dashboard.
371
376
 
@@ -390,7 +395,6 @@ Example - update just the visualization:
390
395
 
391
396
  WARNING: This modifies dashboard configuration. Use with caution.`,
392
397
  updateTileSchema,
393
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
394
398
  async (params) => {
395
399
  const gate = await (0, import_session.requireSession)();
396
400
  if (!gate.ok) return gate.response;
@@ -437,7 +441,8 @@ WARNING: This modifies dashboard configuration. Use with caution.`,
437
441
  }
438
442
  }
439
443
  );
440
- server.tool(
444
+ (0, import_registerTool.registerTool)(
445
+ server,
441
446
  "farseer_delete_tile",
442
447
  `Delete a tile from a dashboard.
443
448
 
@@ -449,7 +454,6 @@ WARNING: This is destructive and cannot be undone.`,
449
454
  dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
450
455
  tileId: import_zod.z.number().describe("Tile ID to delete")
451
456
  },
452
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
453
457
  async (params) => {
454
458
  const gate = await (0, import_session.requireSession)();
455
459
  if (!gate.ok) return gate.response;
@@ -472,7 +476,8 @@ WARNING: This is destructive and cannot be undone.`,
472
476
  }
473
477
  }
474
478
  );
475
- server.tool(
479
+ (0, import_registerTool.registerTool)(
480
+ server,
476
481
  "farseer_create_dashboard",
477
482
  `Create a new empty dashboard.
478
483
 
@@ -488,7 +493,6 @@ If no folder is specified, creates in the root Dashboards folder.`,
488
493
  folderId: import_zod.z.number().optional().describe("Target folder ID. If omitted, uses root Dashboards folder."),
489
494
  folderPath: import_zod.z.array(import_zod.z.string()).optional().describe('Target folder path as array (e.g., ["Dashboards", "Reports"]). Alternative to folderId.')
490
495
  },
491
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
492
496
  async (params) => {
493
497
  const gate = await (0, import_session.requireSession)();
494
498
  if (!gate.ok) return gate.response;
@@ -534,7 +538,8 @@ If no folder is specified, creates in the root Dashboards folder.`,
534
538
  }
535
539
  }
536
540
  );
537
- server.tool(
541
+ (0, import_registerTool.registerTool)(
542
+ server,
538
543
  "farseer_update_dashboard",
539
544
  `Update a dashboard's configuration.
540
545
 
@@ -557,7 +562,6 @@ WARNING: This modifies dashboard configuration. Use with caution.`,
557
562
  "Dashboard fields to update. Supported: name, columns (timeline config), rows (comparison config), options."
558
563
  )
559
564
  },
560
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
561
565
  async (params) => {
562
566
  const gate = await (0, import_session.requireSession)();
563
567
  if (!gate.ok) return gate.response;
@@ -588,7 +592,8 @@ WARNING: This modifies dashboard configuration. Use with caution.`,
588
592
  }
589
593
  }
590
594
  );
591
- server.tool(
595
+ (0, import_registerTool.registerTool)(
596
+ server,
592
597
  "farseer_delete_dashboard",
593
598
  `Delete a dashboard.
594
599
 
@@ -618,7 +623,8 @@ if dashboard deletion is not supported for the tenant.`,
618
623
  }
619
624
  }
620
625
  );
621
- server.tool(
626
+ (0, import_registerTool.registerTool)(
627
+ server,
622
628
  "farseer_duplicate_dashboard",
623
629
  `Duplicate a dashboard to a new name, optionally in a specific folder.
624
630
 
@@ -627,7 +633,6 @@ Specify folderId directly or use folderPath to resolve the target folder.
627
633
 
628
634
  If no folder is specified, duplicates to the root Dashboards folder.`,
629
635
  duplicateDashboardSchema,
630
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
631
636
  async (params) => {
632
637
  const gate = await (0, import_session.requireSession)();
633
638
  if (!gate.ok) return gate.response;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mcp/tools/dashboardTools.ts"],
4
- "sourcesContent": ["/**\n * Dashboard & Tile Tools\n *\n * MCP tools for listing, inspecting, creating, and updating Farseer dashboards and tiles.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport * as farseer from 'farseer-client';\nimport { requireSession } from '../utils/session';\nimport { successResponse, errorResponse, resolveEntityForMcp } from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\nimport { collectFolderItems } from '../../utils/entityResolver';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Extract base URL and auth headers from a native client for raw API calls.\n * This bypasses the generated toJSON serialization which can strip fields.\n */\nfunction getRawApiConfig(nativeClient: farseer.FarseerClient): { basePath: string; headers: Record<string, string> } {\n // BaseAPI stores config as protected `configuration`, FarseerClient as `_configuration`\n const config =\n (nativeClient as any).dashboards?.configuration ||\n (nativeClient as any)._configuration ||\n (nativeClient as any).configuration;\n return {\n basePath: config?.basePath || '',\n headers: config?.headers || {},\n };\n}\n\n/**\n * Make a raw API call bypassing generated serialization.\n * Use this for create/update tile operations where the generated toJSON\n * strips required fields (e.g. the sheet/table field on SHEET_BACKED tiles).\n */\nasync function rawApiCall(\n nativeClient: farseer.FarseerClient,\n method: string,\n path: string,\n body?: unknown,\n): Promise<any> {\n const { basePath, headers } = getRawApiConfig(nativeClient);\n const url = `${basePath}${path}`;\n const response = await fetch(url, {\n method,\n headers: {\n ...headers,\n 'Content-Type': 'application/json',\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const text = await response.text();\n throw new Error(`HTTP ${response.status} ${response.statusText}: ${text}`);\n }\n\n const contentLength = response.headers.get('content-length');\n if (response.status === 204 || contentLength === '0') {\n return null;\n }\n\n const text = await response.text();\n return text ? JSON.parse(text) : null;\n}\n\n/**\n * Every dashboard with the folder it sits in, keyed by the dashboard's own id.\n *\n * Off the folder tree, where each entry carries two ids: its own, and\n * `reference`, the dashboard it holds. The two overlap \u2014 folder entry 87 can\n * hold dashboard 1 \u2014 so listing the entry's id hands back a number that\n * `farseer_get_dashboard` reads as a different dashboard.\n */\nasync function collectDashboardsWithPaths(\n client: farseer.FarseerClient,\n): Promise<Array<{ id: number; name: string; folderPath: string }>> {\n const items = await collectFolderItems(client, farseer.FolderItemType.Dashboard);\n return items.map((item) => ({\n id: Number(item.reference),\n name: item.name,\n folderPath: item.folderPath.join('/') || '/',\n }));\n}\n\n// ---------------------------------------------------------------------------\n// Schemas (defined outside tool registration to avoid TS2589)\n// ---------------------------------------------------------------------------\n\nconst listDashboardsSchema = {\n includeFolderPath: z\n .boolean()\n .optional()\n .describe('Include folder path for each dashboard (slower, traverses folder tree). Default: false.'),\n};\n\nconst getDashboardSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n includeTiles: z.boolean().optional().describe('Include tile details in response (default: true)'),\n};\n\nconst listTilesSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n};\n\nconst getTileSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n tileId: z.number().describe('Tile ID'),\n};\n\nconst createTileSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n tile: z.record(z.any()).describe(\n `Full tile configuration as JSON. Structure:\n{\n \"name\": \"Tile Name\",\n \"subtitle\": \"\",\n \"footnotes\": \"\",\n \"gridPlacements\": { \"lg\": { \"x\": 0, \"y\": 0, \"w\": 6, \"h\": 4 } },\n \"data\": {\n \"type\": \"TEXT\" | \"SHEET_BACKED\" | \"DIMENSION_SLICER\",\n ... type-specific fields\n },\n \"style\": { \"showBackground\": true, \"hasShadow\": true }\n}\n\nFor SHEET_BACKED tiles, data includes: useDashboardFilters, useDashboardTimeline, showTileFilters, showTileTimeline, exportConfigurationId, visualization.\nFor TEXT tiles, data includes: rawContent (rich text object).`,\n ),\n};\n\nconst updateTileSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n tileId: z.number().describe('Tile ID to update'),\n tile: z.record(z.any()).describe(\n `Full or partial tile configuration as JSON. The tool fetches the current tile first\nand deep-merges your changes, so you can pass only the fields you want to change.\nUses raw API internally (bypasses TypeScript client serialization that strips fields like table/sheet).\n\nExample - update visualization only:\n{\n \"data\": {\n \"visualization\": {\n \"rowStyles\": [...],\n \"columnVisualizationByKey\": {...}\n }\n }\n}`,\n ),\n replaceKeys: z\n .array(z.string())\n .optional()\n .describe(\n `Keys to REPLACE entirely instead of deep-merging. Use for map objects like\nrowVisualizationByPath or columnVisualizationByPath where stale keys should be cleared.\nExample: [\"rowVisualizationByPath\", \"columnVisualizationByPath\"]`,\n ),\n};\n\nconst duplicateDashboardSchema = {\n dashboardNameOrId: z.string().describe('Source dashboard name or numeric ID to duplicate'),\n name: z.string().describe('Name for the new dashboard'),\n folderId: z.number().optional().describe('Target folder ID. If omitted, duplicates to root Dashboards folder.'),\n folderPath: z\n .array(z.string())\n .optional()\n .describe('Target folder path as array (e.g., [\"Dashboards\", \"Reports\"]). Alternative to folderId.'),\n};\n\n// ---------------------------------------------------------------------------\n// Tool Registration\n// ---------------------------------------------------------------------------\n\nexport function registerDashboardTools(server: McpServer): void {\n // farseer_list_dashboards\n server.tool(\n 'farseer_list_dashboards',\n `List all dashboards in a Farseer tenant.\n\nDashboards contain tiles that display charts, tables, and other visualizations.\nReturns dashboard IDs, names, and tile counts.\n\nSet includeFolderPath=true to also show the folder path for each dashboard\n(this is slower as it traverses the folder tree).`,\n listDashboardsSchema,\n async (params: { includeFolderPath?: boolean }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n if (params.includeFolderPath) {\n // Traverse folder tree to get paths\n const dashboards = await collectDashboardsWithPaths(nativeClient);\n return successResponse({\n tenant,\n totalDashboards: dashboards.length,\n dashboards,\n });\n }\n\n // Fast path: just list dashboards\n const dashboards = await nativeClient.dashboards.list();\n const result = dashboards.map((d) => ({\n id: d.id,\n name: d.name,\n tileCount: d.tiles?.length || 0,\n }));\n\n return successResponse({\n tenant,\n totalDashboards: result.length,\n dashboards: result,\n });\n } catch (error) {\n return errorResponse(`List dashboards failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_dashboard\n server.tool(\n 'farseer_get_dashboard',\n `Get detailed information about a specific dashboard.\n\nReturns dashboard configuration and optionally its tiles.\nAccepts either a dashboard name or numeric ID.`,\n getDashboardSchema,\n async (params: { dashboardNameOrId: string; includeTiles?: boolean }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n const dashboard = await nativeClient.dashboards.get(dashRef.entity.id);\n const includeTiles = params.includeTiles !== false;\n\n const result: any = {\n id: dashboard.id,\n name: dashboard.name,\n columns: dashboard.columns,\n rows: dashboard.rows,\n options: dashboard.options,\n tileCount: dashboard.tiles?.length || 0,\n };\n\n if (includeTiles && dashboard.tiles) {\n result.tiles = dashboard.tiles.map((t: any) => ({\n id: t.id,\n name: t.name,\n type: t.type,\n position: t.position,\n size: t.size,\n }));\n }\n\n return successResponse({\n tenant,\n dashboard: result,\n });\n } catch (error) {\n return errorResponse(`Get dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_list_tiles\n server.tool(\n 'farseer_list_tiles',\n `List all tiles for a dashboard with their types, positions, and sheet IDs.\n\nReturns tile IDs, names, types (TEXT, SHEET_BACKED, DIMENSION_SLICER),\ngrid placements, and associated sheet IDs for SHEET_BACKED tiles.\n\nAccepts either a dashboard name or numeric ID.`,\n listTilesSchema,\n async (params: { dashboardNameOrId: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n const tiles = await nativeClient.dashboards.listTiles(dashRef.entity.id);\n\n const result = tiles.map((t: any) => {\n const tile: any = {\n id: t.id,\n name: t.name,\n type: t.data?.type,\n gridPlacements: t.gridPlacements,\n };\n // Include sheetId for SHEET_BACKED tiles\n if (t.data?.type === 'SHEET_BACKED' && t.data?.sheet) {\n tile.sheetId = t.data.sheet.id;\n tile.sheetName = t.data.sheet.name;\n }\n return tile;\n });\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n totalTiles: result.length,\n tiles: result,\n });\n } catch (error) {\n return errorResponse(`List tiles failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_tile\n server.tool(\n 'farseer_get_tile',\n `Get the full configuration of a specific tile.\n\nReturns the complete tile object including name, subtitle, footnotes,\ngrid placements, data (type-specific: visualization, sheet config, text content),\nand style settings.\n\nThis is essential for understanding the tile structure before modifying it\nwith farseer_update_tile.\n\nAccepts either a dashboard name or numeric ID.`,\n getTileSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: { dashboardNameOrId: string; tileId: number }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Use raw API to get the full tile without any field stripping\n const tile = await rawApiCall(\n nativeClient,\n 'GET',\n `/dashboards/${dashRef.entity.id}/tiles/${params.tileId}`,\n );\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n tile,\n });\n } catch (error) {\n return errorResponse(`Get tile failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_tile\n server.tool(\n 'farseer_create_tile',\n `Create a new tile on a dashboard.\n\nAccepts the full tile configuration as a JSON object. Uses raw API internally\nto avoid the TypeScript client's serialization issues.\n\nTile types:\n- TEXT: Rich text content tile. data = { type: \"TEXT\", rawContent: {...} }\n- SHEET_BACKED: Table/chart tile backed by a sheet. data = { type: \"SHEET_BACKED\", useDashboardFilters: true, ... }\n- DIMENSION_SLICER: Filter tile. data = { type: \"DIMENSION_SLICER\", ... }\n\nGrid placements use a responsive grid system:\n gridPlacements: { \"lg\": { \"x\": 0, \"y\": 0, \"w\": 6, \"h\": 4 } }\n\nStyle options: showBackground, backgroundColor, showBorder, borderColor, hasShadow, showSubtitle, showFootnotes.`,\n createTileSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: { dashboardNameOrId: string; tile: Record<string, any> }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Apply common defaults\n const tilePayload = { ...params.tile };\n if (tilePayload.subtitle === undefined) tilePayload.subtitle = '';\n if (tilePayload.footnotes === undefined) tilePayload.footnotes = '';\n if (tilePayload.style === undefined) tilePayload.style = {};\n if (tilePayload.data?.type === 'SHEET_BACKED') {\n const d = tilePayload.data;\n if (d.useDashboardFilters === undefined) d.useDashboardFilters = true;\n if (d.useDashboardTimeline === undefined) d.useDashboardTimeline = true;\n if (d.showTileFilters === undefined) d.showTileFilters = false;\n if (d.showTileTimeline === undefined) d.showTileTimeline = false;\n if (d.exportConfigurationId === undefined) d.exportConfigurationId = null;\n if (d.visualization === undefined) d.visualization = { type: 'TABLE' };\n }\n\n // Use raw API to bypass generated serialization that strips fields\n const result = await rawApiCall(\n nativeClient,\n 'POST',\n `/dashboards/${dashRef.entity.id}/tiles`,\n tilePayload,\n );\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n action: 'created',\n tile: {\n id: result?.id,\n name: result?.name,\n type: result?.data?.type,\n },\n message: `Tile \"${params.tile.name || 'unnamed'}\" created on dashboard \"${dashRef.entity.name}\"`,\n });\n } catch (error) {\n return errorResponse(`Create tile failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_update_tile\n server.tool(\n 'farseer_update_tile',\n `Update an existing tile on a dashboard.\n\nFetches the current tile configuration first, then deep-merges your changes\nand sends the full updated object. This means you only need to provide\nthe fields you want to change.\n\nUses raw API internally to bypass the TypeScript client's serialization\nwhich strips fields like table/sheet on SHEET_BACKED tiles.\n\nTip: Use farseer_get_tile first to see the current config, then pass\nonly the changes you need.\n\nExample - update just the visualization:\n{\n \"data\": {\n \"visualization\": {\n \"rowStyles\": [{ \"rowKey\": \"row1\", \"style\": \"bold\" }]\n }\n }\n}\n\nWARNING: This modifies dashboard configuration. Use with caution.`,\n updateTileSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: {\n dashboardNameOrId: string;\n tileId: number;\n tile: Record<string, any>;\n replaceKeys?: string[];\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Fetch current tile to merge with updates\n const currentTile = await rawApiCall(\n nativeClient,\n 'GET',\n `/dashboards/${dashRef.entity.id}/tiles/${params.tileId}`,\n );\n\n if (!currentTile) {\n return errorResponse(\n `Tile ${params.tileId} not found on dashboard \"${dashRef.entity.name}\"`,\n 'NOT_FOUND',\n );\n }\n\n // Deep merge with replace keys support.\n // Auto-replace visualization when its type changes (e.g. TABLE \u2192 CHART)\n // because chart and table configs are incompatible structures.\n const replaceSet = new Set(params.replaceKeys || []);\n const newVisType = params.tile?.data?.visualization?.type;\n const curVisType = currentTile?.data?.visualization?.type;\n if (newVisType && curVisType && newVisType !== curVisType) {\n replaceSet.add('visualization');\n }\n const merged = deepMerge(currentTile, params.tile, replaceSet);\n\n // Remove read-only id field from the update payload\n delete merged.id;\n\n await rawApiCall(\n nativeClient,\n 'PUT',\n `/dashboards/${dashRef.entity.id}/tiles/${params.tileId}`,\n merged,\n );\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n action: 'updated',\n tileId: params.tileId,\n message: `Tile ${params.tileId} updated on dashboard \"${dashRef.entity.name}\"`,\n });\n } catch (error) {\n return errorResponse(`Update tile failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_tile\n server.tool(\n 'farseer_delete_tile',\n `Delete a tile from a dashboard.\n\nPermanently removes the tile identified by its numeric ID.\nUse farseer_list_tiles to find tile IDs first.\n\nWARNING: This is destructive and cannot be undone.`,\n {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n tileId: z.number().describe('Tile ID to delete'),\n },\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: { dashboardNameOrId: string; tileId: number }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n await rawApiCall(nativeClient, 'DELETE', `/dashboards/${dashRef.entity.id}/tiles/${params.tileId}`);\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n action: 'deleted',\n tileId: params.tileId,\n message: `Tile ${params.tileId} deleted from dashboard \"${dashRef.entity.name}\"`,\n });\n } catch (error) {\n return errorResponse(`Delete tile failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_dashboard\n server.tool(\n 'farseer_create_dashboard',\n `Create a new empty dashboard.\n\nCreates a dashboard with the given name in the specified folder.\n\nNOTE: The backend does not accept columns/rows config on create.\nCreate the dashboard first, then use farseer_update_dashboard to configure\ntimeline (columns), comparison (rows), and options.\n\nIf no folder is specified, creates in the root Dashboards folder.`,\n {\n name: z.string().describe('Dashboard name'),\n folderId: z.number().optional().describe('Target folder ID. If omitted, uses root Dashboards folder.'),\n folderPath: z\n .array(z.string())\n .optional()\n .describe('Target folder path as array (e.g., [\"Dashboards\", \"Reports\"]). Alternative to folderId.'),\n },\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: { name: string; folderId?: number; folderPath?: string[] }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n // Resolve target folder\n let targetFolderId = params.folderId ?? 0;\n\n if (!params.folderId && params.folderPath && params.folderPath.length > 0) {\n const folderResults = await nativeClient.folders.search({\n name: params.folderPath[params.folderPath.length - 1],\n types: [farseer.FolderItemType.Folder],\n limit: 20,\n });\n if (folderResults.length > 0) {\n targetFolderId = folderResults[0].id;\n }\n }\n\n // If still no folder, find root Dashboards folder\n if (targetFolderId === 0) {\n const rootItems = await nativeClient.folders.listItemsBatch([{ id: null }]);\n const dashboardsFolder = rootItems[0]?.items?.find(\n (item) =>\n item.type === farseer.FolderItemType.Folder && item.name.toLowerCase() === 'dashboards',\n );\n if (dashboardsFolder) {\n targetFolderId = dashboardsFolder.id;\n }\n }\n\n const createRequest: any = {\n name: params.name,\n folderId: targetFolderId,\n };\n\n const result = await nativeClient.dashboards.create(createRequest);\n\n return successResponse({\n tenant,\n action: 'created',\n dashboard: {\n id: result.id,\n name: result.name,\n },\n folderId: targetFolderId,\n message: `Dashboard \"${params.name}\" created`,\n });\n } catch (error) {\n return errorResponse(`Create dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_update_dashboard\n server.tool(\n 'farseer_update_dashboard',\n `Update a dashboard's configuration.\n\nUpdates dashboard name, columns (timeline), rows (comparison), and options.\nUses raw API internally to avoid serialization issues with complex nested configs.\n\nFetches current dashboard first and deep-merges your changes, so you only need\nto provide the fields you want to change.\n\nExample - change name and timeline:\n{\n \"name\": \"New Dashboard Name\",\n \"columns\": { \"intervalToolbar\": { ... } }\n}\n\nWARNING: This modifies dashboard configuration. Use with caution.`,\n {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n update: z\n .record(z.any())\n .describe(\n 'Dashboard fields to update. Supported: name, columns (timeline config), rows (comparison config), options.',\n ),\n },\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: { dashboardNameOrId: string; update: Record<string, any> }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Fetch current dashboard to merge with updates\n const current = await rawApiCall(nativeClient, 'GET', `/dashboards/${dashRef.entity.id}`);\n\n // Build update payload.\n // columns, rows, options are REPLACED entirely when provided\n // (deep merge causes 400 because GET returns extra read-only fields).\n const base: any = {\n name: current.name,\n columns: current.columns,\n rows: current.rows,\n options: current.options,\n };\n const replaceSet = new Set(['columns', 'rows', 'options']);\n const merged = deepMerge(base, params.update, replaceSet);\n\n await rawApiCall(nativeClient, 'PUT', `/dashboards/${dashRef.entity.id}`, merged);\n\n return successResponse({\n tenant,\n action: 'updated',\n dashboard: { id: dashRef.entity.id, name: merged.name },\n message: `Dashboard \"${dashRef.entity.name}\" updated`,\n });\n } catch (error) {\n return errorResponse(`Update dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_dashboard\n server.tool(\n 'farseer_delete_dashboard',\n `Delete a dashboard.\n\nWARNING: This is destructive. The backend may return 405 Method Not Allowed\nif dashboard deletion is not supported for the tenant.`,\n {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n },\n async (params: { dashboardNameOrId: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n await rawApiCall(nativeClient, 'DELETE', `/dashboards/${dashRef.entity.id}`);\n\n return successResponse({\n tenant,\n action: 'deleted',\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n message: `Dashboard \"${dashRef.entity.name}\" deleted`,\n });\n } catch (error) {\n return errorResponse(`Delete dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_duplicate_dashboard\n server.tool(\n 'farseer_duplicate_dashboard',\n `Duplicate a dashboard to a new name, optionally in a specific folder.\n\nCreates a copy of the source dashboard with all its tiles.\nSpecify folderId directly or use folderPath to resolve the target folder.\n\nIf no folder is specified, duplicates to the root Dashboards folder.`,\n duplicateDashboardSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: { dashboardNameOrId: string; name: string; folderId?: number; folderPath?: string[] }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Resolve target folder\n let targetFolderId = params.folderId ?? 0;\n\n if (!params.folderId && params.folderPath && params.folderPath.length > 0) {\n // Search for the target folder by name\n const folderResults = await nativeClient.folders.search({\n name: params.folderPath[params.folderPath.length - 1],\n types: [farseer.FolderItemType.Folder],\n limit: 20,\n });\n if (folderResults.length > 0) {\n targetFolderId = folderResults[0].id;\n }\n }\n\n // If still no folder, find the root Dashboards folder\n if (targetFolderId === 0) {\n const rootItems = await nativeClient.folders.listItemsBatch([{ id: null }]);\n const dashboardsFolder = rootItems[0]?.items?.find(\n (item) =>\n item.type === farseer.FolderItemType.Folder && item.name.toLowerCase() === 'dashboards',\n );\n if (dashboardsFolder) {\n targetFolderId = dashboardsFolder.id;\n }\n }\n\n const result = await nativeClient.dashboards.duplicate({\n name: params.name,\n sourceId: dashRef.entity.id,\n folderId: targetFolderId,\n } as any);\n\n return successResponse({\n tenant,\n action: 'duplicated',\n source: { id: dashRef.entity.id, name: dashRef.entity.name },\n newDashboard: {\n id: result.id,\n name: result.name,\n },\n folderId: targetFolderId,\n message: `Dashboard \"${dashRef.entity.name}\" duplicated as \"${params.name}\"`,\n });\n } catch (error) {\n return errorResponse(`Duplicate dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n}\n\n// ---------------------------------------------------------------------------\n// Utilities\n// ---------------------------------------------------------------------------\n\n/**\n * Deep merge two objects. Arrays are replaced, not concatenated.\n * The source object's values override the target's values.\n *\n * Keys in the replaceKeys set are replaced entirely instead of deep-merged.\n * This is important for map objects like rowVisualizationByPath where stale\n * keys from the old value should not persist.\n */\nfunction deepMerge(target: any, source: any, replaceKeys?: Set<string>): any {\n if (source === null || source === undefined) return target;\n if (target === null || target === undefined) return source;\n if (typeof source !== 'object' || Array.isArray(source)) return source;\n if (typeof target !== 'object' || Array.isArray(target)) return source;\n\n const result = { ...target };\n for (const key of Object.keys(source)) {\n // If this key is in replaceKeys, replace entirely instead of merging\n if (replaceKeys?.has(key)) {\n result[key] = source[key];\n } else if (typeof source[key] === 'object' && source[key] !== null && !Array.isArray(source[key])) {\n result[key] = deepMerge(target[key], source[key], replaceKeys);\n } else {\n result[key] = source[key];\n }\n }\n return result;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAkB;AAClB,cAAyB;AACzB,qBAA+B;AAC/B,qBAAoE;AACpE,4BAAkC;AAClC,4BAAmC;AAUnC,SAAS,gBAAgB,cAA4F;AAEjH,QAAM,SACD,aAAqB,YAAY,iBACjC,aAAqB,kBACrB,aAAqB;AAC1B,SAAO;AAAA,IACH,UAAU,QAAQ,YAAY;AAAA,IAC9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AQ,EAAE,IAAI,QAAQ,OAAO,IAAI,MAAM,QAAQ,OAAO,KAAK;AAAA,UAC3D,cAAc;AAAA,YACV,IAAI,OAAO;AAAA,YACX,MAAM,OAAO;AAAA,UACjB;AAAA,UACA,UAAU;AAAA,UACV,SAAS,cAAc,QAAQ,OAAO,IAAI,oBAAoB,OAAO,IAAI;AAAA,QAC7E,CAAC;AAAA,MACL,SAAS,OAAO;AACZ,mBAAO,8BAAc,+BAA+B,UAAM,yCAAkB,KAAK,CAAC,IAAI,eAAe;AAAA,MACzG;AAAA,IACJ;AAAA,EACJ;AACJ;AAcA,SAAS,UAAU,QAAa,QAAa,aAAgC;AACzE,MAAI,WAAW,QAAQ,WAAW,OAAW,QAAO;AACpD,MAAI,WAAW,QAAQ,WAAW,OAAW,QAAO;AACpD,MAAI,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,EAAG,QAAO;AAChE,MAAI,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,EAAG,QAAO;AAEhE,QAAM,SAAS,EAAE,GAAG,OAAO;AAC3B,aAAW,OAAO,OAAO,KAAK,MAAM,GAAG;AAEnC,QAAI,aAAa,IAAI,GAAG,GAAG;AACvB,aAAO,GAAG,IAAI,OAAO,GAAG;AAAA,IAC5B,WAAW,OAAO,OAAO,GAAG,MAAM,YAAY,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,QAAQ,OAAO,GAAG,CAAC,GAAG;AAC/F,aAAO,GAAG,IAAI,UAAU,OAAO,GAAG,GAAG,OAAO,GAAG,GAAG,WAAW;AAAA,IACjE,OAAO;AACH,aAAO,GAAG,IAAI,OAAO,GAAG;AAAA,IAC5B;AAAA,EACJ;AACA,SAAO;AACX;",
4
+ "sourcesContent": ["/**\n * Dashboard & Tile Tools\n *\n * MCP tools for listing, inspecting, creating, and updating Farseer dashboards and tiles.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerTool } from '../utils/registerTool';\nimport { z } from 'zod';\nimport * as farseer from 'farseer-client';\nimport { requireSession } from '../utils/session';\nimport { successResponse, errorResponse, resolveEntityForMcp } from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\nimport { collectFolderItems } from '../../utils/entityResolver';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Extract base URL and auth headers from a native client for raw API calls.\n * This bypasses the generated toJSON serialization which can strip fields.\n */\nfunction getRawApiConfig(nativeClient: farseer.FarseerClient): { basePath: string; headers: Record<string, string> } {\n // BaseAPI stores config as protected `configuration`, FarseerClient as `_configuration`\n const config =\n (nativeClient as any).dashboards?.configuration ||\n (nativeClient as any)._configuration ||\n (nativeClient as any).configuration;\n return {\n basePath: config?.basePath || '',\n headers: config?.headers || {},\n };\n}\n\n/**\n * Make a raw API call bypassing generated serialization.\n * Use this for create/update tile operations where the generated toJSON\n * strips required fields (e.g. the sheet/table field on SHEET_BACKED tiles).\n */\nasync function rawApiCall(\n nativeClient: farseer.FarseerClient,\n method: string,\n path: string,\n body?: unknown,\n): Promise<any> {\n const { basePath, headers } = getRawApiConfig(nativeClient);\n const url = `${basePath}${path}`;\n const response = await fetch(url, {\n method,\n headers: {\n ...headers,\n 'Content-Type': 'application/json',\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const text = await response.text();\n throw new Error(`HTTP ${response.status} ${response.statusText}: ${text}`);\n }\n\n const contentLength = response.headers.get('content-length');\n if (response.status === 204 || contentLength === '0') {\n return null;\n }\n\n const text = await response.text();\n return text ? JSON.parse(text) : null;\n}\n\n/**\n * Every dashboard with the folder it sits in, keyed by the dashboard's own id.\n *\n * Off the folder tree, where each entry carries two ids: its own, and\n * `reference`, the dashboard it holds. The two overlap \u2014 folder entry 87 can\n * hold dashboard 1 \u2014 so listing the entry's id hands back a number that\n * `farseer_get_dashboard` reads as a different dashboard.\n */\nasync function collectDashboardsWithPaths(\n client: farseer.FarseerClient,\n): Promise<Array<{ id: number; name: string; folderPath: string }>> {\n const items = await collectFolderItems(client, farseer.FolderItemType.Dashboard);\n return items.map((item) => ({\n id: Number(item.reference),\n name: item.name,\n folderPath: item.folderPath.join('/') || '/',\n }));\n}\n\n// ---------------------------------------------------------------------------\n// Schemas (defined outside tool registration to avoid TS2589)\n// ---------------------------------------------------------------------------\n\nconst listDashboardsSchema = {\n includeFolderPath: z\n .boolean()\n .optional()\n .describe('Include folder path for each dashboard (slower, traverses folder tree). Default: false.'),\n};\n\nconst getDashboardSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n includeTiles: z.boolean().optional().describe('Include tile details in response (default: true)'),\n};\n\nconst listTilesSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n};\n\nconst getTileSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n tileId: z.number().describe('Tile ID'),\n};\n\nconst createTileSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n tile: z.record(z.any()).describe(\n `Full tile configuration as JSON. Structure:\n{\n \"name\": \"Tile Name\",\n \"subtitle\": \"\",\n \"footnotes\": \"\",\n \"gridPlacements\": { \"lg\": { \"x\": 0, \"y\": 0, \"w\": 6, \"h\": 4 } },\n \"data\": {\n \"type\": \"TEXT\" | \"SHEET_BACKED\" | \"DIMENSION_SLICER\",\n ... type-specific fields\n },\n \"style\": { \"showBackground\": true, \"hasShadow\": true }\n}\n\nFor SHEET_BACKED tiles, data includes: useDashboardFilters, useDashboardTimeline, showTileFilters, showTileTimeline, exportConfigurationId, visualization.\nFor TEXT tiles, data includes: rawContent (rich text object).`,\n ),\n};\n\nconst updateTileSchema = {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n tileId: z.number().describe('Tile ID to update'),\n tile: z.record(z.any()).describe(\n `Full or partial tile configuration as JSON. The tool fetches the current tile first\nand deep-merges your changes, so you can pass only the fields you want to change.\nUses raw API internally (bypasses TypeScript client serialization that strips fields like table/sheet).\n\nExample - update visualization only:\n{\n \"data\": {\n \"visualization\": {\n \"rowStyles\": [...],\n \"columnVisualizationByKey\": {...}\n }\n }\n}`,\n ),\n replaceKeys: z\n .array(z.string())\n .optional()\n .describe(\n `Keys to REPLACE entirely instead of deep-merging. Use for map objects like\nrowVisualizationByPath or columnVisualizationByPath where stale keys should be cleared.\nExample: [\"rowVisualizationByPath\", \"columnVisualizationByPath\"]`,\n ),\n};\n\nconst duplicateDashboardSchema = {\n dashboardNameOrId: z.string().describe('Source dashboard name or numeric ID to duplicate'),\n name: z.string().describe('Name for the new dashboard'),\n folderId: z.number().optional().describe('Target folder ID. If omitted, duplicates to root Dashboards folder.'),\n folderPath: z\n .array(z.string())\n .optional()\n .describe('Target folder path as array (e.g., [\"Dashboards\", \"Reports\"]). Alternative to folderId.'),\n};\n\n// ---------------------------------------------------------------------------\n// Tool Registration\n// ---------------------------------------------------------------------------\n\nexport function registerDashboardTools(server: McpServer): void {\n // farseer_list_dashboards\n registerTool(\n server,\n 'farseer_list_dashboards',\n `List all dashboards in a Farseer tenant.\n\nDashboards contain tiles that display charts, tables, and other visualizations.\nReturns dashboard IDs, names, and tile counts.\n\nSet includeFolderPath=true to also show the folder path for each dashboard\n(this is slower as it traverses the folder tree).`,\n listDashboardsSchema,\n async (params: { includeFolderPath?: boolean }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n if (params.includeFolderPath) {\n // Traverse folder tree to get paths\n const dashboards = await collectDashboardsWithPaths(nativeClient);\n return successResponse({\n tenant,\n totalDashboards: dashboards.length,\n dashboards,\n });\n }\n\n // Fast path: just list dashboards\n const dashboards = await nativeClient.dashboards.list();\n const result = dashboards.map((d) => ({\n id: d.id,\n name: d.name,\n tileCount: d.tiles?.length || 0,\n }));\n\n return successResponse({\n tenant,\n totalDashboards: result.length,\n dashboards: result,\n });\n } catch (error) {\n return errorResponse(`List dashboards failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_dashboard\n registerTool(\n server,\n 'farseer_get_dashboard',\n `Get detailed information about a specific dashboard.\n\nReturns dashboard configuration and optionally its tiles.\nAccepts either a dashboard name or numeric ID.`,\n getDashboardSchema,\n async (params: { dashboardNameOrId: string; includeTiles?: boolean }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n const dashboard = await nativeClient.dashboards.get(dashRef.entity.id);\n const includeTiles = params.includeTiles !== false;\n\n const result: any = {\n id: dashboard.id,\n name: dashboard.name,\n columns: dashboard.columns,\n rows: dashboard.rows,\n options: dashboard.options,\n tileCount: dashboard.tiles?.length || 0,\n };\n\n if (includeTiles && dashboard.tiles) {\n result.tiles = dashboard.tiles.map((t: any) => ({\n id: t.id,\n name: t.name,\n type: t.type,\n position: t.position,\n size: t.size,\n }));\n }\n\n return successResponse({\n tenant,\n dashboard: result,\n });\n } catch (error) {\n return errorResponse(`Get dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_list_tiles\n registerTool(\n server,\n 'farseer_list_tiles',\n `List all tiles for a dashboard with their types, positions, and sheet IDs.\n\nReturns tile IDs, names, types (TEXT, SHEET_BACKED, DIMENSION_SLICER),\ngrid placements, and associated sheet IDs for SHEET_BACKED tiles.\n\nAccepts either a dashboard name or numeric ID.`,\n listTilesSchema,\n async (params: { dashboardNameOrId: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n const tiles = await nativeClient.dashboards.listTiles(dashRef.entity.id);\n\n const result = tiles.map((t: any) => {\n const tile: any = {\n id: t.id,\n name: t.name,\n type: t.data?.type,\n gridPlacements: t.gridPlacements,\n };\n // Include sheetId for SHEET_BACKED tiles\n if (t.data?.type === 'SHEET_BACKED' && t.data?.sheet) {\n tile.sheetId = t.data.sheet.id;\n tile.sheetName = t.data.sheet.name;\n }\n return tile;\n });\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n totalTiles: result.length,\n tiles: result,\n });\n } catch (error) {\n return errorResponse(`List tiles failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_tile\n registerTool(\n server,\n 'farseer_get_tile',\n `Get the full configuration of a specific tile.\n\nReturns the complete tile object including name, subtitle, footnotes,\ngrid placements, data (type-specific: visualization, sheet config, text content),\nand style settings.\n\nThis is essential for understanding the tile structure before modifying it\nwith farseer_update_tile.\n\nAccepts either a dashboard name or numeric ID.`,\n getTileSchema,\n async (params: { dashboardNameOrId: string; tileId: number }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Use raw API to get the full tile without any field stripping\n const tile = await rawApiCall(\n nativeClient,\n 'GET',\n `/dashboards/${dashRef.entity.id}/tiles/${params.tileId}`,\n );\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n tile,\n });\n } catch (error) {\n return errorResponse(`Get tile failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_tile\n registerTool(\n server,\n 'farseer_create_tile',\n `Create a new tile on a dashboard.\n\nAccepts the full tile configuration as a JSON object. Uses raw API internally\nto avoid the TypeScript client's serialization issues.\n\nTile types:\n- TEXT: Rich text content tile. data = { type: \"TEXT\", rawContent: {...} }\n- SHEET_BACKED: Table/chart tile backed by a sheet. data = { type: \"SHEET_BACKED\", useDashboardFilters: true, ... }\n- DIMENSION_SLICER: Filter tile. data = { type: \"DIMENSION_SLICER\", ... }\n\nGrid placements use a responsive grid system:\n gridPlacements: { \"lg\": { \"x\": 0, \"y\": 0, \"w\": 6, \"h\": 4 } }\n\nStyle options: showBackground, backgroundColor, showBorder, borderColor, hasShadow, showSubtitle, showFootnotes.`,\n createTileSchema,\n async (params: { dashboardNameOrId: string; tile: Record<string, any> }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Apply common defaults\n const tilePayload = { ...params.tile };\n if (tilePayload.subtitle === undefined) tilePayload.subtitle = '';\n if (tilePayload.footnotes === undefined) tilePayload.footnotes = '';\n if (tilePayload.style === undefined) tilePayload.style = {};\n if (tilePayload.data?.type === 'SHEET_BACKED') {\n const d = tilePayload.data;\n if (d.useDashboardFilters === undefined) d.useDashboardFilters = true;\n if (d.useDashboardTimeline === undefined) d.useDashboardTimeline = true;\n if (d.showTileFilters === undefined) d.showTileFilters = false;\n if (d.showTileTimeline === undefined) d.showTileTimeline = false;\n if (d.exportConfigurationId === undefined) d.exportConfigurationId = null;\n if (d.visualization === undefined) d.visualization = { type: 'TABLE' };\n }\n\n // Use raw API to bypass generated serialization that strips fields\n const result = await rawApiCall(\n nativeClient,\n 'POST',\n `/dashboards/${dashRef.entity.id}/tiles`,\n tilePayload,\n );\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n action: 'created',\n tile: {\n id: result?.id,\n name: result?.name,\n type: result?.data?.type,\n },\n message: `Tile \"${params.tile.name || 'unnamed'}\" created on dashboard \"${dashRef.entity.name}\"`,\n });\n } catch (error) {\n return errorResponse(`Create tile failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_update_tile\n registerTool(\n server,\n 'farseer_update_tile',\n `Update an existing tile on a dashboard.\n\nFetches the current tile configuration first, then deep-merges your changes\nand sends the full updated object. This means you only need to provide\nthe fields you want to change.\n\nUses raw API internally to bypass the TypeScript client's serialization\nwhich strips fields like table/sheet on SHEET_BACKED tiles.\n\nTip: Use farseer_get_tile first to see the current config, then pass\nonly the changes you need.\n\nExample - update just the visualization:\n{\n \"data\": {\n \"visualization\": {\n \"rowStyles\": [{ \"rowKey\": \"row1\", \"style\": \"bold\" }]\n }\n }\n}\n\nWARNING: This modifies dashboard configuration. Use with caution.`,\n updateTileSchema,\n async (params: {\n dashboardNameOrId: string;\n tileId: number;\n tile: Record<string, any>;\n replaceKeys?: string[];\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Fetch current tile to merge with updates\n const currentTile = await rawApiCall(\n nativeClient,\n 'GET',\n `/dashboards/${dashRef.entity.id}/tiles/${params.tileId}`,\n );\n\n if (!currentTile) {\n return errorResponse(\n `Tile ${params.tileId} not found on dashboard \"${dashRef.entity.name}\"`,\n 'NOT_FOUND',\n );\n }\n\n // Deep merge with replace keys support.\n // Auto-replace visualization when its type changes (e.g. TABLE \u2192 CHART)\n // because chart and table configs are incompatible structures.\n const replaceSet = new Set(params.replaceKeys || []);\n const newVisType = params.tile?.data?.visualization?.type;\n const curVisType = currentTile?.data?.visualization?.type;\n if (newVisType && curVisType && newVisType !== curVisType) {\n replaceSet.add('visualization');\n }\n const merged = deepMerge(currentTile, params.tile, replaceSet);\n\n // Remove read-only id field from the update payload\n delete merged.id;\n\n await rawApiCall(\n nativeClient,\n 'PUT',\n `/dashboards/${dashRef.entity.id}/tiles/${params.tileId}`,\n merged,\n );\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n action: 'updated',\n tileId: params.tileId,\n message: `Tile ${params.tileId} updated on dashboard \"${dashRef.entity.name}\"`,\n });\n } catch (error) {\n return errorResponse(`Update tile failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_tile\n registerTool(\n server,\n 'farseer_delete_tile',\n `Delete a tile from a dashboard.\n\nPermanently removes the tile identified by its numeric ID.\nUse farseer_list_tiles to find tile IDs first.\n\nWARNING: This is destructive and cannot be undone.`,\n {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n tileId: z.number().describe('Tile ID to delete'),\n },\n async (params: { dashboardNameOrId: string; tileId: number }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n await rawApiCall(nativeClient, 'DELETE', `/dashboards/${dashRef.entity.id}/tiles/${params.tileId}`);\n\n return successResponse({\n tenant,\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n action: 'deleted',\n tileId: params.tileId,\n message: `Tile ${params.tileId} deleted from dashboard \"${dashRef.entity.name}\"`,\n });\n } catch (error) {\n return errorResponse(`Delete tile failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_dashboard\n registerTool(\n server,\n 'farseer_create_dashboard',\n `Create a new empty dashboard.\n\nCreates a dashboard with the given name in the specified folder.\n\nNOTE: The backend does not accept columns/rows config on create.\nCreate the dashboard first, then use farseer_update_dashboard to configure\ntimeline (columns), comparison (rows), and options.\n\nIf no folder is specified, creates in the root Dashboards folder.`,\n {\n name: z.string().describe('Dashboard name'),\n folderId: z.number().optional().describe('Target folder ID. If omitted, uses root Dashboards folder.'),\n folderPath: z\n .array(z.string())\n .optional()\n .describe('Target folder path as array (e.g., [\"Dashboards\", \"Reports\"]). Alternative to folderId.'),\n },\n async (params: { name: string; folderId?: number; folderPath?: string[] }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n // Resolve target folder\n let targetFolderId = params.folderId ?? 0;\n\n if (!params.folderId && params.folderPath && params.folderPath.length > 0) {\n const folderResults = await nativeClient.folders.search({\n name: params.folderPath[params.folderPath.length - 1],\n types: [farseer.FolderItemType.Folder],\n limit: 20,\n });\n if (folderResults.length > 0) {\n targetFolderId = folderResults[0].id;\n }\n }\n\n // If still no folder, find root Dashboards folder\n if (targetFolderId === 0) {\n const rootItems = await nativeClient.folders.listItemsBatch([{ id: null }]);\n const dashboardsFolder = rootItems[0]?.items?.find(\n (item) =>\n item.type === farseer.FolderItemType.Folder && item.name.toLowerCase() === 'dashboards',\n );\n if (dashboardsFolder) {\n targetFolderId = dashboardsFolder.id;\n }\n }\n\n const createRequest: any = {\n name: params.name,\n folderId: targetFolderId,\n };\n\n const result = await nativeClient.dashboards.create(createRequest);\n\n return successResponse({\n tenant,\n action: 'created',\n dashboard: {\n id: result.id,\n name: result.name,\n },\n folderId: targetFolderId,\n message: `Dashboard \"${params.name}\" created`,\n });\n } catch (error) {\n return errorResponse(`Create dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_update_dashboard\n registerTool(\n server,\n 'farseer_update_dashboard',\n `Update a dashboard's configuration.\n\nUpdates dashboard name, columns (timeline), rows (comparison), and options.\nUses raw API internally to avoid serialization issues with complex nested configs.\n\nFetches current dashboard first and deep-merges your changes, so you only need\nto provide the fields you want to change.\n\nExample - change name and timeline:\n{\n \"name\": \"New Dashboard Name\",\n \"columns\": { \"intervalToolbar\": { ... } }\n}\n\nWARNING: This modifies dashboard configuration. Use with caution.`,\n {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n update: z\n .record(z.any())\n .describe(\n 'Dashboard fields to update. Supported: name, columns (timeline config), rows (comparison config), options.',\n ),\n },\n async (params: { dashboardNameOrId: string; update: Record<string, any> }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Fetch current dashboard to merge with updates\n const current = await rawApiCall(nativeClient, 'GET', `/dashboards/${dashRef.entity.id}`);\n\n // Build update payload.\n // columns, rows, options are REPLACED entirely when provided\n // (deep merge causes 400 because GET returns extra read-only fields).\n const base: any = {\n name: current.name,\n columns: current.columns,\n rows: current.rows,\n options: current.options,\n };\n const replaceSet = new Set(['columns', 'rows', 'options']);\n const merged = deepMerge(base, params.update, replaceSet);\n\n await rawApiCall(nativeClient, 'PUT', `/dashboards/${dashRef.entity.id}`, merged);\n\n return successResponse({\n tenant,\n action: 'updated',\n dashboard: { id: dashRef.entity.id, name: merged.name },\n message: `Dashboard \"${dashRef.entity.name}\" updated`,\n });\n } catch (error) {\n return errorResponse(`Update dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_dashboard\n registerTool(\n server,\n 'farseer_delete_dashboard',\n `Delete a dashboard.\n\nWARNING: This is destructive. The backend may return 405 Method Not Allowed\nif dashboard deletion is not supported for the tenant.`,\n {\n dashboardNameOrId: z.string().describe('Dashboard name or numeric ID'),\n },\n async (params: { dashboardNameOrId: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n await rawApiCall(nativeClient, 'DELETE', `/dashboards/${dashRef.entity.id}`);\n\n return successResponse({\n tenant,\n action: 'deleted',\n dashboard: { id: dashRef.entity.id, name: dashRef.entity.name },\n message: `Dashboard \"${dashRef.entity.name}\" deleted`,\n });\n } catch (error) {\n return errorResponse(`Delete dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_duplicate_dashboard\n registerTool(\n server,\n 'farseer_duplicate_dashboard',\n `Duplicate a dashboard to a new name, optionally in a specific folder.\n\nCreates a copy of the source dashboard with all its tiles.\nSpecify folderId directly or use folderPath to resolve the target folder.\n\nIf no folder is specified, duplicates to the root Dashboards folder.`,\n duplicateDashboardSchema,\n async (params: { dashboardNameOrId: string; name: string; folderId?: number; folderPath?: string[] }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const dashRef = await resolveEntityForMcp(nativeClient, 'dashboard', params.dashboardNameOrId);\n if ('error' in dashRef) {\n return dashRef.error;\n }\n\n // Resolve target folder\n let targetFolderId = params.folderId ?? 0;\n\n if (!params.folderId && params.folderPath && params.folderPath.length > 0) {\n // Search for the target folder by name\n const folderResults = await nativeClient.folders.search({\n name: params.folderPath[params.folderPath.length - 1],\n types: [farseer.FolderItemType.Folder],\n limit: 20,\n });\n if (folderResults.length > 0) {\n targetFolderId = folderResults[0].id;\n }\n }\n\n // If still no folder, find the root Dashboards folder\n if (targetFolderId === 0) {\n const rootItems = await nativeClient.folders.listItemsBatch([{ id: null }]);\n const dashboardsFolder = rootItems[0]?.items?.find(\n (item) =>\n item.type === farseer.FolderItemType.Folder && item.name.toLowerCase() === 'dashboards',\n );\n if (dashboardsFolder) {\n targetFolderId = dashboardsFolder.id;\n }\n }\n\n const result = await nativeClient.dashboards.duplicate({\n name: params.name,\n sourceId: dashRef.entity.id,\n folderId: targetFolderId,\n } as any);\n\n return successResponse({\n tenant,\n action: 'duplicated',\n source: { id: dashRef.entity.id, name: dashRef.entity.name },\n newDashboard: {\n id: result.id,\n name: result.name,\n },\n folderId: targetFolderId,\n message: `Dashboard \"${dashRef.entity.name}\" duplicated as \"${params.name}\"`,\n });\n } catch (error) {\n return errorResponse(`Duplicate dashboard failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n}\n\n// ---------------------------------------------------------------------------\n// Utilities\n// ---------------------------------------------------------------------------\n\n/**\n * Deep merge two objects. Arrays are replaced, not concatenated.\n * The source object's values override the target's values.\n *\n * Keys in the replaceKeys set are replaced entirely instead of deep-merged.\n * This is important for map objects like rowVisualizationByPath where stale\n * keys from the old value should not persist.\n */\nfunction deepMerge(target: any, source: any, replaceKeys?: Set<string>): any {\n if (source === null || source === undefined) return target;\n if (target === null || target === undefined) return source;\n if (typeof source !== 'object' || Array.isArray(source)) return source;\n if (typeof target !== 'object' || Array.isArray(target)) return source;\n\n const result = { ...target };\n for (const key of Object.keys(source)) {\n // If this key is in replaceKeys, replace entirely instead of merging\n if (replaceKeys?.has(key)) {\n result[key] = source[key];\n } else if (typeof source[key] === 'object' && source[key] !== null && !Array.isArray(source[key])) {\n result[key] = deepMerge(target[key], source[key], replaceKeys);\n } else {\n result[key] = source[key];\n }\n }\n return result;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,0BAA6B;AAC7B,iBAAkB;AAClB,cAAyB;AACzB,qBAA+B;AAC/B,qBAAoE;AACpE,4BAAkC;AAClC,4BAAmC;AAUnC,SAAS,gBAAgB,cAA4F;AAEjH,QAAM,SACD,aAAqB,YAAY,iBACjC,aAAqB,kBACrB,aAAqB;AAC1B,SAAO;AAAA,IACH,UAAU,QAAQ,YAAY;AAAA,IAC9B,SAAS,QAAQ,WAAW,CAAC;AAAA,EACjC;AACJ;AAOA,eAAe,WACX,cACA,QACA,MACA,MACY;AACZ,QAAM,EAAE,UAAU,QAAQ,IAAI,gBAAgB,YAAY;AAC1D,QAAM,MAAM,GAAG,QAAQ,GAAG,IAAI;AAC9B,QAAM,WAAW,MAAM,MAAM,KAAK;AAAA,IAC9B;AAAA,IACA,SAAS;AAAA,MACL,GAAG;AAAA,MACH,gBAAgB;AAAA,IACpB;AAAA,IACA,MAAM,SAAS,SAAY,KAAK,UAAU,IAAI,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;AAAA,IACJ;AAAA,EACJ;AACJ;AAcA,SAAS,UAAU,QAAa,QAAa,aAAgC;AACzE,MAAI,WAAW,QAAQ,WAAW,OAAW,QAAO;AACpD,MAAI,WAAW,QAAQ,WAAW,OAAW,QAAO;AACpD,MAAI,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,EAAG,QAAO;AAChE,MAAI,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,EAAG,QAAO;AAEhE,QAAM,SAAS,EAAE,GAAG,OAAO;AAC3B,aAAW,OAAO,OAAO,KAAK,MAAM,GAAG;AAEnC,QAAI,aAAa,IAAI,GAAG,GAAG;AACvB,aAAO,GAAG,IAAI,OAAO,GAAG;AAAA,IAC5B,WAAW,OAAO,OAAO,GAAG,MAAM,YAAY,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,QAAQ,OAAO,GAAG,CAAC,GAAG;AAC/F,aAAO,GAAG,IAAI,UAAU,OAAO,GAAG,GAAG,OAAO,GAAG,GAAG,WAAW;AAAA,IACjE,OAAO;AACH,aAAO,GAAG,IAAI,OAAO,GAAG;AAAA,IAC5B;AAAA,EACJ;AACA,SAAO;AACX;",
6
6
  "names": ["text", "dashboards"]
7
7
  }
@@ -31,6 +31,7 @@ __export(dataTools_exports, {
31
31
  registerDataTools: () => registerDataTools
32
32
  });
33
33
  module.exports = __toCommonJS(dataTools_exports);
34
+ var import_registerTool = require("../utils/registerTool");
34
35
  var import_zod = require("zod");
35
36
  var fs = __toESM(require("fs"));
36
37
  var path = __toESM(require("path"));
@@ -80,7 +81,8 @@ const createFileSchema = {
80
81
  content: import_zod.z.string().describe("File content as text string")
81
82
  };
82
83
  function registerDataTools(server) {
83
- server.tool(
84
+ (0, import_registerTool.registerTool)(
85
+ server,
84
86
  "farseer_export_variable_data",
85
87
  `Export data from a Farseer variable as CSV.
86
88
 
@@ -93,7 +95,6 @@ use the Read tool to inspect the file contents.
93
95
 
94
96
  Use the 'limit' parameter to restrict row count for large variables.`,
95
97
  exportVariableDataSchema,
96
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
97
98
  async (params) => {
98
99
  const gate = await (0, import_session.requireSession)();
99
100
  if (!gate.ok) return gate.response;
@@ -131,7 +132,8 @@ Use the 'limit' parameter to restrict row count for large variables.`,
131
132
  }
132
133
  }
133
134
  );
134
- server.tool(
135
+ (0, import_registerTool.registerTool)(
136
+ server,
135
137
  "farseer_load_variable_data",
136
138
  `Load data from a Farseer variable into a structured CSV format.
137
139
 
@@ -145,7 +147,6 @@ Example usage:
145
147
  - Load "Revenue" data (all dimensions)
146
148
  - Load "Revenue" with dimensions ["Product", "Years", "Months"]`,
147
149
  loadVariableDataSchema,
148
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
149
150
  async (params) => {
150
151
  const gate = await (0, import_session.requireSession)();
151
152
  if (!gate.ok) return gate.response;
@@ -183,7 +184,8 @@ Example usage:
183
184
  }
184
185
  }
185
186
  );
186
- server.tool(
187
+ (0, import_registerTool.registerTool)(
188
+ server,
187
189
  "farseer_create_import_job",
188
190
  `Create and execute a complete data import job on a Farseer instance.
189
191
 
@@ -224,7 +226,6 @@ Example columns for importing revenue data:
224
226
  }
225
227
  ]`,
226
228
  createImportJobSchema,
227
- // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
228
229
  async (params) => {
229
230
  const gate = await (0, import_session.requireSession)();
230
231
  if (!gate.ok) return gate.response;
@@ -306,7 +307,8 @@ Example columns for importing revenue data:
306
307
  }
307
308
  }
308
309
  );
309
- server.tool(
310
+ (0, import_registerTool.registerTool)(
311
+ server,
310
312
  "farseer_create_file",
311
313
  `Create or update a file on a Farseer instance.
312
314
 
@@ -332,10 +334,10 @@ Common use cases:
332
334
  return (0, import_helpers.errorResponse)(`Folder "${folderPath.join("/")}" not found`, "NOT_FOUND");
333
335
  }
334
336
  const buffer = Buffer.from(params.content, "utf-8");
335
- await nativeClient.createOrUpdateFarseerFile(
336
- { name: params.fileName, folderId: folder.id },
337
- buffer
338
- );
337
+ const items = await nativeClient.getFolderItems(folder.id);
338
+ const existing = items.find((item) => item.name === params.fileName);
339
+ if (existing) await nativeClient.createOrUpdateFarseerFile(existing, buffer);
340
+ else await client.createFile(buffer, params.fileName, folderPath);
339
341
  return (0, import_helpers.successResponse)({
340
342
  tenant,
341
343
  fileName: params.fileName,