farseer-cli 1.9.0 → 1.9.1

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.
@@ -37,7 +37,7 @@ var import_documentation = require("./resources/documentation");
37
37
  var import_workflows = require("./prompts/workflows");
38
38
  const SERVER_INSTRUCTIONS = `This MCP server works on a single Farseer tenant per session \u2014 one tenant for the whole session, never switched.
39
39
 
40
- - If it was launched with a tenant (\`--tenant <slug>\` or the \`FARSEER_TENANT\` env), it is locked to that tenant. Do not pass \`tenant\`/\`organisation\` arguments (a different one is rejected), and do not use farseer CLI checkout/login to change it.
40
+ - If it was launched with a tenant (\`--tenant <slug>\` or the \`FARSEER_TENANT\` env), it is locked to that tenant. Tools take no tenant/organisation argument; they always act on the bound tenant. Do not use farseer CLI checkout/login to change it.
41
41
  - If no tenant is set yet, bind it once: when the user says which tenant/client to work on, call \`farseer_select_tenant\`. After that first selection the tenant is locked for the session; to use a different tenant, start a new session.
42
42
  - Use \`farseer_whoami\` to see the active tenant. Do not call other tools before a tenant is set.`;
43
43
  function createMcpServer() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/mcp/server.ts"],
4
- "sourcesContent": ["/**\n * MCP Server Configuration\n *\n * Creates and configures the Farseer MCP server with all tools, resources, and prompts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { CLI_VERSION } from '../utils/constants';\nimport { registerAuthTools } from './tools/authTools';\nimport { registerSyncTools } from './tools/syncTools';\nimport { registerAppTools } from './tools/appTools';\nimport { registerModelTools } from './tools/modelTools';\nimport { registerRunTools } from './tools/runTools';\nimport { registerDataTools } from './tools/dataTools';\nimport { registerSheetTools } from './tools/sheetTools';\nimport { registerDashboardTools } from './tools/dashboardTools';\nimport { registerCellTools } from './tools/cellTools';\nimport { registerFolderTools } from './tools/folderTools';\nimport { registerDocumentationResources } from './resources/documentation';\nimport { registerWorkflowPrompts } from './prompts/workflows';\n\n// Surfaced to the model at connect time (MCP `instructions`). It sets the\n// mental model up front so an agent doesn't try to \"check out\" or authenticate\n// a tenant through CLI commands \u2014 which live on a different code path and do\n// not affect this server.\nconst SERVER_INSTRUCTIONS = `This MCP server works on a single Farseer tenant per session \u2014 one tenant for the whole session, never switched.\n\n- If it was launched with a tenant (\\`--tenant <slug>\\` or the \\`FARSEER_TENANT\\` env), it is locked to that tenant. Do not pass \\`tenant\\`/\\`organisation\\` arguments (a different one is rejected), and do not use farseer CLI checkout/login to change it.\n- If no tenant is set yet, bind it once: when the user says which tenant/client to work on, call \\`farseer_select_tenant\\`. After that first selection the tenant is locked for the session; to use a different tenant, start a new session.\n- Use \\`farseer_whoami\\` to see the active tenant. Do not call other tools before a tenant is set.`;\n\nexport function createMcpServer(): McpServer {\n const server = new McpServer(\n {\n name: 'farseer-cli',\n version: CLI_VERSION,\n },\n { instructions: SERVER_INSTRUCTIONS },\n );\n\n // Register all tools\n registerAuthTools(server);\n registerSyncTools(server);\n registerAppTools(server);\n registerModelTools(server);\n registerRunTools(server);\n registerDataTools(server);\n registerSheetTools(server);\n registerDashboardTools(server);\n registerCellTools(server);\n registerFolderTools(server);\n\n // Register resources (documentation)\n registerDocumentationResources(server);\n\n // Register prompts (workflow templates)\n registerWorkflowPrompts(server);\n\n return server;\n}\n"],
4
+ "sourcesContent": ["/**\n * MCP Server Configuration\n *\n * Creates and configures the Farseer MCP server with all tools, resources, and prompts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { CLI_VERSION } from '../utils/constants';\nimport { registerAuthTools } from './tools/authTools';\nimport { registerSyncTools } from './tools/syncTools';\nimport { registerAppTools } from './tools/appTools';\nimport { registerModelTools } from './tools/modelTools';\nimport { registerRunTools } from './tools/runTools';\nimport { registerDataTools } from './tools/dataTools';\nimport { registerSheetTools } from './tools/sheetTools';\nimport { registerDashboardTools } from './tools/dashboardTools';\nimport { registerCellTools } from './tools/cellTools';\nimport { registerFolderTools } from './tools/folderTools';\nimport { registerDocumentationResources } from './resources/documentation';\nimport { registerWorkflowPrompts } from './prompts/workflows';\n\n// Surfaced to the model at connect time (MCP `instructions`). It sets the\n// mental model up front so an agent doesn't try to \"check out\" or authenticate\n// a tenant through CLI commands \u2014 which live on a different code path and do\n// not affect this server.\nconst SERVER_INSTRUCTIONS = `This MCP server works on a single Farseer tenant per session \u2014 one tenant for the whole session, never switched.\n\n- If it was launched with a tenant (\\`--tenant <slug>\\` or the \\`FARSEER_TENANT\\` env), it is locked to that tenant. Tools take no tenant/organisation argument; they always act on the bound tenant. Do not use farseer CLI checkout/login to change it.\n- If no tenant is set yet, bind it once: when the user says which tenant/client to work on, call \\`farseer_select_tenant\\`. After that first selection the tenant is locked for the session; to use a different tenant, start a new session.\n- Use \\`farseer_whoami\\` to see the active tenant. Do not call other tools before a tenant is set.`;\n\nexport function createMcpServer(): McpServer {\n const server = new McpServer(\n {\n name: 'farseer-cli',\n version: CLI_VERSION,\n },\n { instructions: SERVER_INSTRUCTIONS },\n );\n\n // Register all tools\n registerAuthTools(server);\n registerSyncTools(server);\n registerAppTools(server);\n registerModelTools(server);\n registerRunTools(server);\n registerDataTools(server);\n registerSheetTools(server);\n registerDashboardTools(server);\n registerCellTools(server);\n registerFolderTools(server);\n\n // Register resources (documentation)\n registerDocumentationResources(server);\n\n // Register prompts (workflow templates)\n registerWorkflowPrompts(server);\n\n return server;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,iBAA0B;AAC1B,uBAA4B;AAC5B,uBAAkC;AAClC,uBAAkC;AAClC,sBAAiC;AACjC,wBAAmC;AACnC,sBAAiC;AACjC,uBAAkC;AAClC,wBAAmC;AACnC,4BAAuC;AACvC,uBAAkC;AAClC,yBAAoC;AACpC,2BAA+C;AAC/C,uBAAwC;AAMxC,MAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAMrB,SAAS,kBAA6B;AACzC,QAAM,SAAS,IAAI;AAAA,IACf;AAAA,MACI,MAAM;AAAA,MACN,SAAS;AAAA,IACb;AAAA,IACA,EAAE,cAAc,oBAAoB;AAAA,EACxC;AAGA,0CAAkB,MAAM;AACxB,0CAAkB,MAAM;AACxB,wCAAiB,MAAM;AACvB,4CAAmB,MAAM;AACzB,wCAAiB,MAAM;AACvB,0CAAkB,MAAM;AACxB,4CAAmB,MAAM;AACzB,oDAAuB,MAAM;AAC7B,0CAAkB,MAAM;AACxB,8CAAoB,MAAM;AAG1B,2DAA+B,MAAM;AAGrC,gDAAwB,MAAM;AAE9B,SAAO;AACX;",
6
6
  "names": []
7
7
  }
