@lightdash-tools/mcp 0.17.0 → 0.18.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.
@@ -2,7 +2,7 @@
2
2
  * Content response envelope helpers (RFC §10 / ADR-0006).
3
3
  */
4
4
  import type { ProfileId } from '@lightdash-tools/common';
5
- export type ContentReaderWarningCode = 'CACHE_STALE' | 'FILTER_IGNORED' | 'PARAMETER_DEFAULTED' | 'PARTIAL_RESULT' | 'QUERY_RUNNING' | 'QUERY_TIMEOUT' | 'REDACTED' | 'SQL_EXECUTION_DISABLED' | 'STALE_CONTENT' | 'TRUNCATED' | 'UNSUPPORTED_TILE' | 'UNVERIFIED_CONTENT';
5
+ export type ContentReaderWarningCode = 'CACHE_STALE' | 'DATE_ZOOM_IGNORED' | 'FILTER_IGNORED' | 'PARAMETER_DEFAULTED' | 'PARTIAL_RESULT' | 'QUERY_RUNNING' | 'QUERY_TIMEOUT' | 'REDACTED' | 'SQL_EXECUTION_DISABLED' | 'SQL_RESULT_MAY_BE_ROW_LEVEL' | 'STALE_CONTENT' | 'TRUNCATED' | 'UNSUPPORTED_TILE' | 'UNVERIFIED_CONTENT';
6
6
  export type ContentReaderWarning = {
7
7
  code: ContentReaderWarningCode;
8
8
  message: string;
@@ -12,7 +12,7 @@ export declare const CONTENT_READER_INVARIANTS: readonly [{
12
12
  readonly short: "Do not download or bulk-export results.";
13
13
  }, {
14
14
  readonly id: "no-sql-chart-execution";
15
- readonly short: "Do not execute saved SQL charts (disabled by default on content-reader).";
15
+ readonly short: "Do not execute ad-hoc SQL or standalone SQL charts; saved dashboard SQL tiles are allowed.";
16
16
  }, {
17
17
  readonly id: "no-override-semantics";
18
18
  readonly short: "Do not override filter targets, operators, required-filter behavior, fields, metrics, dimensions, SQL, table calculations, or sorts.";
@@ -20,7 +20,7 @@ exports.CONTENT_READER_INVARIANTS = [
20
20
  },
21
21
  {
22
22
  id: 'no-sql-chart-execution',
23
- short: 'Do not execute saved SQL charts (disabled by default on content-reader).',
23
+ short: 'Do not execute ad-hoc SQL or standalone SQL charts; saved dashboard SQL tiles are allowed.',
24
24
  },
25
25
  {
26
26
  id: 'no-override-semantics',
@@ -22,7 +22,7 @@ Compare **definitions before values**. Matching titles/labels ≠ same metric, g
22
22
 
23
23
  Execute **only** if sides are structurally comparable **or** the user asked about value differences. Use equivalent valid context (same overrides if any). Cap at **≤2** executions unless the user expands scope.
24
24
 
25
- Skip execution when either side is SQL / non-executable — report that as a confirmed blocker.
25
+ Skip execution when either side is a **standalone** SQL chart (`run_chart` / `source=sql`) or otherwise non-executable — report that as a confirmed blocker. Dashboard `sql_chart` tiles may be executed via `run_dashboard_tile`.
26
26
 
27
27
  ## Report causes
28
28
 
@@ -11,7 +11,7 @@ Discover, explain, and **optionally execute** saved Lightdash charts/dashboards
11
11
  - Do not mutate Lightdash resources (create/update/delete/move/promote).
12
12
  - Do not execute arbitrary metric queries, raw SQL, SQL runner, or underlying-data downloads.
13
13
  - Do not bulk-export or page endlessly through result sets.
14
- - Do not execute saved SQL charts (`source=sql` / `chartType=sql`); default capability is off (`canExecuteSqlCharts=false`).
14
+ - Do not execute ad-hoc SQL, SQL runner, or standalone SQL charts (`source=sql` / `chartType=sql`; `canExecuteSqlCharts=false`). Saved dashboard SQL tiles (`sql_chart`, `canExecuteDashboardSqlTiles=true`) may be executed via `run_dashboard_tile`.
15
15
  - Do not override filter **targets/operators**, required-filter behavior, fields, metrics, dimensions, SQL, table calculations, or sorts — only allowed **value** overrides on existing filter ids / known parameters.
16
16
  - Do not execute content outside the resolved project.
17
17
  - Do not present truncated / incomplete coverage as a full answer.
@@ -57,7 +57,7 @@ Record budget / pagination / truncation stops in the answer.
57
57
  ## Phase 0 — Resolve project
58
58
 
59
59
  1. Always pass **`projectUuid`** (or rely on HTTP `X-Lightdash-Project` pin). Without either → `PROJECT_SCOPE_REQUIRED`; stop.
60
- 2. Call `get_project`. Record UUID, name, `context.projectPinned`, and `readerCapabilities` (`canExecuteSavedCharts`, `canExecuteSqlCharts`, `canExecuteDashboardTiles`).
60
+ 2. Call `get_project`. Record UUID, name, `context.projectPinned`, and `readerCapabilities` (`canExecuteSavedCharts`, `canExecuteSqlCharts`, `canExecuteDashboardTiles`, `canExecuteDashboardSqlTiles`).
61
61
  3. There is **no** org-wide project list on this profile — never invent one.
62
62
 
63
63
  ## Answer shape
@@ -19,7 +19,7 @@ When the user asks for trusted / canonical / verified content, or the prompt set
19
19
  1. Prefer **short, high-signal tokens** that appear in titles (product names, Japanese KPI words). Multi-word English phrases often return **zero** hits even when related content exists.
20
20
  2. If the first query is empty, try: alternate language tokens, a single keyword, `spaceUuids` / `parentSpaceUuid`, or browse with `sortBy=views` + `sortDirection=desc` (optional empty/`query` omitted) and then refine.
21
21
  3. Always set `pageSize` (≤25). Prefer `contentTypes` when the user asked for charts vs dashboards.
22
- 4. Read `source` on chart hits: `dbt_explore` (or similar semantic) vs `sql`. Treat `sql` as **not executable** on this profile.
22
+ 4. Read `source` on chart hits: `dbt_explore` (or similar semantic) vs `sql`. Treat `sql` as **not executable via `run_chart`**. Dashboard `sql_chart` tiles are executable via `run_dashboard_tile` when `canExecuteDashboardSqlTiles=true`.
23
23
  5. Ranking heuristics when relevance ties (after verified preference above):
24
24
  - Higher `views` / pinned (`pinnedList` non-null)
25
25
  - Richer description / clearer name match
@@ -5,18 +5,19 @@ URI: `lightdash://playbooks/content-reader/explain-run`
5
5
  ## Inspect metadata first
6
6
 
7
7
  1. Charts: `get_chart` (set `includeQueryDefinition=true` when filters/metrics matter) and/or `explain_content`.
8
- 2. Dashboards: `get_dashboard` with `includeTiles=true` (and filters when needed). Tile objects use **`tileUuid`** (not `uuid`), plus `type`, `title`, `chartUuid`, `executable`.
8
+ 2. Dashboards: `get_dashboard` with `includeTiles=true` (and filters when needed). Tile objects use **`tileUuid`** (not `uuid`), plus `type`, `title`, `chartUuid` / `savedSqlUuid`, `executable`.
9
9
  3. Parameters: `list_project_parameters` / `get_project_parameters` only when the content references parameters or the user asks to override values.
10
10
  4. Distinguish **explicit** description/filters/fieldIds from **inferred** business meaning. Chart descriptions often document population caveats — quote them.
11
11
 
12
12
  ## SQL vs semantic (critical)
13
13
 
14
- | Signal | Action |
15
- | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
16
- | Search `source=sql` | Do **not** call `run_chart`; explain metadata only; cite `CONTENT_NOT_EXECUTABLE` / capability |
17
- | `get_chart` → `chartType=sql` + warnings | Same — saved SQL **chart** body hidden; execution disabled |
18
- | Opaque API errors (e.g. “Saved query not found”) on SQL ids | Treat as non-executable; do not retry endlessly |
19
- | `readerCapabilities.canExecuteSqlCharts=false` | Hard stop for SQL execution |
14
+ | Signal | Action |
15
+ | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
16
+ | Search `source=sql` | Do **not** call `run_chart`; explain metadata only; cite `CONTENT_NOT_EXECUTABLE` / `canExecuteSqlCharts=false` |
17
+ | `get_chart` → `chartType=sql` + warnings | Same — saved SQL **chart** body hidden; standalone execution disabled |
18
+ | Dashboard tile `type=sql_chart` and `executable=true` | Call `run_dashboard_tile` (not `run_chart`). Cite `canExecuteDashboardSqlTiles=true`. SQL text stays hidden |
19
+ | Opaque API errors (e.g. “Saved query not found”) on SQL ids | Treat as non-executable; do not retry endlessly |
20
+ | `readerCapabilities.canExecuteSqlCharts=false` | Hard stop for **standalone** SQL chart execution (`run_chart`); dashboard SQL tiles use the dashboard-sql-chart API |
20
21
 
21
22
  ## Decide whether to execute
22
23
 
@@ -33,11 +34,12 @@ Defaults: `useCache=true`, modest `limit` (≤100; summarize ≤20 rows in the a
33
34
 
34
35
  ## Dashboard tile execution
35
36
 
36
- 1. Pick tiles with `executable=true` and a `chartUuid` (skip markdown / non-chart tiles).
37
- 2. Call `run_dashboard_tile` with dashboard UUID/slug + **`tileUuid`** from `get_dashboard`.
37
+ 1. Pick tiles with `executable=true` (semantic `saved_chart` with `chartUuid`, or `sql_chart` with `savedSqlUuid`). Skip markdown / heading / other non-chart tiles.
38
+ 2. Call `run_dashboard_tile` with dashboard UUID/slug + **`tileUuid`** from `get_dashboard`. Do not use `run_chart` for dashboard SQL tiles.
38
39
  3. Preserve dashboard context; only pass `filterOverrides` / `parameterOverrides` for **existing** filter ids / known parameter names with **values** (never retarget filters).
39
- 4. Optional **date zoom**: pass `dateZoom: { granularity?, xAxisFieldId? }` when the user asks to simulate a zoom ([date zoom](https://docs.lightdash.com/guides/date-zoom)). Otherwise execution uses the dashboard’s saved default granularity. Cite `appliedDateZoom` in the report when present.
40
- 5. Cap tiles per summary (`maximumTiles` / budget ≤5). Unexecuted tiles must not support conclusions.
40
+ 4. Optional **date zoom** on **semantic** tiles: pass `dateZoom: { granularity?, xAxisFieldId? }` when the user asks to simulate a zoom ([date zoom](https://docs.lightdash.com/guides/date-zoom)). SQL tiles ignore `dateZoom` (`DATE_ZOOM_IGNORED`); the dashboard default granularity applies. Cite `appliedDateZoom` when present.
41
+ 5. SQL tile rows may be grain-level (`SQL_RESULT_MAY_BE_ROW_LEVEL`) — do not treat them as semantic aggregates.
42
+ 6. Cap tiles per summary (`maximumTiles` / budget ≤5). Unexecuted tiles must not support conclusions.
41
43
 
42
44
  ## Async handles
43
45
 
@@ -18,6 +18,7 @@ const READER_CAPABILITIES = {
18
18
  canExecuteSavedCharts: true,
19
19
  canExecuteSqlCharts: false,
20
20
  canExecuteDashboardTiles: true,
21
+ canExecuteDashboardSqlTiles: true,
21
22
  };
22
23
  const DEVELOPER_CAPABILITIES = {
23
24
  canDiscoverContent: true,
@@ -176,6 +176,7 @@ function mockContext(listProjects, getProject) {
176
176
  canExecuteSavedCharts: true,
177
177
  canExecuteSqlCharts: false,
178
178
  canExecuteDashboardTiles: true,
179
+ canExecuteDashboardSqlTiles: true,
179
180
  });
180
181
  (0, vitest_1.expect)(body.context.projectUuid).toBe(PINNED);
181
182
  (0, vitest_1.expect)(getProject).toHaveBeenCalledWith(PINNED);
@@ -4,8 +4,48 @@
4
4
  import type { McpContextProvider } from '../../server/request-context.js';
5
5
  import type { McpServer } from '@modelcontextprotocol/server';
6
6
  export declare function detectChartType(chart: Record<string, unknown>): 'semantic' | 'sql' | 'unknown';
7
+ export type DashboardTileClass = {
8
+ kind: 'not_executable';
9
+ reason: 'missing_saved_sql_uuid' | 'unsupported_type';
10
+ tileType: string;
11
+ } | {
12
+ kind: 'saved_chart';
13
+ } | {
14
+ kind: 'sql_chart';
15
+ savedSqlUuid: string;
16
+ };
17
+ /** Shared execute/discovery rule: semantic tiles by type; SQL tiles need savedSqlUuid. */
18
+ export declare function classifyDashboardTile(type: string, props: Record<string, unknown>): DashboardTileClass;
7
19
  /** Pass through OpenAPI TableCalculation fields agents need to clone. */
8
20
  export declare function toReaderTableCalculation(tc: unknown): Record<string, unknown>;
21
+ export declare function toReaderDashboard(dashboard: Record<string, unknown>, includeTiles: boolean): {
22
+ description: unknown;
23
+ filters: unknown;
24
+ name: unknown;
25
+ parameters: unknown;
26
+ slug: unknown;
27
+ space: {
28
+ name: unknown;
29
+ uuid: unknown;
30
+ };
31
+ tabs: unknown;
32
+ tiles: Array<{
33
+ chartKind: unknown;
34
+ chartName: unknown;
35
+ chartSlug: unknown;
36
+ chartUuid: unknown;
37
+ executable: boolean;
38
+ savedSqlUuid: unknown;
39
+ tabUuid: unknown;
40
+ tileUuid: unknown;
41
+ title: unknown;
42
+ type: string;
43
+ }> | undefined;
44
+ updatedAt: unknown;
45
+ uuid: unknown;
46
+ verification: unknown;
47
+ views: unknown;
48
+ };
9
49
  export declare function registerSearchContent(server: McpServer, contextProvider: McpContextProvider): void;
10
50
  export declare function registerListVerifiedContent(server: McpServer, contextProvider: McpContextProvider): void;
11
51
  export declare function registerGetDashboard(server: McpServer, contextProvider: McpContextProvider): void;
@@ -5,7 +5,9 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getChartTool = exports.getDashboardTool = exports.listVerifiedContentTool = exports.searchContentTool = void 0;
7
7
  exports.detectChartType = detectChartType;
8
+ exports.classifyDashboardTile = classifyDashboardTile;
8
9
  exports.toReaderTableCalculation = toReaderTableCalculation;
10
+ exports.toReaderDashboard = toReaderDashboard;
9
11
  exports.registerSearchContent = registerSearchContent;
10
12
  exports.registerListVerifiedContent = registerListVerifiedContent;
11
13
  exports.registerGetDashboard = registerGetDashboard;
@@ -32,6 +34,20 @@ function detectChartType(chart) {
32
34
  }
33
35
  return 'unknown';
34
36
  }
37
+ /** Shared execute/discovery rule: semantic tiles by type; SQL tiles need savedSqlUuid. */
38
+ function classifyDashboardTile(type, props) {
39
+ if (type === 'saved_chart') {
40
+ return { kind: 'saved_chart' };
41
+ }
42
+ if (type === 'sql_chart') {
43
+ const savedSqlUuid = props.savedSqlUuid;
44
+ if (typeof savedSqlUuid === 'string' && savedSqlUuid.length > 0) {
45
+ return { kind: 'sql_chart', savedSqlUuid };
46
+ }
47
+ return { kind: 'not_executable', tileType: type, reason: 'missing_saved_sql_uuid' };
48
+ }
49
+ return { kind: 'not_executable', tileType: type, reason: 'unsupported_type' };
50
+ }
35
51
  /** Pass through OpenAPI TableCalculation fields agents need to clone. */
36
52
  function toReaderTableCalculation(tc) {
37
53
  const row = (tc !== null && tc !== void 0 ? tc : {});
@@ -105,17 +121,17 @@ function toReaderDashboard(dashboard, includeTiles) {
105
121
  const t = tile;
106
122
  const props = ((_a = t.properties) !== null && _a !== void 0 ? _a : {});
107
123
  const type = typeof t.type === 'string' ? t.type : 'unknown';
108
- const executable = type === 'saved_chart';
109
124
  return {
110
125
  tileUuid: t.uuid,
111
126
  tabUuid: t.tabUuid,
112
127
  type,
113
128
  title: (_b = props.title) !== null && _b !== void 0 ? _b : props.chartName,
114
129
  chartUuid: (_c = props.savedChartUuid) !== null && _c !== void 0 ? _c : props.chartUuid,
130
+ savedSqlUuid: props.savedSqlUuid,
115
131
  chartSlug: props.chartSlug,
116
132
  chartName: props.chartName,
117
133
  chartKind: props.chartKind,
118
- executable,
134
+ executable: classifyDashboardTile(type, props).kind !== 'not_executable',
119
135
  };
120
136
  })
121
137
  : undefined;
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Unit tests for get_chart table-calculation pass-through.
2
+ * Unit tests for get_chart table-calculation pass-through and dashboard tile flags.
3
3
  */
4
4
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Unit tests for get_chart table-calculation pass-through.
3
+ * Unit tests for get_chart table-calculation pass-through and dashboard tile flags.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const vitest_1 = require("vitest");
@@ -62,3 +62,79 @@ const reader_content_js_1 = require("./reader-content.js");
62
62
  });
63
63
  });
64
64
  });
65
+ (0, vitest_1.describe)('classifyDashboardTile', () => {
66
+ (0, vitest_1.it)('treats saved_chart as executable by type', () => {
67
+ (0, vitest_1.expect)((0, reader_content_js_1.classifyDashboardTile)('saved_chart', {})).toEqual({ kind: 'saved_chart' });
68
+ });
69
+ (0, vitest_1.it)('requires savedSqlUuid for sql_chart', () => {
70
+ (0, vitest_1.expect)((0, reader_content_js_1.classifyDashboardTile)('sql_chart', { savedSqlUuid: 'sql-1' })).toEqual({
71
+ kind: 'sql_chart',
72
+ savedSqlUuid: 'sql-1',
73
+ });
74
+ (0, vitest_1.expect)((0, reader_content_js_1.classifyDashboardTile)('sql_chart', {})).toEqual({
75
+ kind: 'not_executable',
76
+ tileType: 'sql_chart',
77
+ reason: 'missing_saved_sql_uuid',
78
+ });
79
+ });
80
+ (0, vitest_1.it)('rejects markdown and unknown types', () => {
81
+ (0, vitest_1.expect)((0, reader_content_js_1.classifyDashboardTile)('markdown', {})).toEqual({
82
+ kind: 'not_executable',
83
+ tileType: 'markdown',
84
+ reason: 'unsupported_type',
85
+ });
86
+ });
87
+ });
88
+ (0, vitest_1.describe)('toReaderDashboard', () => {
89
+ (0, vitest_1.it)('marks sql_chart tiles executable when savedSqlUuid is present', () => {
90
+ const mapped = (0, reader_content_js_1.toReaderDashboard)({
91
+ uuid: 'aaaa1111-bbbb-4ccc-8ddd-eeeeeeeeeeee',
92
+ name: 'App',
93
+ tiles: [
94
+ {
95
+ uuid: 'tile-sql',
96
+ type: 'sql_chart',
97
+ properties: { savedSqlUuid: 'sql-1', chartName: 'SQL KPI' },
98
+ },
99
+ {
100
+ uuid: 'tile-sql-missing',
101
+ type: 'sql_chart',
102
+ properties: { chartName: 'Broken' },
103
+ },
104
+ {
105
+ uuid: 'tile-sem',
106
+ type: 'saved_chart',
107
+ properties: { savedChartUuid: 'chart-1', chartName: 'Revenue' },
108
+ },
109
+ {
110
+ uuid: 'tile-md',
111
+ type: 'markdown',
112
+ properties: { title: 'Notes' },
113
+ },
114
+ ],
115
+ }, true);
116
+ (0, vitest_1.expect)(mapped.tiles).toEqual(vitest_1.expect.arrayContaining([
117
+ vitest_1.expect.objectContaining({
118
+ tileUuid: 'tile-sql',
119
+ type: 'sql_chart',
120
+ savedSqlUuid: 'sql-1',
121
+ executable: true,
122
+ }),
123
+ vitest_1.expect.objectContaining({
124
+ tileUuid: 'tile-sql-missing',
125
+ type: 'sql_chart',
126
+ executable: false,
127
+ }),
128
+ vitest_1.expect.objectContaining({
129
+ tileUuid: 'tile-sem',
130
+ type: 'saved_chart',
131
+ executable: true,
132
+ }),
133
+ vitest_1.expect.objectContaining({
134
+ tileUuid: 'tile-md',
135
+ type: 'markdown',
136
+ executable: false,
137
+ }),
138
+ ]));
139
+ });
140
+ });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Saved-content execution tools for content-reader (semantic only; SQL disabled).
2
+ * Saved-content execution tools for content-reader (semantic charts + dashboard SQL tiles).
3
3
  */
4
4
  import type { McpContextProvider } from '../../server/request-context.js';
5
5
  import type { McpServer } from '@modelcontextprotocol/server';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Saved-content execution tools for content-reader (semantic only; SQL disabled).
3
+ * Saved-content execution tools for content-reader (semantic charts + dashboard SQL tiles).
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runDashboardTileTool = exports.runChartTool = void 0;
@@ -26,6 +26,102 @@ const dateZoomSchema = zod_1.z
26
26
  xAxisFieldId: zod_1.z.string().optional(),
27
27
  })
