farseer-cli 1.1.3 → 1.3.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.
- package/dist/commands/model.js +0 -3
- package/dist/commands/model.js.map +2 -2
- package/dist/commands/pull.js +7 -1
- package/dist/commands/pull.js.map +2 -2
- package/dist/commands/push.js +12 -1
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/run.js +96 -0
- package/dist/commands/run.js.map +2 -2
- package/dist/commands/variables.js +0 -3
- package/dist/commands/variables.js.map +2 -2
- package/dist/index.js +3 -0
- package/dist/index.js.map +2 -2
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/index.js.map +2 -2
- package/dist/mcp/server.js +2 -0
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/tools/dashboardTools.js +646 -9
- package/dist/mcp/tools/dashboardTools.js.map +3 -3
- package/dist/mcp/tools/folderTools.js +154 -0
- package/dist/mcp/tools/folderTools.js.map +7 -0
- package/dist/mcp/tools/modelTools.js +258 -9
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/runTools.js +42 -0
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +312 -0
- package/dist/mcp/tools/sheetTools.js.map +2 -2
- package/dist/mcp/utils/helpers.js +2 -0
- package/dist/mcp/utils/helpers.js.map +2 -2
- package/dist/services/farseerApi.js +44 -12
- package/dist/services/farseerApi.js.map +2 -2
- package/dist/services/farseerService.js +29 -6
- package/dist/services/farseerService.js.map +2 -2
- package/dist/utils/fileLogger.js +225 -0
- package/dist/utils/fileLogger.js.map +7 -0
- package/package.json +7 -4
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var dashboardTools_exports = {};
|
|
20
30
|
__export(dashboardTools_exports, {
|
|
@@ -22,12 +32,67 @@ __export(dashboardTools_exports, {
|
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(dashboardTools_exports);
|
|
24
34
|
var import_zod = require("zod");
|
|
35
|
+
var farseer = __toESM(require("farseer-client"));
|
|
25
36
|
var import_farseerFactory = require("../../services/farseerFactory");
|
|
26
37
|
var import_entityResolver = require("../../utils/entityResolver");
|
|
27
38
|
var import_helpers = require("../utils/helpers");
|
|
39
|
+
async function extractErrorMessage(error) {
|
|
40
|
+
if (error instanceof Error) return error.message;
|
|
41
|
+
if (error && typeof error === "object" && "status" in error && "statusText" in error) {
|
|
42
|
+
const resp = error;
|
|
43
|
+
const body = resp.text ? await resp.text() : "";
|
|
44
|
+
return `HTTP ${resp.status} ${resp.statusText}${body ? ": " + body : ""}`;
|
|
45
|
+
}
|
|
46
|
+
return String(error);
|
|
47
|
+
}
|
|
48
|
+
function getRawApiConfig(nativeClient) {
|
|
49
|
+
const config = nativeClient.dashboards?.configuration || nativeClient._configuration || nativeClient.configuration;
|
|
50
|
+
return {
|
|
51
|
+
basePath: config?.basePath || "",
|
|
52
|
+
headers: config?.headers || {}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async function rawApiCall(nativeClient, method, path, body) {
|
|
56
|
+
const { basePath, headers } = getRawApiConfig(nativeClient);
|
|
57
|
+
const url = `${basePath}${path}`;
|
|
58
|
+
const response = await fetch(url, {
|
|
59
|
+
method,
|
|
60
|
+
headers: {
|
|
61
|
+
...headers,
|
|
62
|
+
"Content-Type": "application/json"
|
|
63
|
+
},
|
|
64
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
65
|
+
});
|
|
66
|
+
if (!response.ok) {
|
|
67
|
+
const text2 = await response.text();
|
|
68
|
+
throw new Error(`HTTP ${response.status} ${response.statusText}: ${text2}`);
|
|
69
|
+
}
|
|
70
|
+
const contentLength = response.headers.get("content-length");
|
|
71
|
+
if (response.status === 204 || contentLength === "0") {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const text = await response.text();
|
|
75
|
+
return text ? JSON.parse(text) : null;
|
|
76
|
+
}
|
|
77
|
+
async function collectDashboardsWithPaths(client, folderId, currentPath) {
|
|
78
|
+
const items = [];
|
|
79
|
+
const results = await client.folders.listItemsBatch([{ id: folderId }]);
|
|
80
|
+
const children = results[0]?.items ?? [];
|
|
81
|
+
for (const child of children) {
|
|
82
|
+
if (child.type === farseer.FolderItemType.Dashboard) {
|
|
83
|
+
items.push({ id: child.id, name: child.name, folderPath: currentPath || "/" });
|
|
84
|
+
} else if (child.type === farseer.FolderItemType.Folder) {
|
|
85
|
+
const subPath = currentPath ? `${currentPath}/${child.name}` : child.name;
|
|
86
|
+
const sub = await collectDashboardsWithPaths(client, child.id, subPath);
|
|
87
|
+
items.push(...sub);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return items;
|
|
91
|
+
}
|
|
28
92
|
const listDashboardsSchema = {
|
|
29
93
|
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
30
|
-
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted.")
|
|
94
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
95
|
+
includeFolderPath: import_zod.z.boolean().optional().describe("Include folder path for each dashboard (slower, traverses folder tree). Default: false.")
|
|
31
96
|
};
|
|
32
97
|
const getDashboardSchema = {
|
|
33
98
|
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
@@ -35,15 +100,73 @@ const getDashboardSchema = {
|
|
|
35
100
|
dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
|
|
36
101
|
includeTiles: import_zod.z.boolean().optional().describe("Include tile details in response (default: true)")
|
|
37
102
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
103
|
+
const listTilesSchema = {
|
|
104
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
105
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
106
|
+
dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID")
|
|
107
|
+
};
|
|
108
|
+
const getTileSchema = {
|
|
109
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
110
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
111
|
+
dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
|
|
112
|
+
tileId: import_zod.z.number().describe("Tile ID")
|
|
113
|
+
};
|
|
114
|
+
const createTileSchema = {
|
|
115
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
116
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
117
|
+
dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
|
|
118
|
+
tile: import_zod.z.record(import_zod.z.any()).describe(
|
|
119
|
+
`Full tile configuration as JSON. Structure:
|
|
120
|
+
{
|
|
121
|
+
"name": "Tile Name",
|
|
122
|
+
"subtitle": "",
|
|
123
|
+
"footnotes": "",
|
|
124
|
+
"gridPlacements": { "lg": { "x": 0, "y": 0, "w": 6, "h": 4 } },
|
|
125
|
+
"data": {
|
|
126
|
+
"type": "TEXT" | "SHEET_BACKED" | "DIMENSION_SLICER",
|
|
127
|
+
... type-specific fields
|
|
128
|
+
},
|
|
129
|
+
"style": { "showBackground": true, "hasShadow": true }
|
|
46
130
|
}
|
|
131
|
+
|
|
132
|
+
For SHEET_BACKED tiles, data includes: useDashboardFilters, useDashboardTimeline, showTileFilters, showTileTimeline, exportConfigurationId, visualization.
|
|
133
|
+
For TEXT tiles, data includes: rawContent (rich text object).`
|
|
134
|
+
)
|
|
135
|
+
};
|
|
136
|
+
const updateTileSchema = {
|
|
137
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
138
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
139
|
+
dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
|
|
140
|
+
tileId: import_zod.z.number().describe("Tile ID to update"),
|
|
141
|
+
tile: import_zod.z.record(import_zod.z.any()).describe(
|
|
142
|
+
`Full or partial tile configuration as JSON. The tool fetches the current tile first
|
|
143
|
+
and deep-merges your changes, so you can pass only the fields you want to change.
|
|
144
|
+
Uses raw API internally (bypasses TypeScript client serialization that strips fields like table/sheet).
|
|
145
|
+
|
|
146
|
+
Example - update visualization only:
|
|
147
|
+
{
|
|
148
|
+
"data": {
|
|
149
|
+
"visualization": {
|
|
150
|
+
"rowStyles": [...],
|
|
151
|
+
"columnVisualizationByKey": {...}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}`
|
|
155
|
+
),
|
|
156
|
+
replaceKeys: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
157
|
+
`Keys to REPLACE entirely instead of deep-merging. Use for map objects like
|
|
158
|
+
rowVisualizationByPath or columnVisualizationByPath where stale keys should be cleared.
|
|
159
|
+
Example: ["rowVisualizationByPath", "columnVisualizationByPath"]`
|
|
160
|
+
)
|
|
161
|
+
};
|
|
162
|
+
const duplicateDashboardSchema = {
|
|
163
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
164
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
165
|
+
dashboardNameOrId: import_zod.z.string().describe("Source dashboard name or numeric ID to duplicate"),
|
|
166
|
+
name: import_zod.z.string().describe("Name for the new dashboard"),
|
|
167
|
+
folderId: import_zod.z.number().optional().describe("Target folder ID. If omitted, duplicates to root Dashboards folder."),
|
|
168
|
+
folderPath: import_zod.z.array(import_zod.z.string()).optional().describe('Target folder path as array (e.g., ["Dashboards", "Reports"]). Alternative to folderId.')
|
|
169
|
+
};
|
|
47
170
|
function registerDashboardTools(server) {
|
|
48
171
|
server.tool(
|
|
49
172
|
"farseer_list_dashboards",
|
|
@@ -52,6 +175,9 @@ function registerDashboardTools(server) {
|
|
|
52
175
|
Dashboards contain tiles that display charts, tables, and other visualizations.
|
|
53
176
|
Returns dashboard IDs, names, and tile counts.
|
|
54
177
|
|
|
178
|
+
Set includeFolderPath=true to also show the folder path for each dashboard
|
|
179
|
+
(this is slower as it traverses the folder tree).
|
|
180
|
+
|
|
55
181
|
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
56
182
|
listDashboardsSchema,
|
|
57
183
|
async (params) => {
|
|
@@ -61,6 +187,14 @@ If no tenant is specified, uses the currently checked-out tenant.`,
|
|
|
61
187
|
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
62
188
|
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
63
189
|
try {
|
|
190
|
+
if (params.includeFolderPath) {
|
|
191
|
+
const dashboards2 = await collectDashboardsWithPaths(nativeClient, null, "");
|
|
192
|
+
return (0, import_helpers.successResponse)({
|
|
193
|
+
tenant,
|
|
194
|
+
totalDashboards: dashboards2.length,
|
|
195
|
+
dashboards: dashboards2
|
|
196
|
+
});
|
|
197
|
+
}
|
|
64
198
|
const dashboards = await nativeClient.dashboards.list();
|
|
65
199
|
const result = dashboards.map((d) => ({
|
|
66
200
|
id: d.id,
|
|
@@ -125,6 +259,509 @@ If no tenant is specified, uses the currently checked-out tenant.`,
|
|
|
125
259
|
}
|
|
126
260
|
}
|
|
127
261
|
);
|
|
262
|
+
server.tool(
|
|
263
|
+
"farseer_list_tiles",
|
|
264
|
+
`List all tiles for a dashboard with their types, positions, and sheet IDs.
|
|
265
|
+
|
|
266
|
+
Returns tile IDs, names, types (TEXT, SHEET_BACKED, DIMENSION_SLICER),
|
|
267
|
+
grid placements, and associated sheet IDs for SHEET_BACKED tiles.
|
|
268
|
+
|
|
269
|
+
Accepts either a dashboard name or numeric ID.
|
|
270
|
+
|
|
271
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
272
|
+
listTilesSchema,
|
|
273
|
+
async (params) => {
|
|
274
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
275
|
+
if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
|
|
276
|
+
const { organisation, tenant } = resolved;
|
|
277
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
278
|
+
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
279
|
+
try {
|
|
280
|
+
const dashRef = await (0, import_entityResolver.resolveDashboardId)(nativeClient, params.dashboardNameOrId);
|
|
281
|
+
if (!dashRef) {
|
|
282
|
+
return (0, import_helpers.errorResponse)(`Dashboard "${params.dashboardNameOrId}" not found`, "NOT_FOUND");
|
|
283
|
+
}
|
|
284
|
+
const tiles = await nativeClient.dashboards.listTiles(dashRef.id);
|
|
285
|
+
const result = tiles.map((t) => {
|
|
286
|
+
const tile = {
|
|
287
|
+
id: t.id,
|
|
288
|
+
name: t.name,
|
|
289
|
+
type: t.data?.type,
|
|
290
|
+
gridPlacements: t.gridPlacements
|
|
291
|
+
};
|
|
292
|
+
if (t.data?.type === "SHEET_BACKED" && t.data?.sheet) {
|
|
293
|
+
tile.sheetId = t.data.sheet.id;
|
|
294
|
+
tile.sheetName = t.data.sheet.name;
|
|
295
|
+
}
|
|
296
|
+
return tile;
|
|
297
|
+
});
|
|
298
|
+
return (0, import_helpers.successResponse)({
|
|
299
|
+
tenant,
|
|
300
|
+
dashboard: { id: dashRef.id, name: dashRef.name },
|
|
301
|
+
totalTiles: result.length,
|
|
302
|
+
tiles: result
|
|
303
|
+
});
|
|
304
|
+
} catch (error) {
|
|
305
|
+
return (0, import_helpers.errorResponse)(`List tiles failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
server.tool(
|
|
310
|
+
"farseer_get_tile",
|
|
311
|
+
`Get the full configuration of a specific tile.
|
|
312
|
+
|
|
313
|
+
Returns the complete tile object including name, subtitle, footnotes,
|
|
314
|
+
grid placements, data (type-specific: visualization, sheet config, text content),
|
|
315
|
+
and style settings.
|
|
316
|
+
|
|
317
|
+
This is essential for understanding the tile structure before modifying it
|
|
318
|
+
with farseer_update_tile.
|
|
319
|
+
|
|
320
|
+
Accepts either a dashboard name or numeric ID.
|
|
321
|
+
|
|
322
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
323
|
+
getTileSchema,
|
|
324
|
+
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
325
|
+
async (params) => {
|
|
326
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
327
|
+
if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
|
|
328
|
+
const { organisation, tenant } = resolved;
|
|
329
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
330
|
+
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
331
|
+
try {
|
|
332
|
+
const dashRef = await (0, import_entityResolver.resolveDashboardId)(nativeClient, params.dashboardNameOrId);
|
|
333
|
+
if (!dashRef) {
|
|
334
|
+
return (0, import_helpers.errorResponse)(`Dashboard "${params.dashboardNameOrId}" not found`, "NOT_FOUND");
|
|
335
|
+
}
|
|
336
|
+
const tile = await rawApiCall(nativeClient, "GET", `/dashboards/${dashRef.id}/tiles/${params.tileId}`);
|
|
337
|
+
return (0, import_helpers.successResponse)({
|
|
338
|
+
tenant,
|
|
339
|
+
dashboard: { id: dashRef.id, name: dashRef.name },
|
|
340
|
+
tile
|
|
341
|
+
});
|
|
342
|
+
} catch (error) {
|
|
343
|
+
return (0, import_helpers.errorResponse)(`Get tile failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
server.tool(
|
|
348
|
+
"farseer_create_tile",
|
|
349
|
+
`Create a new tile on a dashboard.
|
|
350
|
+
|
|
351
|
+
Accepts the full tile configuration as a JSON object. Uses raw API internally
|
|
352
|
+
to avoid the TypeScript client's serialization issues.
|
|
353
|
+
|
|
354
|
+
Tile types:
|
|
355
|
+
- TEXT: Rich text content tile. data = { type: "TEXT", rawContent: {...} }
|
|
356
|
+
- SHEET_BACKED: Table/chart tile backed by a sheet. data = { type: "SHEET_BACKED", useDashboardFilters: true, ... }
|
|
357
|
+
- DIMENSION_SLICER: Filter tile. data = { type: "DIMENSION_SLICER", ... }
|
|
358
|
+
|
|
359
|
+
Grid placements use a responsive grid system:
|
|
360
|
+
gridPlacements: { "lg": { "x": 0, "y": 0, "w": 6, "h": 4 } }
|
|
361
|
+
|
|
362
|
+
Style options: showBackground, backgroundColor, showBorder, borderColor, hasShadow, showSubtitle, showFootnotes.
|
|
363
|
+
|
|
364
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
365
|
+
createTileSchema,
|
|
366
|
+
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
367
|
+
async (params) => {
|
|
368
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
369
|
+
if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
|
|
370
|
+
const { organisation, tenant } = resolved;
|
|
371
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
372
|
+
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
373
|
+
try {
|
|
374
|
+
const dashRef = await (0, import_entityResolver.resolveDashboardId)(nativeClient, params.dashboardNameOrId);
|
|
375
|
+
if (!dashRef) {
|
|
376
|
+
return (0, import_helpers.errorResponse)(`Dashboard "${params.dashboardNameOrId}" not found`, "NOT_FOUND");
|
|
377
|
+
}
|
|
378
|
+
const tilePayload = { ...params.tile };
|
|
379
|
+
if (tilePayload.subtitle === void 0) tilePayload.subtitle = "";
|
|
380
|
+
if (tilePayload.footnotes === void 0) tilePayload.footnotes = "";
|
|
381
|
+
if (tilePayload.style === void 0) tilePayload.style = {};
|
|
382
|
+
if (tilePayload.data?.type === "SHEET_BACKED") {
|
|
383
|
+
const d = tilePayload.data;
|
|
384
|
+
if (d.useDashboardFilters === void 0) d.useDashboardFilters = true;
|
|
385
|
+
if (d.useDashboardTimeline === void 0) d.useDashboardTimeline = true;
|
|
386
|
+
if (d.showTileFilters === void 0) d.showTileFilters = false;
|
|
387
|
+
if (d.showTileTimeline === void 0) d.showTileTimeline = false;
|
|
388
|
+
if (d.exportConfigurationId === void 0) d.exportConfigurationId = null;
|
|
389
|
+
if (d.visualization === void 0) d.visualization = { type: "TABLE" };
|
|
390
|
+
}
|
|
391
|
+
const result = await rawApiCall(nativeClient, "POST", `/dashboards/${dashRef.id}/tiles`, tilePayload);
|
|
392
|
+
return (0, import_helpers.successResponse)({
|
|
393
|
+
tenant,
|
|
394
|
+
dashboard: { id: dashRef.id, name: dashRef.name },
|
|
395
|
+
action: "created",
|
|
396
|
+
tile: {
|
|
397
|
+
id: result?.id,
|
|
398
|
+
name: result?.name,
|
|
399
|
+
type: result?.data?.type
|
|
400
|
+
},
|
|
401
|
+
message: `Tile "${params.tile.name || "unnamed"}" created on dashboard "${dashRef.name}"`
|
|
402
|
+
});
|
|
403
|
+
} catch (error) {
|
|
404
|
+
return (0, import_helpers.errorResponse)(`Create tile failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
server.tool(
|
|
409
|
+
"farseer_update_tile",
|
|
410
|
+
`Update an existing tile on a dashboard.
|
|
411
|
+
|
|
412
|
+
Fetches the current tile configuration first, then deep-merges your changes
|
|
413
|
+
and sends the full updated object. This means you only need to provide
|
|
414
|
+
the fields you want to change.
|
|
415
|
+
|
|
416
|
+
Uses raw API internally to bypass the TypeScript client's serialization
|
|
417
|
+
which strips fields like table/sheet on SHEET_BACKED tiles.
|
|
418
|
+
|
|
419
|
+
Tip: Use farseer_get_tile first to see the current config, then pass
|
|
420
|
+
only the changes you need.
|
|
421
|
+
|
|
422
|
+
Example - update just the visualization:
|
|
423
|
+
{
|
|
424
|
+
"data": {
|
|
425
|
+
"visualization": {
|
|
426
|
+
"rowStyles": [{ "rowKey": "row1", "style": "bold" }]
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
WARNING: This modifies dashboard configuration. Use with caution.
|
|
432
|
+
|
|
433
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
434
|
+
updateTileSchema,
|
|
435
|
+
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
436
|
+
async (params) => {
|
|
437
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
438
|
+
if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
|
|
439
|
+
const { organisation, tenant } = resolved;
|
|
440
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
441
|
+
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
442
|
+
try {
|
|
443
|
+
const dashRef = await (0, import_entityResolver.resolveDashboardId)(nativeClient, params.dashboardNameOrId);
|
|
444
|
+
if (!dashRef) {
|
|
445
|
+
return (0, import_helpers.errorResponse)(`Dashboard "${params.dashboardNameOrId}" not found`, "NOT_FOUND");
|
|
446
|
+
}
|
|
447
|
+
const currentTile = await rawApiCall(
|
|
448
|
+
nativeClient,
|
|
449
|
+
"GET",
|
|
450
|
+
`/dashboards/${dashRef.id}/tiles/${params.tileId}`
|
|
451
|
+
);
|
|
452
|
+
if (!currentTile) {
|
|
453
|
+
return (0, import_helpers.errorResponse)(`Tile ${params.tileId} not found on dashboard "${dashRef.name}"`, "NOT_FOUND");
|
|
454
|
+
}
|
|
455
|
+
const replaceSet = new Set(params.replaceKeys || []);
|
|
456
|
+
const newVisType = params.tile?.data?.visualization?.type;
|
|
457
|
+
const curVisType = currentTile?.data?.visualization?.type;
|
|
458
|
+
if (newVisType && curVisType && newVisType !== curVisType) {
|
|
459
|
+
replaceSet.add("visualization");
|
|
460
|
+
}
|
|
461
|
+
const merged = deepMerge(currentTile, params.tile, replaceSet);
|
|
462
|
+
delete merged.id;
|
|
463
|
+
await rawApiCall(nativeClient, "PUT", `/dashboards/${dashRef.id}/tiles/${params.tileId}`, merged);
|
|
464
|
+
return (0, import_helpers.successResponse)({
|
|
465
|
+
tenant,
|
|
466
|
+
dashboard: { id: dashRef.id, name: dashRef.name },
|
|
467
|
+
action: "updated",
|
|
468
|
+
tileId: params.tileId,
|
|
469
|
+
message: `Tile ${params.tileId} updated on dashboard "${dashRef.name}"`
|
|
470
|
+
});
|
|
471
|
+
} catch (error) {
|
|
472
|
+
return (0, import_helpers.errorResponse)(`Update tile failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
);
|
|
476
|
+
server.tool(
|
|
477
|
+
"farseer_delete_tile",
|
|
478
|
+
`Delete a tile from a dashboard.
|
|
479
|
+
|
|
480
|
+
Permanently removes the tile identified by its numeric ID.
|
|
481
|
+
Use farseer_list_tiles to find tile IDs first.
|
|
482
|
+
|
|
483
|
+
WARNING: This is destructive and cannot be undone.
|
|
484
|
+
|
|
485
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
486
|
+
{
|
|
487
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
488
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
489
|
+
dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
|
|
490
|
+
tileId: import_zod.z.number().describe("Tile ID to delete")
|
|
491
|
+
},
|
|
492
|
+
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
493
|
+
async (params) => {
|
|
494
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
495
|
+
if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
|
|
496
|
+
const { organisation, tenant } = resolved;
|
|
497
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
498
|
+
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
499
|
+
try {
|
|
500
|
+
const dashRef = await (0, import_entityResolver.resolveDashboardId)(nativeClient, params.dashboardNameOrId);
|
|
501
|
+
if (!dashRef) {
|
|
502
|
+
return (0, import_helpers.errorResponse)(`Dashboard "${params.dashboardNameOrId}" not found`, "NOT_FOUND");
|
|
503
|
+
}
|
|
504
|
+
await rawApiCall(nativeClient, "DELETE", `/dashboards/${dashRef.id}/tiles/${params.tileId}`);
|
|
505
|
+
return (0, import_helpers.successResponse)({
|
|
506
|
+
tenant,
|
|
507
|
+
dashboard: { id: dashRef.id, name: dashRef.name },
|
|
508
|
+
action: "deleted",
|
|
509
|
+
tileId: params.tileId,
|
|
510
|
+
message: `Tile ${params.tileId} deleted from dashboard "${dashRef.name}"`
|
|
511
|
+
});
|
|
512
|
+
} catch (error) {
|
|
513
|
+
return (0, import_helpers.errorResponse)(`Delete tile failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
server.tool(
|
|
518
|
+
"farseer_create_dashboard",
|
|
519
|
+
`Create a new empty dashboard.
|
|
520
|
+
|
|
521
|
+
Creates a dashboard with the given name in the specified folder.
|
|
522
|
+
|
|
523
|
+
NOTE: The backend does not accept columns/rows config on create.
|
|
524
|
+
Create the dashboard first, then use farseer_update_dashboard to configure
|
|
525
|
+
timeline (columns), comparison (rows), and options.
|
|
526
|
+
|
|
527
|
+
If no folder is specified, creates in the root Dashboards folder.
|
|
528
|
+
|
|
529
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
530
|
+
{
|
|
531
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
532
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
533
|
+
name: import_zod.z.string().describe("Dashboard name"),
|
|
534
|
+
folderId: import_zod.z.number().optional().describe("Target folder ID. If omitted, uses root Dashboards folder."),
|
|
535
|
+
folderPath: import_zod.z.array(import_zod.z.string()).optional().describe('Target folder path as array (e.g., ["Dashboards", "Reports"]). Alternative to folderId.')
|
|
536
|
+
},
|
|
537
|
+
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
538
|
+
async (params) => {
|
|
539
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
540
|
+
if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
|
|
541
|
+
const { organisation, tenant } = resolved;
|
|
542
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
543
|
+
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
544
|
+
try {
|
|
545
|
+
let targetFolderId = params.folderId ?? 0;
|
|
546
|
+
if (!params.folderId && params.folderPath && params.folderPath.length > 0) {
|
|
547
|
+
const folderResults = await nativeClient.folders.search({
|
|
548
|
+
name: params.folderPath[params.folderPath.length - 1],
|
|
549
|
+
types: [farseer.FolderItemType.Folder],
|
|
550
|
+
limit: 20
|
|
551
|
+
});
|
|
552
|
+
if (folderResults.length > 0) {
|
|
553
|
+
targetFolderId = folderResults[0].id;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (targetFolderId === 0) {
|
|
557
|
+
const rootItems = await nativeClient.folders.listItemsBatch([{ id: null }]);
|
|
558
|
+
const dashboardsFolder = rootItems[0]?.items?.find(
|
|
559
|
+
(item) => item.type === farseer.FolderItemType.Folder && item.name.toLowerCase() === "dashboards"
|
|
560
|
+
);
|
|
561
|
+
if (dashboardsFolder) {
|
|
562
|
+
targetFolderId = dashboardsFolder.id;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
const createRequest = {
|
|
566
|
+
name: params.name,
|
|
567
|
+
folderId: targetFolderId
|
|
568
|
+
};
|
|
569
|
+
const result = await nativeClient.dashboards.create(createRequest);
|
|
570
|
+
return (0, import_helpers.successResponse)({
|
|
571
|
+
tenant,
|
|
572
|
+
action: "created",
|
|
573
|
+
dashboard: {
|
|
574
|
+
id: result.id,
|
|
575
|
+
name: result.name
|
|
576
|
+
},
|
|
577
|
+
folderId: targetFolderId,
|
|
578
|
+
message: `Dashboard "${params.name}" created`
|
|
579
|
+
});
|
|
580
|
+
} catch (error) {
|
|
581
|
+
return (0, import_helpers.errorResponse)(`Create dashboard failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
server.tool(
|
|
586
|
+
"farseer_update_dashboard",
|
|
587
|
+
`Update a dashboard's configuration.
|
|
588
|
+
|
|
589
|
+
Updates dashboard name, columns (timeline), rows (comparison), and options.
|
|
590
|
+
Uses raw API internally to avoid serialization issues with complex nested configs.
|
|
591
|
+
|
|
592
|
+
Fetches current dashboard first and deep-merges your changes, so you only need
|
|
593
|
+
to provide the fields you want to change.
|
|
594
|
+
|
|
595
|
+
Example - change name and timeline:
|
|
596
|
+
{
|
|
597
|
+
"name": "New Dashboard Name",
|
|
598
|
+
"columns": { "intervalToolbar": { ... } }
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
WARNING: This modifies dashboard configuration. Use with caution.
|
|
602
|
+
|
|
603
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
604
|
+
{
|
|
605
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
606
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
607
|
+
dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
|
|
608
|
+
update: import_zod.z.record(import_zod.z.any()).describe(
|
|
609
|
+
"Dashboard fields to update. Supported: name, columns (timeline config), rows (comparison config), options."
|
|
610
|
+
)
|
|
611
|
+
},
|
|
612
|
+
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
613
|
+
async (params) => {
|
|
614
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
615
|
+
if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
|
|
616
|
+
const { organisation, tenant } = resolved;
|
|
617
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
618
|
+
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
619
|
+
try {
|
|
620
|
+
const dashRef = await (0, import_entityResolver.resolveDashboardId)(nativeClient, params.dashboardNameOrId);
|
|
621
|
+
if (!dashRef) {
|
|
622
|
+
return (0, import_helpers.errorResponse)(`Dashboard "${params.dashboardNameOrId}" not found`, "NOT_FOUND");
|
|
623
|
+
}
|
|
624
|
+
const current = await rawApiCall(nativeClient, "GET", `/dashboards/${dashRef.id}`);
|
|
625
|
+
const base = {
|
|
626
|
+
name: current.name,
|
|
627
|
+
columns: current.columns,
|
|
628
|
+
rows: current.rows,
|
|
629
|
+
options: current.options
|
|
630
|
+
};
|
|
631
|
+
const replaceSet = /* @__PURE__ */ new Set(["columns", "rows", "options"]);
|
|
632
|
+
const merged = deepMerge(base, params.update, replaceSet);
|
|
633
|
+
await rawApiCall(nativeClient, "PUT", `/dashboards/${dashRef.id}`, merged);
|
|
634
|
+
return (0, import_helpers.successResponse)({
|
|
635
|
+
tenant,
|
|
636
|
+
action: "updated",
|
|
637
|
+
dashboard: { id: dashRef.id, name: merged.name },
|
|
638
|
+
message: `Dashboard "${dashRef.name}" updated`
|
|
639
|
+
});
|
|
640
|
+
} catch (error) {
|
|
641
|
+
return (0, import_helpers.errorResponse)(`Update dashboard failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
);
|
|
645
|
+
server.tool(
|
|
646
|
+
"farseer_delete_dashboard",
|
|
647
|
+
`Delete a dashboard.
|
|
648
|
+
|
|
649
|
+
WARNING: This is destructive. The backend may return 405 Method Not Allowed
|
|
650
|
+
if dashboard deletion is not supported for the tenant.
|
|
651
|
+
|
|
652
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
653
|
+
{
|
|
654
|
+
organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
|
|
655
|
+
tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
|
|
656
|
+
dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID")
|
|
657
|
+
},
|
|
658
|
+
async (params) => {
|
|
659
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
660
|
+
if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
|
|
661
|
+
const { organisation, tenant } = resolved;
|
|
662
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
663
|
+
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
664
|
+
try {
|
|
665
|
+
const dashRef = await (0, import_entityResolver.resolveDashboardId)(nativeClient, params.dashboardNameOrId);
|
|
666
|
+
if (!dashRef) {
|
|
667
|
+
return (0, import_helpers.errorResponse)(`Dashboard "${params.dashboardNameOrId}" not found`, "NOT_FOUND");
|
|
668
|
+
}
|
|
669
|
+
await rawApiCall(nativeClient, "DELETE", `/dashboards/${dashRef.id}`);
|
|
670
|
+
return (0, import_helpers.successResponse)({
|
|
671
|
+
tenant,
|
|
672
|
+
action: "deleted",
|
|
673
|
+
dashboard: { id: dashRef.id, name: dashRef.name },
|
|
674
|
+
message: `Dashboard "${dashRef.name}" deleted`
|
|
675
|
+
});
|
|
676
|
+
} catch (error) {
|
|
677
|
+
return (0, import_helpers.errorResponse)(`Delete dashboard failed: ${await extractErrorMessage(error)}`, "NETWORK_ERROR");
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
server.tool(
|
|
682
|
+
"farseer_duplicate_dashboard",
|
|
683
|
+
`Duplicate a dashboard to a new name, optionally in a specific folder.
|
|
684
|
+
|
|
685
|
+
Creates a copy of the source dashboard with all its tiles.
|
|
686
|
+
Specify folderId directly or use folderPath to resolve the target folder.
|
|
687
|
+
|
|
688
|
+
If no folder is specified, duplicates to the root Dashboards folder.
|
|
689
|
+
|
|
690
|
+
If no tenant is specified, uses the currently checked-out tenant.`,
|
|
691
|
+
duplicateDashboardSchema,
|
|
692
|
+
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
693
|
+
async (params) => {
|
|
694
|
+
const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
|
|
695
|
+
if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
|
|
696
|
+
const { organisation, tenant } = resolved;
|
|
697
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
698
|
+
if (!nativeClient) return (0, import_helpers.authRequiredResponse)(tenant);
|
|
699
|
+
try {
|
|
700
|
+
const dashRef = await (0, import_entityResolver.resolveDashboardId)(nativeClient, params.dashboardNameOrId);
|
|
701
|
+
if (!dashRef) {
|
|
702
|
+
return (0, import_helpers.errorResponse)(`Dashboard "${params.dashboardNameOrId}" not found`, "NOT_FOUND");
|
|
703
|
+
}
|
|
704
|
+
let targetFolderId = params.folderId ?? 0;
|
|
705
|
+
if (!params.folderId && params.folderPath && params.folderPath.length > 0) {
|
|
706
|
+
const folderResults = await nativeClient.folders.search({
|
|
707
|
+
name: params.folderPath[params.folderPath.length - 1],
|
|
708
|
+
types: [farseer.FolderItemType.Folder],
|
|
709
|
+
limit: 20
|
|
710
|
+
});
|
|
711
|
+
if (folderResults.length > 0) {
|
|
712
|
+
targetFolderId = folderResults[0].id;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
if (targetFolderId === 0) {
|
|
716
|
+
const rootItems = await nativeClient.folders.listItemsBatch([{ id: null }]);
|
|
717
|
+
const dashboardsFolder = rootItems[0]?.items?.find(
|
|
718
|
+
(item) => item.type === farseer.FolderItemType.Folder && item.name.toLowerCase() === "dashboards"
|
|
719
|
+
);
|
|
720
|
+
if (dashboardsFolder) {
|
|
721
|
+
targetFolderId = dashboardsFolder.id;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
const result = await nativeClient.dashboards.duplicate({
|
|
725
|
+
name: params.name,
|
|
726
|
+
sourceId: dashRef.id,
|
|
727
|
+
folderId: targetFolderId
|
|
728
|
+
});
|
|
729
|
+
return (0, import_helpers.successResponse)({
|
|
730
|
+
tenant,
|
|
731
|
+
action: "duplicated",
|
|
732
|
+
source: { id: dashRef.id, name: dashRef.name },
|
|
733
|
+
newDashboard: {
|
|
734
|
+
id: result.id,
|
|
735
|
+
name: result.name
|
|
736
|
+
},
|
|
737
|
+
folderId: targetFolderId,
|
|
738
|
+
message: `Dashboard "${dashRef.name}" duplicated as "${params.name}"`
|
|
739
|
+
});
|
|
740
|
+
} catch (error) {
|
|
741
|
+
return (0, import_helpers.errorResponse)(
|
|
742
|
+
`Duplicate dashboard failed: ${await extractErrorMessage(error)}`,
|
|
743
|
+
"NETWORK_ERROR"
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
function deepMerge(target, source, replaceKeys) {
|
|
750
|
+
if (source === null || source === void 0) return target;
|
|
751
|
+
if (target === null || target === void 0) return source;
|
|
752
|
+
if (typeof source !== "object" || Array.isArray(source)) return source;
|
|
753
|
+
if (typeof target !== "object" || Array.isArray(target)) return source;
|
|
754
|
+
const result = { ...target };
|
|
755
|
+
for (const key of Object.keys(source)) {
|
|
756
|
+
if (replaceKeys?.has(key)) {
|
|
757
|
+
result[key] = source[key];
|
|
758
|
+
} else if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
|
|
759
|
+
result[key] = deepMerge(target[key], source[key], replaceKeys);
|
|
760
|
+
} else {
|
|
761
|
+
result[key] = source[key];
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return result;
|
|
128
765
|
}
|
|
129
766
|
// Annotate the CommonJS export names for ESM import in node:
|
|
130
767
|
0 && (module.exports = {
|