@@ -28,18 +28,12 @@ var import_farseerApi = require("../../services/farseerApi");
28
28
  var import_helpers = require("../utils/helpers");
29
29
  var import_errorFormatter = require("../../utils/errorFormatter");
30
30
  const listAppsSchema = {
31
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
32
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
33
31
  details: import_zod.z.boolean().optional().describe("Include full details for each app")
34
32
  };
35
33
  const getAppSchema = {
36
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
37
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
38
34
  appName: import_zod.z.string().describe("Name of the app (can include spaces)")
39
35
  };
40
36
  const createAppSchema = {
41
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
42
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
43
37
  appName: import_zod.z.string().describe("Name for the new app")
44
38
  };
45
39
  const argumentSchema = import_zod.z.object({
@@ -60,8 +54,6 @@ const argumentSchema = import_zod.z.object({
60
54
  path: ["defaultValue"]
61
55
  });
62
56
  const configureAppSchema = {
63
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
64
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
65
57
  appName: import_zod.z.string().describe("Name of the app to configure"),
66
58
  entrypoint: import_zod.z.string().optional().describe(`Main script filename \u2014 must be a file in the app's source folder (e.g., "index.ts")`),
67
59
  sourceFolder: import_zod.z.string().optional().describe(`Source folder the app's scripts come from (path under Files/, e.g. "Scripts/MyApp")`),
@@ -70,8 +62,6 @@ const configureAppSchema = {
70
62
  newName: import_zod.z.string().optional().describe("Rename the app")
71
63
  };
72
64
  const deleteAppSchema = {
73
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
74
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
75
65
  appName: import_zod.z.string().describe("Name of the app to delete")
76
66
  };
77
67
  function registerAppTools(server) {
@@ -85,12 +75,10 @@ Apps are executable script configurations that include:
85
75
  - List of included scripts
86
76
  - Expected arguments with default values
87
77
 
88
- Use details=true to include full information for each app.
89
-
90
- If no tenant is specified, uses the currently checked-out tenant.`,
78
+ Use details=true to include full information for each app.`,
91
79
  listAppsSchema,
92
80
  async (params) => {
93
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
81
+ const resolved = (0, import_helpers.getSessionTenant)();
94
82
  if (!resolved) {
95
83
  return (0, import_helpers.tenantRequiredResponse)();
96
84
  }
@@ -153,12 +141,10 @@ Returns:
153
141
  - App name and description
154
142
  - Entry point script (main script that runs)
155
143
  - List of all included scripts
156
- - Expected arguments with their default values
157
-
158
- If no tenant is specified, uses the currently checked-out tenant.`,
144
+ - Expected arguments with their default values`,
159
145
  getAppSchema,
160
146
  async (params) => {
161
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
147
+ const resolved = (0, import_helpers.getSessionTenant)();
162
148
  if (!resolved) {
163
149
  return (0, import_helpers.tenantRequiredResponse)();
164
150
  }
@@ -217,12 +203,10 @@ Workflow to create a new app:
217
203
  4. Configure it with farseer_configure_app (set entrypoint, scripts, arguments)
218
204
  5. Run it with farseer_run_app (CLI injects auth credentials automatically)
219
205
 
220
- Scripts should use \`new FarseerClient()\` with no arguments - credentials are injected via environment variables by the CLI at runtime.
221
-
222
- If no tenant is specified, uses the currently checked-out tenant.`,
206
+ Scripts should use \`new FarseerClient()\` with no arguments - credentials are injected via environment variables by the CLI at runtime.`,
223
207
  createAppSchema,
224
208
  async (params) => {
225
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
209
+ const resolved = (0, import_helpers.getSessionTenant)();
226
210
  if (!resolved) {
227
211
  return (0, import_helpers.tenantRequiredResponse)();
228
212
  }
@@ -272,12 +256,10 @@ Important:
272
256
  - Settings you don't pass are preserved (this only changes what you specify).
273
257
  - Arguments are passed to the script as a JSON-encoded FARSEER_ARGS env var
274
258
  - Boolean dataType requires defaultValue \u2208 { "true", "false" }; defaultValue
275
- must be one of options when options is set
276
-
277
- If no tenant is specified, uses the currently checked-out tenant.`,
259
+ must be one of options when options is set`,
278
260
  configureAppSchema,
279
261
  async (params) => {
280
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
262
+ const resolved = (0, import_helpers.getSessionTenant)();
281
263
  if (!resolved) {
282
264
  return (0, import_helpers.tenantRequiredResponse)();
283
265
  }
@@ -346,12 +328,10 @@ If no tenant is specified, uses the currently checked-out tenant.`,
346
328
 
347
329
  WARNING: This is irreversible - the app will be permanently removed from the remote instance.
348
330
 
349
- This does NOT delete the script files, only the app configuration.
350
-
351
- If no tenant is specified, uses the currently checked-out tenant.`,
331
+ This does NOT delete the script files, only the app configuration.`,
352
332
  deleteAppSchema,
353
333
  async (params) => {
354
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
334
+ const resolved = (0, import_helpers.getSessionTenant)();
355
335
  if (!resolved) {
356
336
  return (0, import_helpers.tenantRequiredResponse)();
357
337
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mcp/tools/appTools.ts"],
4
- "sourcesContent": ["/**\n * App Management Tools\n *\n * Tools for managing Farseer apps (Remote Jobs).\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { getFarseerClientWithFallback } from '../../services/farseerFactory';\nimport { AppArgument, AppUpdateChanges, applySourceFolderChange } from '../../services/farseerApi';\nimport {\n resolveOrgAndTenant,\n successResponse,\n errorResponse,\n authRequiredResponse,\n tenantRequiredResponse,\n} from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Define schemas outside of tool registration to avoid deep type instantiation\nconst listAppsSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n details: z.boolean().optional().describe('Include full details for each app'),\n};\n\nconst getAppSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n appName: z.string().describe('Name of the app (can include spaces)'),\n};\n\nconst createAppSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n appName: z.string().describe('Name for the new app'),\n};\n\nexport const argumentSchema = z\n .object({\n name: z.string(),\n dataType: z.enum(['string', 'boolean']).optional().describe('Data type. Defaults to \"string\" if omitted.'),\n fixed: z\n .boolean()\n .optional()\n .describe('Lock the value at run time so users cannot override it (admin sets, user reads only).'),\n options: z\n .array(z.string())\n .optional()\n .describe('Closed allowed-value set. Only meaningful for string dataType.'),\n defaultValue: z.string().optional(),\n secret: z.boolean().optional().describe('Mask the value in inputs and logs.'),\n })\n // Cross-axis checks mirror the backend's `validateExpectedArguments` so an\n // LLM caller gets pre-request feedback. Backend stays authoritative \u2014 these\n // catch the same shapes earlier, they don't replace the validator.\n .refine(\n (a) => a.dataType !== 'boolean' || a.defaultValue === undefined || ['true', 'false'].includes(a.defaultValue),\n {\n message: 'Boolean argument defaultValue must be \"true\" or \"false\"',\n path: ['defaultValue'],\n },\n )\n .refine((a) => !a.options || a.defaultValue === undefined || a.options.includes(a.defaultValue), {\n message: 'defaultValue must be one of the options',\n path: ['defaultValue'],\n });\n\nconst configureAppSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n appName: z.string().describe('Name of the app to configure'),\n entrypoint: z\n .string()\n .optional()\n .describe('Main script filename \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")'),\n sourceFolder: z\n .string()\n .optional()\n .describe('Source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")'),\n description: z.string().optional().describe('App description'),\n arguments: z.array(argumentSchema).optional().describe('App arguments with default values'),\n newName: z.string().optional().describe('Rename the app'),\n};\n\nconst deleteAppSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n appName: z.string().describe('Name of the app to delete'),\n};\n\nexport function registerAppTools(server: McpServer): void {\n // Cast to avoid TS2589 deep type instantiation with MCP SDK + Zod generics\n const s: any = server;\n\n // farseer_list_apps - List all apps\n s.tool(\n 'farseer_list_apps',\n `List all apps (Remote Jobs) configured on a Farseer tenant.\n\nApps are executable script configurations that include:\n- Entry point script\n- List of included scripts\n- Expected arguments with default values\n\nUse details=true to include full information for each app.\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n listAppsSchema,\n async (params: { organisation?: string; tenant?: string; details?: boolean }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const appList = await clientResult.client.listApps();\n\n if (!params.details) {\n return successResponse({\n tenant,\n totalApps: appList.length,\n apps: appList.map((a) => ({\n name: a.name,\n id: a.id,\n reference: a.reference,\n })),\n });\n }\n\n // Get full details for each app\n const appsWithDetails = [];\n for (const item of appList) {\n const app = await clientResult.client.getApp(item.reference);\n if (app) {\n const appScripts = app.scriptFiles ?? [];\n const mainScript = appScripts.find((s) => s.id === app.mainScriptFileId);\n appsWithDetails.push({\n name: app.name,\n id: app.id,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: appScripts.map((s) => s.name),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n });\n }\n }\n\n return successResponse({\n tenant,\n totalApps: appsWithDetails.length,\n apps: appsWithDetails,\n });\n } catch (error) {\n return errorResponse(`List apps failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_app - Get app details\n s.tool(\n 'farseer_get_app',\n `Get detailed information about a specific Farseer app.\n\nReturns:\n- App name and description\n- Entry point script (main script that runs)\n- List of all included scripts\n- Expected arguments with their default values\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n getAppSchema,\n async (params: { organisation?: string; tenant?: string; appName: string }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const app = await clientResult.client.getAppByName(params.appName);\n\n if (!app) {\n return errorResponse(`App \"${params.appName}\" not found`, 'NOT_FOUND');\n }\n\n const getAppScripts = app.scriptFiles ?? [];\n const mainScript = getAppScripts.find((s) => s.id === app.mainScriptFileId);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: getAppScripts.map((s) => ({\n id: s.id,\n name: s.name,\n isEntrypoint: s.id === app.mainScriptFileId,\n })),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n status: app.status,\n lastHeartbeat: app.lastHeartbeat,\n },\n });\n } catch (error) {\n return errorResponse(`Get app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_app - Create new app\n s.tool(\n 'farseer_create_app',\n `Create a new Farseer app.\n\nA Farseer App is a named configuration that points to a TypeScript script and defines its arguments.\nThe script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).\n\nWorkflow to create a new app:\n1. Write the script at farseer-apps/<tenant>/files/Scripts/<name>.ts\n2. Push the script to remote with farseer_push (scripts must exist on remote first)\n3. Create the app with this tool (farseer_create_app)\n4. Configure it with farseer_configure_app (set entrypoint, scripts, arguments)\n5. Run it with farseer_run_app (CLI injects auth credentials automatically)\n\nScripts should use \\`new FarseerClient()\\` with no arguments - credentials are injected via environment variables by the CLI at runtime.\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n createAppSchema,\n async (params: { organisation?: string; tenant?: string; appName: string }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n // Check if app already exists\n const existing = await clientResult.client.getAppByName(params.appName);\n if (existing) {\n return errorResponse(`App \"${params.appName}\" already exists`, 'VALIDATION_ERROR');\n }\n\n const app = await clientResult.client.createApp(params.appName);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n },\n message: `App \"${params.appName}\" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`,\n });\n } catch (error) {\n return errorResponse(`Create app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_configure_app - Configure app settings\n s.tool(\n 'farseer_configure_app',\n `Configure an existing Farseer app.\n\nYou can set:\n- sourceFolder: Folder under Files/ the app's scripts come from (e.g. \"Scripts/MyApp\")\n- entrypoint: Main script to execute \u2014 must be a file in the source folder (e.g., \"index.ts\")\n- description: App description\n- arguments: List of expected arguments. Each has a name, optional dataType\n ('string' | 'boolean' \u2014 defaults to 'string'), optional fixed (locks the\n value at run time), optional options (closed allowed-value set, string\n dataType only), optional defaultValue, and optional secret.\n- newName: Rename the app\n\nImportant:\n- The app's scripts are derived from its source folder; the entrypoint must be\n one of those files. To use a script from another folder, set sourceFolder first.\n- Changing sourceFolder to a folder that doesn't contain the current entrypoint\n requires passing entrypoint in the same call.\n- Settings you don't pass are preserved (this only changes what you specify).\n- Arguments are passed to the script as a JSON-encoded FARSEER_ARGS env var\n- Boolean dataType requires defaultValue \u2208 { \"true\", \"false\" }; defaultValue\n must be one of options when options is set\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n configureAppSchema,\n async (params: {\n organisation?: string;\n tenant?: string;\n appName: string;\n entrypoint?: string;\n sourceFolder?: string;\n description?: string;\n arguments?: Array<{\n name: string;\n dataType?: 'string' | 'boolean';\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n }>;\n newName?: string;\n }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const app = await clientResult.client.getAppByName(params.appName);\n if (!app) {\n return errorResponse(`App \"${params.appName}\" not found`, 'NOT_FOUND');\n }\n\n // The set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (params.newName) {\n changes.name = params.newName;\n }\n\n if (params.description !== undefined) {\n changes.description = params.description;\n }\n\n if (params.arguments) {\n // PUT semantics on the backend: this `expectedArguments`\n // array replaces the existing one wholesale. So if the\n // caller supplies a name but omits axes (dataType, fixed,\n // options, secret), we look up the existing arg by name\n // and carry those fields over. Without this merge, a\n // configure_app call that only re-sets defaultValue would\n // silently clear the secret flag or demote a dropdown\n // back to a plain string variable.\n //\n // Lookup is case-insensitive for convenience (caller\n // shouldn't have to remember exact casing to update an\n // existing arg), but on the write we keep the backend's\n // stored casing: validateExpectedArguments on the server\n // is case-sensitive (seen.has(arg.name)), so writing\n // back caller-supplied case would silently rename the\n // arg (e.g. jobName \u2192 JOBNAME) and break the next push.\n const existingByName = new Map(app.expectedArguments.map((e) => [e.name.toLowerCase(), e]));\n changes.expectedArguments = params.arguments.map((a) => {\n const existing = existingByName.get(a.name.toLowerCase());\n const arg: AppArgument = {\n name: existing?.name ?? a.name,\n dataType: a.dataType ?? existing?.dataType ?? 'string',\n };\n const fixed = a.fixed ?? existing?.fixed;\n if (fixed !== undefined) arg.fixed = fixed;\n const options = a.options ?? existing?.options;\n if (options !== undefined) arg.options = options;\n const defaultValue = a.defaultValue ?? existing?.defaultValue;\n if (defaultValue !== undefined) arg.defaultValue = defaultValue;\n const secret = a.secret ?? existing?.secret;\n if (secret !== undefined) arg.secret = secret;\n return arg;\n });\n }\n\n // Source folder + entrypoint. An app's scripts derive from its\n // source folder, and the entrypoint must be one of those files.\n // The decision lives in applySourceFolderChange (shared with the\n // CLI `app configure` command); the 'mcp' caller gets a plain,\n // param-worded error string.\n const sourceFolderError = await applySourceFolderChange(\n clientResult.client,\n app,\n changes,\n { sourceFolder: params.sourceFolder, entrypoint: params.entrypoint },\n 'mcp',\n );\n if (sourceFolderError) {\n return errorResponse(sourceFolderError, 'VALIDATION_ERROR');\n }\n\n const reference = app.id.toString();\n await clientResult.client.updateApp(reference, changes, app);\n\n return successResponse({\n tenant,\n appName: params.newName || params.appName,\n updated: Object.keys(changes),\n message: `App \"${params.appName}\" configured successfully`,\n });\n } catch (error) {\n return errorResponse(`Configure app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_app - Delete app\n s.tool(\n 'farseer_delete_app',\n `Delete an app from a Farseer tenant.\n\nWARNING: This is irreversible - the app will be permanently removed from the remote instance.\n\nThis does NOT delete the script files, only the app configuration.\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n deleteAppSchema,\n async (params: { organisation?: string; tenant?: string; appName: string }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n // Find the app in the folder listing to get the folder item_node ID\n // (getAppByName returns remoteJob ID which differs from folder item ID)\n const allApps = await clientResult.client.listApps();\n const appItem = allApps.find((a) => a.name.toLowerCase() === params.appName.toLowerCase());\n if (!appItem) {\n return errorResponse(`App \"${params.appName}\" not found`, 'NOT_FOUND');\n }\n\n await clientResult.client.deleteApp(appItem.id);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await clientResult.client.listApps();\n if (remaining.some((a) => a.id === appItem.id)) {\n return errorResponse(\n `Delete reported success but \"${params.appName}\" is still present`,\n 'NETWORK_ERROR',\n );\n }\n\n return successResponse({\n tenant,\n deletedApp: params.appName,\n message: `App \"${params.appName}\" has been deleted`,\n });\n } catch (error) {\n return errorResponse(`Delete app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n}\n"],
5
- "mapp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C3C,UAAI,CAAC,UAAU;AACX,mBAAO,uCAAuB;AAAA,MAClC;AACA,YAAM,EAAE,cAAc,OAAO,IAAI;AAEjC,YAAM,eAAe,UAAM,oDAA6B,cAAc,MAAM;AAC5E,UAAI,CAAC,cAAc;AACf,mBAAO,qCAAqB,MAAM;AAAA,MACtC;AAEA,UAAI;AAGA,cAAM,UAAU,MAAM,aAAa,OAAO,SAAS;AACnD,cAAM,UAAU,QAAQ,KAAK,CAAC,MAAM,EAAE,KAAK,YAAY,MAAM,OAAO,QAAQ,YAAY,CAAC;AACzF,YAAI,CAAC,SAAS;AACV,qBAAO,8BAAc,QAAQ,OAAO,OAAO,eAAe,WAAW;AAAA,QACzE;AAEA,cAAM,aAAa,OAAO,UAAU,QAAQ,EAAE;AAG9C,cAAM,YAAY,MAAM,aAAa,OAAO,SAAS;AACrD,YAAI,UAAU,KAAK,CAAC,MAAM,EAAE,OAAO,QAAQ,EAAE,GAAG;AAC5C,qBAAO;AAAA,YACH,gCAAgC,OAAO,OAAO;AAAA,YAC9C;AAAA,UACJ;AAAA,QACJ;AAEA,mBAAO,gCAAgB;AAAA,UACnB;AAAA,UACA,YAAY,OAAO;AAAA,UACnB,SAAS,QAAQ,OAAO,OAAO;AAAA,QACnC,CAAC;AAAA,MACL,SAAS,OAAO;AACZ,mBAAO,8BAAc,sBAAsB,UAAM,yCAAkB,KAAK,CAAC,IAAI,eAAe;AAAA,MAChG;AAAA,IACJ;AAAA,EACJ;AACJ;",
4
+ "sourcesContent": ["/**\n * App Management Tools\n *\n * Tools for managing Farseer apps (Remote Jobs).\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { getFarseerClientWithFallback } from '../../services/farseerFactory';\nimport { AppArgument, AppUpdateChanges, applySourceFolderChange } from '../../services/farseerApi';\nimport {\n getSessionTenant,\n successResponse,\n errorResponse,\n authRequiredResponse,\n tenantRequiredResponse,\n} from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Define schemas outside of tool registration to avoid deep type instantiation\nconst listAppsSchema = {\n details: z.boolean().optional().describe('Include full details for each app'),\n};\n\nconst getAppSchema = {\n appName: z.string().describe('Name of the app (can include spaces)'),\n};\n\nconst createAppSchema = {\n appName: z.string().describe('Name for the new app'),\n};\n\nexport const argumentSchema = z\n .object({\n name: z.string(),\n dataType: z.enum(['string', 'boolean']).optional().describe('Data type. Defaults to \"string\" if omitted.'),\n fixed: z\n .boolean()\n .optional()\n .describe('Lock the value at run time so users cannot override it (admin sets, user reads only).'),\n options: z\n .array(z.string())\n .optional()\n .describe('Closed allowed-value set. Only meaningful for string dataType.'),\n defaultValue: z.string().optional(),\n secret: z.boolean().optional().describe('Mask the value in inputs and logs.'),\n })\n // Cross-axis checks mirror the backend's `validateExpectedArguments` so an\n // LLM caller gets pre-request feedback. Backend stays authoritative \u2014 these\n // catch the same shapes earlier, they don't replace the validator.\n .refine(\n (a) => a.dataType !== 'boolean' || a.defaultValue === undefined || ['true', 'false'].includes(a.defaultValue),\n {\n message: 'Boolean argument defaultValue must be \"true\" or \"false\"',\n path: ['defaultValue'],\n },\n )\n .refine((a) => !a.options || a.defaultValue === undefined || a.options.includes(a.defaultValue), {\n message: 'defaultValue must be one of the options',\n path: ['defaultValue'],\n });\n\nconst configureAppSchema = {\n appName: z.string().describe('Name of the app to configure'),\n entrypoint: z\n .string()\n .optional()\n .describe('Main script filename \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")'),\n sourceFolder: z\n .string()\n .optional()\n .describe('Source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")'),\n description: z.string().optional().describe('App description'),\n arguments: z.array(argumentSchema).optional().describe('App arguments with default values'),\n newName: z.string().optional().describe('Rename the app'),\n};\n\nconst deleteAppSchema = {\n appName: z.string().describe('Name of the app to delete'),\n};\n\nexport function registerAppTools(server: McpServer): void {\n // Cast to avoid TS2589 deep type instantiation with MCP SDK + Zod generics\n const s: any = server;\n\n // farseer_list_apps - List all apps\n s.tool(\n 'farseer_list_apps',\n `List all apps (Remote Jobs) configured on a Farseer tenant.\n\nApps are executable script configurations that include:\n- Entry point script\n- List of included scripts\n- Expected arguments with default values\n\nUse details=true to include full information for each app.`,\n listAppsSchema,\n async (params: { details?: boolean }) => {\n const resolved = getSessionTenant();\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const appList = await clientResult.client.listApps();\n\n if (!params.details) {\n return successResponse({\n tenant,\n totalApps: appList.length,\n apps: appList.map((a) => ({\n name: a.name,\n id: a.id,\n reference: a.reference,\n })),\n });\n }\n\n // Get full details for each app\n const appsWithDetails = [];\n for (const item of appList) {\n const app = await clientResult.client.getApp(item.reference);\n if (app) {\n const appScripts = app.scriptFiles ?? [];\n const mainScript = appScripts.find((s) => s.id === app.mainScriptFileId);\n appsWithDetails.push({\n name: app.name,\n id: app.id,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: appScripts.map((s) => s.name),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n });\n }\n }\n\n return successResponse({\n tenant,\n totalApps: appsWithDetails.length,\n apps: appsWithDetails,\n });\n } catch (error) {\n return errorResponse(`List apps failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_app - Get app details\n s.tool(\n 'farseer_get_app',\n `Get detailed information about a specific Farseer app.\n\nReturns:\n- App name and description\n- Entry point script (main script that runs)\n- List of all included scripts\n- Expected arguments with their default values`,\n getAppSchema,\n async (params: { appName: string }) => {\n const resolved = getSessionTenant();\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const app = await clientResult.client.getAppByName(params.appName);\n\n if (!app) {\n return errorResponse(`App \"${params.appName}\" not found`, 'NOT_FOUND');\n }\n\n const getAppScripts = app.scriptFiles ?? [];\n const mainScript = getAppScripts.find((s) => s.id === app.mainScriptFileId);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: getAppScripts.map((s) => ({\n id: s.id,\n name: s.name,\n isEntrypoint: s.id === app.mainScriptFileId,\n })),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n status: app.status,\n lastHeartbeat: app.lastHeartbeat,\n },\n });\n } catch (error) {\n return errorResponse(`Get app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_app - Create new app\n s.tool(\n 'farseer_create_app',\n `Create a new Farseer app.\n\nA Farseer App is a named configuration that points to a TypeScript script and defines its arguments.\nThe script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).\n\nWorkflow to create a new app:\n1. Write the script at farseer-apps/<tenant>/files/Scripts/<name>.ts\n2. Push the script to remote with farseer_push (scripts must exist on remote first)\n3. Create the app with this tool (farseer_create_app)\n4. Configure it with farseer_configure_app (set entrypoint, scripts, arguments)\n5. Run it with farseer_run_app (CLI injects auth credentials automatically)\n\nScripts should use \\`new FarseerClient()\\` with no arguments - credentials are injected via environment variables by the CLI at runtime.`,\n createAppSchema,\n async (params: { appName: string }) => {\n const resolved = getSessionTenant();\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n // Check if app already exists\n const existing = await clientResult.client.getAppByName(params.appName);\n if (existing) {\n return errorResponse(`App \"${params.appName}\" already exists`, 'VALIDATION_ERROR');\n }\n\n const app = await clientResult.client.createApp(params.appName);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n },\n message: `App \"${params.appName}\" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`,\n });\n } catch (error) {\n return errorResponse(`Create app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_configure_app - Configure app settings\n s.tool(\n 'farseer_configure_app',\n `Configure an existing Farseer app.\n\nYou can set:\n- sourceFolder: Folder under Files/ the app's scripts come from (e.g. \"Scripts/MyApp\")\n- entrypoint: Main script to execute \u2014 must be a file in the source folder (e.g., \"index.ts\")\n- description: App description\n- arguments: List of expected arguments. Each has a name, optional dataType\n ('string' | 'boolean' \u2014 defaults to 'string'), optional fixed (locks the\n value at run time), optional options (closed allowed-value set, string\n dataType only), optional defaultValue, and optional secret.\n- newName: Rename the app\n\nImportant:\n- The app's scripts are derived from its source folder; the entrypoint must be\n one of those files. To use a script from another folder, set sourceFolder first.\n- Changing sourceFolder to a folder that doesn't contain the current entrypoint\n requires passing entrypoint in the same call.\n- Settings you don't pass are preserved (this only changes what you specify).\n- Arguments are passed to the script as a JSON-encoded FARSEER_ARGS env var\n- Boolean dataType requires defaultValue \u2208 { \"true\", \"false\" }; defaultValue\n must be one of options when options is set`,\n configureAppSchema,\n async (params: {\n appName: string;\n entrypoint?: string;\n sourceFolder?: string;\n description?: string;\n arguments?: Array<{\n name: string;\n dataType?: 'string' | 'boolean';\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n }>;\n newName?: string;\n }) => {\n const resolved = getSessionTenant();\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n const app = await clientResult.client.getAppByName(params.appName);\n if (!app) {\n return errorResponse(`App \"${params.appName}\" not found`, 'NOT_FOUND');\n }\n\n // The set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (params.newName) {\n changes.name = params.newName;\n }\n\n if (params.description !== undefined) {\n changes.description = params.description;\n }\n\n if (params.arguments) {\n // PUT semantics on the backend: this `expectedArguments`\n // array replaces the existing one wholesale. So if the\n // caller supplies a name but omits axes (dataType, fixed,\n // options, secret), we look up the existing arg by name\n // and carry those fields over. Without this merge, a\n // configure_app call that only re-sets defaultValue would\n // silently clear the secret flag or demote a dropdown\n // back to a plain string variable.\n //\n // Lookup is case-insensitive for convenience (caller\n // shouldn't have to remember exact casing to update an\n // existing arg), but on the write we keep the backend's\n // stored casing: validateExpectedArguments on the server\n // is case-sensitive (seen.has(arg.name)), so writing\n // back caller-supplied case would silently rename the\n // arg (e.g. jobName \u2192 JOBNAME) and break the next push.\n const existingByName = new Map(app.expectedArguments.map((e) => [e.name.toLowerCase(), e]));\n changes.expectedArguments = params.arguments.map((a) => {\n const existing = existingByName.get(a.name.toLowerCase());\n const arg: AppArgument = {\n name: existing?.name ?? a.name,\n dataType: a.dataType ?? existing?.dataType ?? 'string',\n };\n const fixed = a.fixed ?? existing?.fixed;\n if (fixed !== undefined) arg.fixed = fixed;\n const options = a.options ?? existing?.options;\n if (options !== undefined) arg.options = options;\n const defaultValue = a.defaultValue ?? existing?.defaultValue;\n if (defaultValue !== undefined) arg.defaultValue = defaultValue;\n const secret = a.secret ?? existing?.secret;\n if (secret !== undefined) arg.secret = secret;\n return arg;\n });\n }\n\n // Source folder + entrypoint. An app's scripts derive from its\n // source folder, and the entrypoint must be one of those files.\n // The decision lives in applySourceFolderChange (shared with the\n // CLI `app configure` command); the 'mcp' caller gets a plain,\n // param-worded error string.\n const sourceFolderError = await applySourceFolderChange(\n clientResult.client,\n app,\n changes,\n { sourceFolder: params.sourceFolder, entrypoint: params.entrypoint },\n 'mcp',\n );\n if (sourceFolderError) {\n return errorResponse(sourceFolderError, 'VALIDATION_ERROR');\n }\n\n const reference = app.id.toString();\n await clientResult.client.updateApp(reference, changes, app);\n\n return successResponse({\n tenant,\n appName: params.newName || params.appName,\n updated: Object.keys(changes),\n message: `App \"${params.appName}\" configured successfully`,\n });\n } catch (error) {\n return errorResponse(`Configure app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_app - Delete app\n s.tool(\n 'farseer_delete_app',\n `Delete an app from a Farseer tenant.\n\nWARNING: This is irreversible - the app will be permanently removed from the remote instance.\n\nThis does NOT delete the script files, only the app configuration.`,\n deleteAppSchema,\n async (params: { appName: string }) => {\n const resolved = getSessionTenant();\n if (!resolved) {\n return tenantRequiredResponse();\n }\n const { organisation, tenant } = resolved;\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n if (!clientResult) {\n return authRequiredResponse(tenant);\n }\n\n try {\n // Find the app in the folder listing to get the folder item_node ID\n // (getAppByName returns remoteJob ID which differs from folder item ID)\n const allApps = await clientResult.client.listApps();\n const appItem = allApps.find((a) => a.name.toLowerCase() === params.appName.toLowerCase());\n if (!appItem) {\n return errorResponse(`App \"${params.appName}\" not found`, 'NOT_FOUND');\n }\n\n await clientResult.client.deleteApp(appItem.id);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await clientResult.client.listApps();\n if (remaining.some((a) => a.id === appItem.id)) {\n return errorResponse(\n `Delete reported success but \"${params.appName}\" is still present`,\n 'NETWORK_ERROR',\n );\n }\n\n return successResponse({\n tenant,\n deletedApp: params.appName,\n message: `App \"${params.appName}\" has been deleted`,\n });\n } catch (error) {\n return errorResponse(`Delete app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\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AA,UACnB;AAAA,UACA,YAAY,OAAO;AAAA,UACnB,SAAS,QAAQ,OAAO,OAAO;AAAA,QACnC,CAAC;AAAA,MACL,SAAS,OAAO;AACZ,mBAAO,8BAAc,sBAAsB,UAAM,yCAAkB,KAAK,CAAC,IAAI,eAAe;AAAA,MAChG;AAAA,IACJ;AAAA,EACJ;AACJ;",
6
6
  "names": ["s"]
7
7
  }
@@ -30,8 +30,6 @@ const dimensionSchema = import_zod.z.object({
30
30
  dimensionValue: import_zod.z.string().describe('Dimension member value (e.g., "2024", "Widget A")')
31
31
  });
32
32
  const queryCellsSchema = {
33
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
34
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
35
33
  queries: import_zod.z.array(
36
34
  import_zod.z.object({
37
35
  variable: import_zod.z.string().describe("Variable name"),
@@ -58,13 +56,11 @@ Example query:
58
56
 
59
57
  Returns the value for each queried cell along with its dimension coordinates.
60
58
 
61
- To write data, use farseer_create_import_job instead \u2014 it provides audit trail and undo support.
62
-
63
- If no tenant is specified, uses the currently checked-out tenant.`,
59
+ To write data, use farseer_create_import_job instead \u2014 it provides audit trail and undo support.`,
64
60
  queryCellsSchema,
65
61
  // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
66
62
  async (params) => {
67
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
63
+ const resolved = (0, import_helpers.getSessionTenant)();
68
64
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
69
65
  const { organisation, tenant } = resolved;
70
66
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mcp/tools/cellTools.ts"],
4
- "sourcesContent": ["/**\n * Cell Tools\n *\n * MCP tools for querying cell values in Farseer.\n * For writing data, use farseer_create_import_job which provides audit trail and undo support.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { getNativeFarseerClient } from '../../services/farseerFactory';\nimport {\n resolveOrgAndTenant,\n successResponse,\n errorResponse,\n authRequiredResponse,\n tenantRequiredResponse,\n} from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Shared dimension schema\nconst dimensionSchema = z.object({\n dimensionTable: z.string().describe('Dimension table name (e.g., \"Years\", \"Product\")'),\n dimensionValue: z.string().describe('Dimension member value (e.g., \"2024\", \"Widget A\")'),\n});\n\n// Define schemas outside of tool registration to avoid TS2589\nconst queryCellsSchema = {\n organisation: z\n .string()\n .optional()\n .describe('Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping.'),\n tenant: z.string().optional().describe('Tenant ID. Uses checked-out tenant if omitted.'),\n queries: z\n .array(\n z.object({\n variable: z.string().describe('Variable name'),\n dimensions: z.array(dimensionSchema).describe('Dimension filters'),\n }),\n )\n .describe('Array of cell queries to execute'),\n};\n\nexport function registerCellTools(server: McpServer): void {\n // farseer_query_cells\n server.tool(\n 'farseer_query_cells',\n `Query cell values from a Farseer tenant.\n\nEach query specifies a variable name and dimension filters to locate specific cells.\nMultiple queries can be batched in a single call.\n\nExample query:\n{\n \"variable\": \"Revenue\",\n \"dimensions\": [\n { \"dimensionTable\": \"Years\", \"dimensionValue\": \"Y2025\" },\n { \"dimensionTable\": \"Product\", \"dimensionValue\": \"Widget A\" }\n ]\n}\n\nReturns the value for each queried cell along with its dimension coordinates.\n\nTo write data, use farseer_create_import_job instead \u2014 it provides audit trail and undo support.\n\nIf no tenant is specified, uses the currently checked-out tenant.`,\n queryCellsSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: {\n organisation?: string;\n tenant?: string;\n queries: Array<{\n variable: string;\n dimensions: Array<{ dimensionTable: string; dimensionValue: string }>;\n }>;\n }) => {\n const resolved = resolveOrgAndTenant(params);\n if (!resolved) return tenantRequiredResponse();\n const { organisation, tenant } = resolved;\n\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n if (!nativeClient) return authRequiredResponse(tenant);\n\n try {\n const results = await nativeClient.cells.query(params.queries);\n\n return successResponse({\n tenant,\n queryCount: params.queries.length,\n results,\n });\n } catch (error) {\n return errorResponse(`Query cells failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,iBAAkB;AAClB,4BAAuC;AACvC,qBAMO;AACP,4BAAkC;AAGlC,MAAM,kBAAkB,aAAE,OAAO;AAAA,EAC7B,gBAAgB,aAAE,OAAO,EAAE,SAAS,iDAAiD;AAAA,EACrF,gBAAgB,aAAE,OAAO,EAAE,SAAS,mDAAmD;AAC3F,CAAC;AAGD,MAAM,mBAAmB;AAAA,EACrB,cAAc,aACT,OAAO,EACP,SAAS,EACT,SAAS,sFAAsF;AAAA,EACpG,QAAQ,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gDAAgD;AAAA,EACvF,SAAS,aACJ;AAAA,IACG,aAAE,OAAO;AAAA,MACL,UAAU,aAAE,OAAO,EAAE,SAAS,eAAe;AAAA,MAC7C,YAAY,aAAE,MAAM,eAAe,EAAE,SAAS,mBAAmB;AAAA,IACrE,CAAC;AAAA,EACL,EACC,SAAS,kCAAkC;AACpD;AAEO,SAAS,kBAAkB,QAAyB;AAEvD,SAAO;AAAA,IACH;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmBA;AAAA;AAAA,IAEA,OAAO,WAOD;AACF,YAAM,eAAW,oCAAoB,MAAM;AAC3C,UAAI,CAAC,SAAU,YAAO,uCAAuB;AAC7C,YAAM,EAAE,cAAc,OAAO,IAAI;AAEjC,YAAM,eAAe,UAAM,8CAAuB,cAAc,MAAM;AACtE,UAAI,CAAC,aAAc,YAAO,qCAAqB,MAAM;AAErD,UAAI;AACA,cAAM,UAAU,MAAM,aAAa,MAAM,MAAM,OAAO,OAAO;AAE7D,mBAAO,gCAAgB;AAAA,UACnB;AAAA,UACA,YAAY,OAAO,QAAQ;AAAA,UAC3B;AAAA,QACJ,CAAC;AAAA,MACL,SAAS,OAAO;AACZ,mBAAO,8BAAc,uBAAuB,UAAM,yCAAkB,KAAK,CAAC,IAAI,eAAe;AAAA,MACjG;AAAA,IACJ;AAAA,EACJ;AACJ;",
4
+ "sourcesContent": ["/**\n * Cell Tools\n *\n * MCP tools for querying cell values in Farseer.\n * For writing data, use farseer_create_import_job which provides audit trail and undo support.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { getNativeFarseerClient } from '../../services/farseerFactory';\nimport {\n getSessionTenant,\n successResponse,\n errorResponse,\n authRequiredResponse,\n tenantRequiredResponse,\n} from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Shared dimension schema\nconst dimensionSchema = z.object({\n dimensionTable: z.string().describe('Dimension table name (e.g., \"Years\", \"Product\")'),\n dimensionValue: z.string().describe('Dimension member value (e.g., \"2024\", \"Widget A\")'),\n});\n\n// Define schemas outside of tool registration to avoid TS2589\nconst queryCellsSchema = {\n queries: z\n .array(\n z.object({\n variable: z.string().describe('Variable name'),\n dimensions: z.array(dimensionSchema).describe('Dimension filters'),\n }),\n )\n .describe('Array of cell queries to execute'),\n};\n\nexport function registerCellTools(server: McpServer): void {\n // farseer_query_cells\n server.tool(\n 'farseer_query_cells',\n `Query cell values from a Farseer tenant.\n\nEach query specifies a variable name and dimension filters to locate specific cells.\nMultiple queries can be batched in a single call.\n\nExample query:\n{\n \"variable\": \"Revenue\",\n \"dimensions\": [\n { \"dimensionTable\": \"Years\", \"dimensionValue\": \"Y2025\" },\n { \"dimensionTable\": \"Product\", \"dimensionValue\": \"Widget A\" }\n ]\n}\n\nReturns the value for each queried cell along with its dimension coordinates.\n\nTo write data, use farseer_create_import_job instead \u2014 it provides audit trail and undo support.`,\n queryCellsSchema,\n // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas\n async (params: {\n queries: Array<{\n variable: string;\n dimensions: Array<{ dimensionTable: string; dimensionValue: string }>;\n }>;\n }) => {\n const resolved = getSessionTenant();\n if (!resolved) return tenantRequiredResponse();\n const { organisation, tenant } = resolved;\n\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n if (!nativeClient) return authRequiredResponse(tenant);\n\n try {\n const results = await nativeClient.cells.query(params.queries);\n\n return successResponse({\n tenant,\n queryCount: params.queries.length,\n results,\n });\n } catch (error) {\n return errorResponse(`Query cells failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,iBAAkB;AAClB,4BAAuC;AACvC,qBAMO;AACP,4BAAkC;AAGlC,MAAM,kBAAkB,aAAE,OAAO;AAAA,EAC7B,gBAAgB,aAAE,OAAO,EAAE,SAAS,iDAAiD;AAAA,EACrF,gBAAgB,aAAE,OAAO,EAAE,SAAS,mDAAmD;AAC3F,CAAC;AAGD,MAAM,mBAAmB;AAAA,EACrB,SAAS,aACJ;AAAA,IACG,aAAE,OAAO;AAAA,MACL,UAAU,aAAE,OAAO,EAAE,SAAS,eAAe;AAAA,MAC7C,YAAY,aAAE,MAAM,eAAe,EAAE,SAAS,mBAAmB;AAAA,IACrE,CAAC;AAAA,EACL,EACC,SAAS,kCAAkC;AACpD;AAEO,SAAS,kBAAkB,QAAyB;AAEvD,SAAO;AAAA,IACH;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAiBA;AAAA;AAAA,IAEA,OAAO,WAKD;AACF,YAAM,eAAW,iCAAiB;AAClC,UAAI,CAAC,SAAU,YAAO,uCAAuB;AAC7C,YAAM,EAAE,cAAc,OAAO,IAAI;AAEjC,YAAM,eAAe,UAAM,8CAAuB,cAAc,MAAM;AACtE,UAAI,CAAC,aAAc,YAAO,qCAAqB,MAAM;AAErD,UAAI;AACA,cAAM,UAAU,MAAM,aAAa,MAAM,MAAM,OAAO,OAAO;AAE7D,mBAAO,gCAAgB;AAAA,UACnB;AAAA,UACA,YAAY,OAAO,QAAQ;AAAA,UAC3B;AAAA,QACJ,CAAC;AAAA,MACL,SAAS,OAAO;AACZ,mBAAO,8BAAc,uBAAuB,UAAM,yCAAkB,KAAK,CAAC,IAAI,eAAe;AAAA,MACjG;AAAA,IACJ;AAAA,EACJ;AACJ;",
6
6
  "names": []
7
7
  }
@@ -82,30 +82,20 @@ async function collectDashboardsWithPaths(client, folderId, currentPath) {
82
82
  return items;
83
83
  }
84
84
  const listDashboardsSchema = {
85
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
86
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
87
85
  includeFolderPath: import_zod.z.boolean().optional().describe("Include folder path for each dashboard (slower, traverses folder tree). Default: false.")
88
86
  };
89
87
  const getDashboardSchema = {
90
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
91
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
92
88
  dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
93
89
  includeTiles: import_zod.z.boolean().optional().describe("Include tile details in response (default: true)")
94
90
  };
95
91
  const listTilesSchema = {
96
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
97
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
98
92
  dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID")
99
93
  };
100
94
  const getTileSchema = {
101
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
102
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
103
95
  dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
104
96
  tileId: import_zod.z.number().describe("Tile ID")
105
97
  };
106
98
  const createTileSchema = {
107
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
108
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
109
99
  dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
110
100
  tile: import_zod.z.record(import_zod.z.any()).describe(
111
101
  `Full tile configuration as JSON. Structure:
@@ -126,8 +116,6 @@ For TEXT tiles, data includes: rawContent (rich text object).`
126
116
  )
127
117
  };
128
118
  const updateTileSchema = {
129
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
130
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
131
119
  dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
132
120
  tileId: import_zod.z.number().describe("Tile ID to update"),
133
121
  tile: import_zod.z.record(import_zod.z.any()).describe(
@@ -152,8 +140,6 @@ Example: ["rowVisualizationByPath", "columnVisualizationByPath"]`
152
140
  )
153
141
  };
154
142
  const duplicateDashboardSchema = {
155
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
156
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
157
143
  dashboardNameOrId: import_zod.z.string().describe("Source dashboard name or numeric ID to duplicate"),
158
144
  name: import_zod.z.string().describe("Name for the new dashboard"),
159
145
  folderId: import_zod.z.number().optional().describe("Target folder ID. If omitted, duplicates to root Dashboards folder."),
@@ -168,12 +154,10 @@ Dashboards contain tiles that display charts, tables, and other visualizations.
168
154
  Returns dashboard IDs, names, and tile counts.
169
155
 
170
156
  Set includeFolderPath=true to also show the folder path for each dashboard
171
- (this is slower as it traverses the folder tree).
172
-
173
- If no tenant is specified, uses the currently checked-out tenant.`,
157
+ (this is slower as it traverses the folder tree).`,
174
158
  listDashboardsSchema,
175
159
  async (params) => {
176
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
160
+ const resolved = (0, import_helpers.getSessionTenant)();
177
161
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
178
162
  const { organisation, tenant } = resolved;
179
163
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -208,12 +192,10 @@ If no tenant is specified, uses the currently checked-out tenant.`,
208
192
  `Get detailed information about a specific dashboard.
209
193
 
210
194
  Returns dashboard configuration and optionally its tiles.
211
- Accepts either a dashboard name or numeric ID.
212
-
213
- If no tenant is specified, uses the currently checked-out tenant.`,
195
+ Accepts either a dashboard name or numeric ID.`,
214
196
  getDashboardSchema,
215
197
  async (params) => {
216
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
198
+ const resolved = (0, import_helpers.getSessionTenant)();
217
199
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
218
200
  const { organisation, tenant } = resolved;
219
201
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -258,12 +240,10 @@ If no tenant is specified, uses the currently checked-out tenant.`,
258
240
  Returns tile IDs, names, types (TEXT, SHEET_BACKED, DIMENSION_SLICER),
259
241
  grid placements, and associated sheet IDs for SHEET_BACKED tiles.
260
242
 
261
- Accepts either a dashboard name or numeric ID.
262
-
263
- If no tenant is specified, uses the currently checked-out tenant.`,
243
+ Accepts either a dashboard name or numeric ID.`,
264
244
  listTilesSchema,
265
245
  async (params) => {
266
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
246
+ const resolved = (0, import_helpers.getSessionTenant)();
267
247
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
268
248
  const { organisation, tenant } = resolved;
269
249
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -309,13 +289,11 @@ and style settings.
309
289
  This is essential for understanding the tile structure before modifying it
310
290
  with farseer_update_tile.
311
291
 
312
- Accepts either a dashboard name or numeric ID.
313
-
314
- If no tenant is specified, uses the currently checked-out tenant.`,
292
+ Accepts either a dashboard name or numeric ID.`,
315
293
  getTileSchema,
316
294
  // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
317
295
  async (params) => {
318
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
296
+ const resolved = (0, import_helpers.getSessionTenant)();
319
297
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
320
298
  const { organisation, tenant } = resolved;
321
299
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -351,13 +329,11 @@ Tile types:
351
329
  Grid placements use a responsive grid system:
352
330
  gridPlacements: { "lg": { "x": 0, "y": 0, "w": 6, "h": 4 } }
353
331
 
354
- Style options: showBackground, backgroundColor, showBorder, borderColor, hasShadow, showSubtitle, showFootnotes.
355
-
356
- If no tenant is specified, uses the currently checked-out tenant.`,
332
+ Style options: showBackground, backgroundColor, showBorder, borderColor, hasShadow, showSubtitle, showFootnotes.`,
357
333
  createTileSchema,
358
334
  // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
359
335
  async (params) => {
360
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
336
+ const resolved = (0, import_helpers.getSessionTenant)();
361
337
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
362
338
  const { organisation, tenant } = resolved;
363
339
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -420,13 +396,11 @@ Example - update just the visualization:
420
396
  }
421
397
  }
422
398
 
423
- WARNING: This modifies dashboard configuration. Use with caution.
424
-
425
- If no tenant is specified, uses the currently checked-out tenant.`,
399
+ WARNING: This modifies dashboard configuration. Use with caution.`,
426
400
  updateTileSchema,
427
401
  // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
428
402
  async (params) => {
429
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
403
+ const resolved = (0, import_helpers.getSessionTenant)();
430
404
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
431
405
  const { organisation, tenant } = resolved;
432
406
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -472,18 +446,14 @@ If no tenant is specified, uses the currently checked-out tenant.`,
472
446
  Permanently removes the tile identified by its numeric ID.
473
447
  Use farseer_list_tiles to find tile IDs first.
474
448
 
475
- WARNING: This is destructive and cannot be undone.
476
-
477
- If no tenant is specified, uses the currently checked-out tenant.`,
449
+ WARNING: This is destructive and cannot be undone.`,
478
450
  {
479
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
480
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
481
451
  dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
482
452
  tileId: import_zod.z.number().describe("Tile ID to delete")
483
453
  },
484
454
  // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
485
455
  async (params) => {
486
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
456
+ const resolved = (0, import_helpers.getSessionTenant)();
487
457
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
488
458
  const { organisation, tenant } = resolved;
489
459
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -516,19 +486,15 @@ NOTE: The backend does not accept columns/rows config on create.
516
486
  Create the dashboard first, then use farseer_update_dashboard to configure
517
487
  timeline (columns), comparison (rows), and options.
518
488
 
519
- If no folder is specified, creates in the root Dashboards folder.
520
-
521
- If no tenant is specified, uses the currently checked-out tenant.`,
489
+ If no folder is specified, creates in the root Dashboards folder.`,
522
490
  {
523
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
524
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
525
491
  name: import_zod.z.string().describe("Dashboard name"),
526
492
  folderId: import_zod.z.number().optional().describe("Target folder ID. If omitted, uses root Dashboards folder."),
527
493
  folderPath: import_zod.z.array(import_zod.z.string()).optional().describe('Target folder path as array (e.g., ["Dashboards", "Reports"]). Alternative to folderId.')
528
494
  },
529
495
  // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
530
496
  async (params) => {
531
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
497
+ const resolved = (0, import_helpers.getSessionTenant)();
532
498
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
533
499
  const { organisation, tenant } = resolved;
534
500
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -590,12 +556,8 @@ Example - change name and timeline:
590
556
  "columns": { "intervalToolbar": { ... } }
591
557
  }
592
558
 
593
- WARNING: This modifies dashboard configuration. Use with caution.
594
-
595
- If no tenant is specified, uses the currently checked-out tenant.`,
559
+ WARNING: This modifies dashboard configuration. Use with caution.`,
596
560
  {
597
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
598
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
599
561
  dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID"),
600
562
  update: import_zod.z.record(import_zod.z.any()).describe(
601
563
  "Dashboard fields to update. Supported: name, columns (timeline config), rows (comparison config), options."
@@ -603,7 +565,7 @@ If no tenant is specified, uses the currently checked-out tenant.`,
603
565
  },
604
566
  // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
605
567
  async (params) => {
606
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
568
+ const resolved = (0, import_helpers.getSessionTenant)();
607
569
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
608
570
  const { organisation, tenant } = resolved;
609
571
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -639,16 +601,12 @@ If no tenant is specified, uses the currently checked-out tenant.`,
639
601
  `Delete a dashboard.
640
602
 
641
603
  WARNING: This is destructive. The backend may return 405 Method Not Allowed
642
- if dashboard deletion is not supported for the tenant.
643
-
644
- If no tenant is specified, uses the currently checked-out tenant.`,
604
+ if dashboard deletion is not supported for the tenant.`,
645
605
  {
646
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted, uses checked-out org or saved mapping."),
647
- tenant: import_zod.z.string().optional().describe("Tenant ID. Uses checked-out tenant if omitted."),
648
606
  dashboardNameOrId: import_zod.z.string().describe("Dashboard name or numeric ID")
649
607
  },
650
608
  async (params) => {
651
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
609
+ const resolved = (0, import_helpers.getSessionTenant)();
652
610
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
653
611
  const { organisation, tenant } = resolved;
654
612
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
@@ -677,13 +635,11 @@ If no tenant is specified, uses the currently checked-out tenant.`,
677
635
  Creates a copy of the source dashboard with all its tiles.
678
636
  Specify folderId directly or use folderPath to resolve the target folder.
679
637
 
680
- If no folder is specified, duplicates to the root Dashboards folder.
681
-
682
- If no tenant is specified, uses the currently checked-out tenant.`,
638
+ If no folder is specified, duplicates to the root Dashboards folder.`,
683
639
  duplicateDashboardSchema,
684
640
  // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
685
641
  async (params) => {
686
- const resolved = (0, import_helpers.resolveOrgAndTenant)(params);
642
+ const resolved = (0, import_helpers.getSessionTenant)();
687
643
  if (!resolved) return (0, import_helpers.tenantRequiredResponse)();
688
644
  const { organisation, tenant } = resolved;
689
645
  const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);