28
28
  .optional();
29
+ const SQL_TILE_ROW_LEVEL_WARNING = {
30
+ code: 'SQL_RESULT_MAY_BE_ROW_LEVEL',
31
+ message: 'Dashboard SQL tile results may be grain-level rows, not semantic aggregates',
32
+ };
33
+ const DATE_ZOOM_IGNORED_ON_SQL_TILE = {
34
+ code: 'DATE_ZOOM_IGNORED',
35
+ message: 'dateZoom is not a field on dashboard-sql-chart; dashboard default granularity applies',
36
+ };
37
+ function filterOverrideWarnings(messages) {
38
+ return messages.map((message) => ({ code: 'FILTER_IGNORED', message }));
39
+ }
40
+ function dashboardTileRequestBase(args) {
41
+ return {
42
+ dashboardUuid: String(args.dashboard.uuid),
43
+ tileUuid: args.tileUuid,
44
+ dashboardFilters: args.filters,
45
+ dashboardSorts: [],
46
+ parameters: args.parameterOverrides,
47
+ limit: args.limit,
48
+ invalidateCache: false,
49
+ context: 'dashboardView',
50
+ };
51
+ }
52
+ async function executeSemanticDashboardTile(args) {
53
+ var _a, _b;
54
+ const chartUuid = String((_b = (_a = args.props.savedChartUuid) !== null && _a !== void 0 ? _a : args.props.chartUuid) !== null && _b !== void 0 ? _b : '');
55
+ if (!chartUuid) {
56
+ return (0, reader_tool_helpers_js_1.codedErrorResult)('CONTENT_NOT_EXECUTABLE', 'Tile has no saved chart UUID');
57
+ }
58
+ const body = Object.assign(Object.assign({}, dashboardTileRequestBase(args)), { chartUuid, dateZoom: args.dateZoom });
59
+ const bounded = await (0, bounded_saved_query_js_1.runBoundedSavedQuery)({
60
+ client: args.client,
61
+ projectUuid: args.projectUuid,
62
+ sourceType: 'dashboard_tile',
63
+ sourceUuid: args.tileUuid,
64
+ limit: args.limit,
65
+ waitForResults: args.waitForResults,
66
+ timeoutMs: args.timeoutMs,
67
+ execute: () => args.client.v2.query.runDashboardChartQuery(args.projectUuid, body),
68
+ });
69
+ if (!bounded.ok) {
70
+ return bounded.result;
71
+ }
72
+ return (0, shared_js_1.jsonToolResult)((0, envelope_js_1.contentReaderEnvelope)(Object.assign(Object.assign({}, bounded.normalized), { content: {
73
+ type: 'dashboard_tile',
74
+ dashboardUuid: args.dashboard.uuid,
75
+ dashboardName: args.dashboard.name,
76
+ tileUuid: args.tileUuid,
77
+ chartUuid,
78
+ chartName: args.props.chartName,
79
+ }, appliedDashboardFilters: args.filters, appliedDateZoom: args.dateZoom }), {
80
+ profile: args.profile,
81
+ projectUuid: args.projectUuid,
82
+ projectPinned: args.projectPinned,
83
+ complete: (0, reader_tool_helpers_js_1.isCoverageComplete)(bounded.normalized),
84
+ truncated: bounded.normalized.truncated,
85
+ warnings: [...filterOverrideWarnings(args.filterWarnings), ...bounded.warnings],
86
+ }));
87
+ }
88
+ async function executeSqlDashboardTile(args) {
89
+ const body = Object.assign(Object.assign({}, dashboardTileRequestBase(args)), { savedSqlUuid: args.savedSqlUuid, dashboardFilters: args.filters });
90
+ const bounded = await (0, bounded_saved_query_js_1.runBoundedSavedQuery)({
91
+ client: args.client,
92
+ projectUuid: args.projectUuid,
93
+ sourceType: 'dashboard_tile',
94
+ sourceUuid: args.tileUuid,
95
+ limit: args.limit,
96
+ waitForResults: args.waitForResults,
97
+ timeoutMs: args.timeoutMs,
98
+ execute: () => args.client.v2.query.runDashboardSqlChartQuery(args.projectUuid, body),
99
+ });
100
+ if (!bounded.ok) {
101
+ return bounded.result;
102
+ }
103
+ return (0, shared_js_1.jsonToolResult)((0, envelope_js_1.contentReaderEnvelope)(Object.assign(Object.assign({}, bounded.normalized), { content: {
104
+ type: 'dashboard_tile',
105
+ dashboardUuid: args.dashboard.uuid,
106
+ dashboardName: args.dashboard.name,
107
+ tileUuid: args.tileUuid,
108
+ savedSqlUuid: args.savedSqlUuid,
109
+ chartSlug: args.props.chartSlug,
110
+ chartName: args.props.chartName,
111
+ }, appliedDashboardFilters: args.filters }), {
112
+ profile: args.profile,
113
+ projectUuid: args.projectUuid,
114
+ projectPinned: args.projectPinned,
115
+ complete: (0, reader_tool_helpers_js_1.isCoverageComplete)(bounded.normalized),
116
+ truncated: bounded.normalized.truncated,
117
+ warnings: [
118
+ ...filterOverrideWarnings(args.filterWarnings),
119
+ SQL_TILE_ROW_LEVEL_WARNING,
120
+ ...(args.dateZoomIgnored ? [DATE_ZOOM_IGNORED_ON_SQL_TILE] : []),
121
+ ...bounded.warnings,
122
+ ],
123
+ }));
124
+ }
29
125
  function registerRunChart(server, contextProvider) {
30
126
  (0, content_reader_js_1.registerContentReaderTool)(server, 'run_chart', {
31
127
  title: 'Run chart',
@@ -92,20 +188,17 @@ function registerRunChart(server, contextProvider) {
92
188
  }));
93
189
  }
94
190
  catch (err) {
95
- if (err instanceof project_scope_js_1.ProjectScopeError) {
96
- return (0, reader_tool_helpers_js_1.codedErrorResult)(err.code, err.message);
97
- }
98
191
  if (err instanceof result_limits_js_1.ResultLimitError) {
99
192
  return (0, reader_tool_helpers_js_1.codedErrorResult)(err.code, err.message);
100
193
  }
101
- throw err;
194
+ return (0, reader_tool_helpers_js_1.projectScopeErrorResult)(err);
102
195
  }
103
196
  }));
104
197
  }
105
198
  function registerRunDashboardTile(server, contextProvider) {
106
199
  (0, content_reader_js_1.registerContentReaderTool)(server, 'run_dashboard_tile', {
107
200
  title: 'Run dashboard tile',
108
- description: 'Execute one dashboard tile in dashboard context (saved semantic charts only; SQL tiles disabled)',
201
+ description: 'Execute one dashboard tile in dashboard context (saved semantic charts or saved SQL tiles). Cache-first, bounded rows.',
109
202
  safety: content_reader_js_1.SAVED_EXECUTION_SAFETY,
110
203
  inputSchema: {
111
204
  projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
@@ -124,10 +217,7 @@ function registerRunDashboardTile(server, contextProvider) {
124
217
  waitForResults: zod_1.z.boolean().optional(),
125
218
  timeoutMs: zod_1.z.number().int().nonnegative().optional(),
126
219
  },
127
- },
128
- /* eslint-disable sonarjs/cognitive-complexity, sonarjs/cyclomatic-complexity -- tile validation + execution */
129
- (profile) => (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
130
- var _a, _b, _c;
220
+ }, (profile) => (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
131
221
  try {
132
222
  const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
133
223
  if (args.useCache === false) {
@@ -142,77 +232,46 @@ function registerRunDashboardTile(server, contextProvider) {
142
232
  if (!tile) {
143
233
  return (0, reader_tool_helpers_js_1.codedErrorResult)('CONTENT_NOT_FOUND', `Tile '${args.tileUuid}' not found on dashboard`);
144
234
  }
145
- const tileType = String((_a = tile.type) !== null && _a !== void 0 ? _a : 'unknown');
146
- if (tileType === 'sql_chart') {
147
- return (0, reader_tool_helpers_js_1.codedErrorResult)('CONTENT_NOT_EXECUTABLE', 'Dashboard SQL chart tiles are disabled by default on content-reader');
148
- }
149
- if (tileType !== 'saved_chart') {
150
- return (0, reader_tool_helpers_js_1.codedErrorResult)('CONTENT_NOT_EXECUTABLE', `Tile type '${tileType}' is not executable`);
151
- }
235
+ const tileType = typeof tile.type === 'string' ? tile.type : 'unknown';
152
236
  const props = (0, api_shape_js_1.asRecord)(tile.properties);
153
- const chartUuid = String((_c = (_b = props.savedChartUuid) !== null && _b !== void 0 ? _b : props.chartUuid) !== null && _c !== void 0 ? _c : '');
154
- if (!chartUuid) {
155
- return (0, reader_tool_helpers_js_1.codedErrorResult)('CONTENT_NOT_EXECUTABLE', 'Tile has no saved chart UUID');
237
+ const classified = (0, reader_content_js_1.classifyDashboardTile)(tileType, props);
238
+ if (classified.kind === 'not_executable') {
239
+ return (0, reader_tool_helpers_js_1.codedErrorResult)('CONTENT_NOT_EXECUTABLE', classified.reason === 'missing_saved_sql_uuid'
240
+ ? 'Tile has no saved SQL UUID'
241
+ : `Tile type '${classified.tileType}' is not executable`);
156
242
  }
157
243
  const { filters, warnings: filterWarnings } = (0, filter_overrides_js_1.applyFilterValueOverrides)(dashboard.filters, args.filterOverrides);
158
- const body = {
159
- dashboardUuid: String(dashboard.uuid),
160
- tileUuid: args.tileUuid,
161
- chartUuid,
162
- dashboardFilters: filters,
163
- dashboardSorts: [],
164
- parameters: args.parameterOverrides,
165
- dateZoom: args.dateZoom,
166
- limit,
167
- invalidateCache: false,
168
- context: 'dashboardView',
169
- };
170
- const bounded = await (0, bounded_saved_query_js_1.runBoundedSavedQuery)({
244
+ const shared = {
171
245
  client: c,
246
+ profile,
172
247
  projectUuid: scope.projectUuid,
173
- sourceType: 'dashboard_tile',
174
- sourceUuid: args.tileUuid,
248
+ projectPinned: scope.projectPinned,
249
+ dashboard,
250
+ tileUuid: args.tileUuid,
251
+ props,
252
+ filters,
253
+ filterWarnings,
175
254
  limit,
255
+ parameterOverrides: args.parameterOverrides,
176
256
  waitForResults: args.waitForResults,
177
257
  timeoutMs: args.timeoutMs,
178
- execute: () => c.v2.query.runDashboardChartQuery(scope.projectUuid, body),
179
- });
180
- if (!bounded.ok) {
181
- return bounded.result;
258
+ };
259
+ switch (classified.kind) {
260
+ case 'sql_chart':
261
+ return executeSqlDashboardTile(Object.assign(Object.assign({}, shared), { savedSqlUuid: classified.savedSqlUuid, dateZoomIgnored: args.dateZoom !== undefined }));
262
+ case 'saved_chart':
263
+ return executeSemanticDashboardTile(Object.assign(Object.assign({}, shared), { dateZoom: args.dateZoom }));
264
+ default: {
265
+ const _exhaustive = classified;
266
+ return _exhaustive;
267
+ }
182
268
  }
183
- return (0, shared_js_1.jsonToolResult)((0, envelope_js_1.contentReaderEnvelope)(Object.assign(Object.assign({}, bounded.normalized), { content: {
184
- type: 'dashboard_tile',
185
- dashboardUuid: dashboard.uuid,
186
- dashboardName: dashboard.name,
187
- tileUuid: args.tileUuid,
188
- chartUuid,
189
- chartName: props.chartName,
190
- }, appliedDashboardFilters: filters, appliedDateZoom: args.dateZoom }), {
191
- profile,
192
- projectUuid: scope.projectUuid,
193
- projectPinned: scope.projectPinned,
194
- complete: (0, reader_tool_helpers_js_1.isCoverageComplete)(bounded.normalized),
195
- truncated: bounded.normalized.truncated,
196
- warnings: [
197
- ...filterWarnings.map((message) => ({
198
- code: 'FILTER_IGNORED',
199
- message,
200
- })),
201
- ...bounded.warnings,
202
- ],
203
- }));
204
269
  }
205
270
  catch (err) {
206
- if (err instanceof project_scope_js_1.ProjectScopeError) {
207
- return (0, reader_tool_helpers_js_1.codedErrorResult)(err.code, err.message);
208
- }
209
- if (err instanceof result_limits_js_1.ResultLimitError) {
210
- return (0, reader_tool_helpers_js_1.codedErrorResult)(err.code, err.message);
211
- }
212
- if (err instanceof filter_overrides_js_1.FilterOverrideError) {
271
+ if (err instanceof result_limits_js_1.ResultLimitError || err instanceof filter_overrides_js_1.FilterOverrideError) {
213
272
  return (0, reader_tool_helpers_js_1.codedErrorResult)(err.code, err.message);
214
273
  }
215
- throw err;
274
+ return (0, reader_tool_helpers_js_1.projectScopeErrorResult)(err);
216
275
  }
217
276
  }));
218
277
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * run_chart / run_dashboard_tile registration and handler tests.
3
+ */
4
+ export {};
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+ /**
3
+ * run_chart / run_dashboard_tile registration and handler tests.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const vitest_1 = require("vitest");
7
+ const server_profile_js_1 = require("../../audit/server-profile.js");
8
+ const mcp_client_session_js_1 = require("../../governance/mcp-client-session.js");
9
+ const result_limits_js_1 = require("../../policy/result-limits.js");
10
+ const query_ledger_js_1 = require("../query/query-ledger.js");
11
+ const reader_execution_js_1 = require("./reader-execution.js");
12
+ const PROJECT = '550e8400-e29b-41d4-a716-446655440000';
13
+ const DASHBOARD = 'aaaa1111-bbbb-4ccc-8ddd-eeeeeeeeeeee';
14
+ const TILE_SQL = 'bbbb2222-cccc-4ddd-8eee-ffffffffffff';
15
+ const TILE_SEM = 'cccc3333-dddd-4eee-8fff-aaaaaaaaaaaa';
16
+ const TILE_MD = 'dddd4444-eeee-4fff-8aaa-bbbbbbbbbbbb';
17
+ const TILE_SQL_MISSING = 'eeee5555-ffff-4aaa-8bbb-cccccccccccc';
18
+ const SAVED_SQL = 'ffff6666-aaaa-4bbb-8ccc-dddddddddddd';
19
+ const SAVED_CHART = '1111aaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee';
20
+ const dashboardFixture = {
21
+ uuid: DASHBOARD,
22
+ name: 'App',
23
+ tiles: [
24
+ {
25
+ uuid: TILE_SQL,
26
+ type: 'sql_chart',
27
+ properties: { savedSqlUuid: SAVED_SQL, chartSlug: 'sql-kpi', chartName: 'SQL KPI' },
28
+ },
29
+ {
30
+ uuid: TILE_SEM,
31
+ type: 'saved_chart',
32
+ properties: { savedChartUuid: SAVED_CHART, chartName: 'Revenue' },
33
+ },
34
+ {
35
+ uuid: TILE_MD,
36
+ type: 'markdown',
37
+ properties: { title: 'Notes' },
38
+ },
39
+ {
40
+ uuid: TILE_SQL_MISSING,
41
+ type: 'sql_chart',
42
+ properties: { chartName: 'Broken SQL tile' },
43
+ },
44
+ ],
45
+ filters: { dimensions: [], metrics: [], tableCalculations: [] },
46
+ };
47
+ function readerContext(lightdashClient) {
48
+ return {
49
+ getContext: async () => ({
50
+ lightdashClient,
51
+ auth: { mode: 'none' },
52
+ }),
53
+ };
54
+ }
55
+ function registerDashboardTileHandler(lightdashClient) {
56
+ const mockServer = { registerTool: vitest_1.vi.fn() };
57
+ (0, server_profile_js_1.bindServerProfile)(mockServer, 'content-reader');
58
+ (0, reader_execution_js_1.registerRunDashboardTile)(mockServer, readerContext(lightdashClient));
59
+ const [toolName, , handler] = mockServer.registerTool.mock.calls[0];
60
+ (0, vitest_1.expect)(toolName).toBe('lightdash_run_dashboard_tile');
61
+ return handler;
62
+ }
63
+ (0, vitest_1.describe)('registerRunDashboardTile', () => {
64
+ (0, vitest_1.beforeEach)(() => {
65
+ (0, query_ledger_js_1.resetQueryLedgerForTests)();
66
+ (0, result_limits_js_1.resetQueryBudgetsForTests)();
67
+ vitest_1.vi.restoreAllMocks();
68
+ });
69
+ (0, vitest_1.it)('executes sql_chart tiles via runDashboardSqlChartQuery', async () => {
70
+ const runDashboardSqlChartQuery = vitest_1.vi.fn().mockResolvedValue({ queryUuid: 'q-sql' });
71
+ const runDashboardChartQuery = vitest_1.vi.fn();
72
+ const getAsyncQueryResults = vitest_1.vi.fn().mockResolvedValue({
73
+ queryUuid: 'q-sql',
74
+ status: 'ready',
75
+ columns: {},
76
+ rows: [{ metric: 1 }],
77
+ totalResults: 1,
78
+ });
79
+ const getDashboard = vitest_1.vi.fn().mockResolvedValue(dashboardFixture);
80
+ const handler = registerDashboardTileHandler({
81
+ v2: {
82
+ dashboards: { getDashboard },
83
+ query: { runDashboardSqlChartQuery, runDashboardChartQuery, getAsyncQueryResults },
84
+ },
85
+ });
86
+ const sessionId = (0, mcp_client_session_js_1.resolveMcpClientSessionId)({ sessionId: 'mcp-reader-sql-1' });
87
+ await (0, mcp_client_session_js_1.runWithMcpClientSessionAsync)(sessionId, async () => {
88
+ const result = await handler({
89
+ projectUuid: PROJECT,
90
+ dashboardUuidOrSlug: DASHBOARD,
91
+ tileUuid: TILE_SQL,
92
+ waitForResults: true,
93
+ timeoutMs: 5000,
94
+ });
95
+ (0, vitest_1.expect)(result.isError).toBeUndefined();
96
+ (0, vitest_1.expect)(runDashboardSqlChartQuery).toHaveBeenCalledWith(PROJECT, vitest_1.expect.objectContaining({
97
+ savedSqlUuid: SAVED_SQL,
98
+ dashboardUuid: DASHBOARD,
99
+ tileUuid: TILE_SQL,
100
+ dashboardSorts: [],
101
+ invalidateCache: false,
102
+ context: 'dashboardView',
103
+ }));
104
+ (0, vitest_1.expect)(runDashboardChartQuery).not.toHaveBeenCalled();
105
+ const body = JSON.parse(result.content[0].text);
106
+ (0, vitest_1.expect)(body.data.queryUuid).toBe('q-sql');
107
+ (0, vitest_1.expect)(body.data.content).toMatchObject({
108
+ type: 'dashboard_tile',
109
+ savedSqlUuid: SAVED_SQL,
110
+ tileUuid: TILE_SQL,
111
+ });
112
+ (0, vitest_1.expect)(body.data.content).not.toHaveProperty('chartUuid');
113
+ (0, vitest_1.expect)(body.warnings.map((w) => w.code)).toContain('SQL_RESULT_MAY_BE_ROW_LEVEL');
114
+ });
115
+ });
116
+ (0, vitest_1.it)('warns and ignores dateZoom on sql_chart tiles', async () => {
117
+ const runDashboardSqlChartQuery = vitest_1.vi.fn().mockResolvedValue({ queryUuid: 'q-sql-zoom' });
118
+ const getAsyncQueryResults = vitest_1.vi.fn().mockResolvedValue({
119
+ queryUuid: 'q-sql-zoom',
120
+ status: 'ready',
121
+ columns: {},
122
+ rows: [],
123
+ totalResults: 0,
124
+ });
125
+ const handler = registerDashboardTileHandler({
126
+ v2: {
127
+ dashboards: { getDashboard: vitest_1.vi.fn().mockResolvedValue(dashboardFixture) },
128
+ query: { runDashboardSqlChartQuery, getAsyncQueryResults },
129
+ },
130
+ });
131
+ const sessionId = (0, mcp_client_session_js_1.resolveMcpClientSessionId)({ sessionId: 'mcp-reader-sql-zoom' });
132
+ await (0, mcp_client_session_js_1.runWithMcpClientSessionAsync)(sessionId, async () => {
133
+ const result = await handler({
134
+ projectUuid: PROJECT,
135
+ dashboardUuidOrSlug: DASHBOARD,
136
+ tileUuid: TILE_SQL,
137
+ dateZoom: { granularity: 'week' },
138
+ waitForResults: true,
139
+ });
140
+ (0, vitest_1.expect)(result.isError).toBeUndefined();
141
+ const [, body] = runDashboardSqlChartQuery.mock.calls[0];
142
+ (0, vitest_1.expect)(body).not.toHaveProperty('dateZoom');
143
+ const parsed = JSON.parse(result.content[0].text);
144
+ (0, vitest_1.expect)(parsed.warnings.map((w) => w.code)).toEqual(vitest_1.expect.arrayContaining(['DATE_ZOOM_IGNORED', 'SQL_RESULT_MAY_BE_ROW_LEVEL']));
145
+ });
146
+ });
147
+ (0, vitest_1.it)('returns CONTENT_NOT_EXECUTABLE when sql_chart has no savedSqlUuid', async () => {
148
+ const runDashboardSqlChartQuery = vitest_1.vi.fn();
149
+ const handler = registerDashboardTileHandler({
150
+ v2: {
151
+ dashboards: { getDashboard: vitest_1.vi.fn().mockResolvedValue(dashboardFixture) },
152
+ query: { runDashboardSqlChartQuery },
153
+ },
154
+ });
155
+ const result = await handler({
156
+ projectUuid: PROJECT,
157
+ dashboardUuidOrSlug: DASHBOARD,
158
+ tileUuid: TILE_SQL_MISSING,
159
+ });
160
+ (0, vitest_1.expect)(result.isError).toBe(true);
161
+ (0, vitest_1.expect)(JSON.stringify(result)).toContain('CONTENT_NOT_EXECUTABLE');
162
+ (0, vitest_1.expect)(JSON.stringify(result)).toContain('saved SQL UUID');
163
+ (0, vitest_1.expect)(runDashboardSqlChartQuery).not.toHaveBeenCalled();
164
+ });
165
+ (0, vitest_1.it)('executes saved_chart tiles via runDashboardChartQuery', async () => {
166
+ const runDashboardChartQuery = vitest_1.vi.fn().mockResolvedValue({ queryUuid: 'q-sem' });
167
+ const runDashboardSqlChartQuery = vitest_1.vi.fn();
168
+ const getAsyncQueryResults = vitest_1.vi.fn().mockResolvedValue({
169
+ queryUuid: 'q-sem',
170
+ status: 'ready',
171
+ columns: {},
172
+ rows: [{ revenue: 10 }],
173
+ totalResults: 1,
174
+ });
175
+ const handler = registerDashboardTileHandler({
176
+ v2: {
177
+ dashboards: { getDashboard: vitest_1.vi.fn().mockResolvedValue(dashboardFixture) },
178
+ query: { runDashboardChartQuery, runDashboardSqlChartQuery, getAsyncQueryResults },
179
+ },
180
+ });
181
+ const sessionId = (0, mcp_client_session_js_1.resolveMcpClientSessionId)({ sessionId: 'mcp-reader-sem-1' });
182
+ await (0, mcp_client_session_js_1.runWithMcpClientSessionAsync)(sessionId, async () => {
183
+ const result = await handler({
184
+ projectUuid: PROJECT,
185
+ dashboardUuidOrSlug: DASHBOARD,
186
+ tileUuid: TILE_SEM,
187
+ waitForResults: true,
188
+ });
189
+ (0, vitest_1.expect)(result.isError).toBeUndefined();
190
+ (0, vitest_1.expect)(runDashboardChartQuery).toHaveBeenCalledWith(PROJECT, vitest_1.expect.objectContaining({
191
+ chartUuid: SAVED_CHART,
192
+ tileUuid: TILE_SEM,
193
+ context: 'dashboardView',
194
+ }));
195
+ (0, vitest_1.expect)(runDashboardSqlChartQuery).not.toHaveBeenCalled();
196
+ const body = JSON.parse(result.content[0].text);
197
+ (0, vitest_1.expect)(body.data.content).toMatchObject({ chartUuid: SAVED_CHART });
198
+ });
199
+ });
200
+ (0, vitest_1.it)('returns CONTENT_NOT_EXECUTABLE for markdown tiles', async () => {
201
+ const runDashboardSqlChartQuery = vitest_1.vi.fn();
202
+ const runDashboardChartQuery = vitest_1.vi.fn();
203
+ const handler = registerDashboardTileHandler({
204
+ v2: {
205
+ dashboards: { getDashboard: vitest_1.vi.fn().mockResolvedValue(dashboardFixture) },
206
+ query: { runDashboardSqlChartQuery, runDashboardChartQuery },
207
+ },
208
+ });
209
+ const result = await handler({
210
+ projectUuid: PROJECT,
211
+ dashboardUuidOrSlug: DASHBOARD,
212
+ tileUuid: TILE_MD,
213
+ });
214
+ (0, vitest_1.expect)(result.isError).toBe(true);
215
+ (0, vitest_1.expect)(JSON.stringify(result)).toContain('CONTENT_NOT_EXECUTABLE');
216
+ (0, vitest_1.expect)(runDashboardSqlChartQuery).not.toHaveBeenCalled();
217
+ (0, vitest_1.expect)(runDashboardChartQuery).not.toHaveBeenCalled();
218
+ });
219
+ });
220
+ (0, vitest_1.describe)('registerRunChart', () => {
221
+ (0, vitest_1.beforeEach)(() => {
222
+ (0, query_ledger_js_1.resetQueryLedgerForTests)();
223
+ (0, result_limits_js_1.resetQueryBudgetsForTests)();
224
+ vitest_1.vi.restoreAllMocks();
225
+ });
226
+ (0, vitest_1.it)('returns CONTENT_NOT_EXECUTABLE for standalone SQL charts', async () => {
227
+ const searchContent = vitest_1.vi.fn().mockResolvedValue({
228
+ data: [{ contentType: 'chart', uuid: SAVED_SQL, slug: 'sql-kpi', source: 'sql' }],
229
+ });
230
+ const runChartQuery = vitest_1.vi.fn();
231
+ const mockServer = { registerTool: vitest_1.vi.fn() };
232
+ (0, server_profile_js_1.bindServerProfile)(mockServer, 'content-reader');
233
+ (0, reader_execution_js_1.registerRunChart)(mockServer, readerContext({
234
+ v2: { content: { searchContent }, query: { runChartQuery } },
235
+ }));
236
+ const [toolName, , handler] = mockServer.registerTool.mock.calls[0];
237
+ (0, vitest_1.expect)(toolName).toBe('lightdash_run_chart');
238
+ const result = await handler({
239
+ projectUuid: PROJECT,
240
+ chartUuidOrSlug: SAVED_SQL,
241
+ });
242
+ (0, vitest_1.expect)(result.isError).toBe(true);
243
+ (0, vitest_1.expect)(JSON.stringify(result)).toContain('CONTENT_NOT_EXECUTABLE');
244
+ (0, vitest_1.expect)(runChartQuery).not.toHaveBeenCalled();
245
+ });
246
+ });
@@ -18,7 +18,7 @@ type DashboardFilterLike = {
18
18
  required?: boolean;
19
19
  disabled?: boolean;
20
20
  };
21
- type DashboardFiltersLike = {
21
+ export type DashboardFiltersLike = {
22
22
  dimensions?: DashboardFilterLike[];
23
23
  metrics?: DashboardFilterLike[];
24
24
  tableCalculations?: DashboardFilterLike[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash-tools/mcp",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "MCP server for Lightdash semantic-layer, organization-audit, content-reader, content-developer, content-governance, and ai-agent-ops profiles.",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  "commander": "^15.0.0",
25
25
  "hono": "^4.13.0",
26
26
  "zod": "^4.4.3",
27
- "@lightdash-tools/client": "0.17.0",
28
- "@lightdash-tools/common": "0.17.0"
27
+ "@lightdash-tools/client": "0.18.0",
28
+ "@lightdash-tools/common": "0.18.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@modelcontextprotocol/client": "2.0.0",