@lightdash-tools/mcp 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -14
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +31 -57
- package/dist/cli-help.d.ts +5 -0
- package/dist/cli-help.js +23 -0
- package/dist/cli-help.test.js +24 -0
- package/dist/config/env.d.ts +2 -2
- package/dist/config/env.js +3 -3
- package/dist/config/load-mcp-config.js +10 -2
- package/dist/config/load-mcp-config.test.js +34 -6
- package/dist/config/obsolete-env.js +0 -4
- package/dist/config/obsolete-env.test.js +0 -5
- package/dist/config/runtime.js +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +22 -32
- package/dist/profiles/ai-agent-ops/v1/index.js +25 -6
- package/dist/profiles/ai-agent-ops/v1/prompts.test.js +2 -5
- package/dist/profiles/content-developer/v1/index.js +36 -6
- package/dist/profiles/content-developer/v1/prompts.test.js +7 -8
- package/dist/profiles/content-governance/v1/index.js +7 -6
- package/dist/profiles/content-governance/v1/prompts.test.js +2 -5
- package/dist/profiles/content-reader/v1/index.js +26 -6
- package/dist/profiles/content-reader/v1/prompts.test.js +2 -5
- package/dist/profiles/data-analyst/v1/index.js +19 -6
- package/dist/profiles/data-analyst/v1/prompts.test.js +2 -4
- package/dist/profiles/index.d.ts +3 -1
- package/dist/profiles/index.js +6 -1
- package/dist/profiles/index.test.js +29 -14
- package/dist/profiles/organization-audit/v1/index.js +27 -6
- package/dist/profiles/organization-audit/v1/prompts.test.js +2 -5
- package/dist/profiles/semantic-layer/v1/index.js +17 -6
- package/dist/profiles/semantic-layer/v1/prompts.js +3 -2
- package/dist/profiles/semantic-layer/v1/prompts.test.js +2 -5
- package/dist/profiles/semantic-layer/v1/resources/playbooks/compose-compile.md +14 -8
- package/dist/profiles/semantic-layer/v1/resources/playbooks/core.md +9 -9
- package/dist/profiles/semantic-layer/v1/resources/playbooks/explore.md +4 -3
- package/dist/profiles/test-support/playbook-invariants.d.ts +5 -0
- package/dist/profiles/test-support/playbook-invariants.js +14 -0
- package/dist/profiles/types.d.ts +6 -1
- package/dist/profiles/types.js +1 -1
- package/dist/protocol-contract.test.js +2 -2
- package/dist/server/capabilities.d.ts +2 -2
- package/dist/server/capabilities.js +3 -4
- package/dist/server/capabilities.test.js +4 -5
- package/dist/stdio.process.test.js +114 -193
- package/dist/tools/ai-agents/agents.d.ts +2 -0
- package/dist/tools/ai-agents/agents.js +5 -0
- package/dist/tools/ai-agents/discovery.d.ts +4 -0
- package/dist/tools/ai-agents/discovery.js +7 -0
- package/dist/tools/ai-agents/evaluations.d.ts +9 -0
- package/dist/tools/ai-agents/evaluations.js +12 -0
- package/dist/tools/ai-agents/threads.d.ts +2 -0
- package/dist/tools/ai-agents/threads.js +5 -0
- package/dist/tools/composition/explain-content.d.ts +1 -0
- package/dist/tools/composition/explain-content.js +4 -0
- package/dist/tools/organization/invariants.test.js +7 -3
- package/dist/tools/organization/inventory.d.ts +5 -0
- package/dist/tools/organization/inventory.js +8 -0
- package/dist/tools/organization/roles.d.ts +5 -0
- package/dist/tools/organization/roles.js +8 -0
- package/dist/tools/project/content.d.ts +4 -0
- package/dist/tools/project/content.js +7 -0
- package/dist/tools/project/delete-chart.d.ts +3 -1
- package/dist/tools/project/delete-chart.js +4 -2
- package/dist/tools/project/delete-dashboard.d.ts +3 -1
- package/dist/tools/project/delete-dashboard.js +4 -2
- package/dist/tools/project/developer-content-preview.d.ts +3 -0
- package/dist/tools/project/developer-content-preview.js +6 -0
- package/dist/tools/project/developer-content.d.ts +16 -1
- package/dist/tools/project/developer-content.js +18 -5
- package/dist/tools/project/developer-get-chart-as-code.d.ts +1 -0
- package/dist/tools/project/developer-get-chart-as-code.js +4 -0
- package/dist/tools/project/get-dashboard-promote-diff.d.ts +1 -0
- package/dist/tools/project/get-dashboard-promote-diff.js +4 -0
- package/dist/tools/project/invariants.test.js +6 -18
- package/dist/tools/project/parameters.d.ts +2 -0
- package/dist/tools/project/parameters.js +5 -0
- package/dist/tools/project/projects.d.ts +8 -2
- package/dist/tools/project/projects.js +34 -38
- package/dist/tools/project/projects.test.js +6 -6
- package/dist/tools/project/promote-dashboard.d.ts +3 -1
- package/dist/tools/project/promote-dashboard.js +4 -2
- package/dist/tools/project/reader-content.d.ts +3 -0
- package/dist/tools/project/reader-content.js +6 -0
- package/dist/tools/project/reader-execution.d.ts +2 -0
- package/dist/tools/project/reader-execution.js +5 -0
- package/dist/tools/project/reader-export-chart-image.d.ts +1 -0
- package/dist/tools/project/reader-export-chart-image.js +4 -0
- package/dist/tools/project/schedulers.d.ts +2 -0
- package/dist/tools/project/schedulers.js +5 -0
- package/dist/tools/project/spaces.d.ts +2 -0
- package/dist/tools/project/spaces.js +5 -0
- package/dist/tools/query/lifecycle.d.ts +2 -0
- package/dist/tools/query/lifecycle.js +5 -0
- package/dist/tools/query/run-metric-query.d.ts +1 -0
- package/dist/tools/query/run-metric-query.js +4 -0
- package/dist/tools/registry.d.ts +5 -284
- package/dist/tools/registry.js +9 -137
- package/dist/tools/registry.test.js +36 -0
- package/dist/tools/semantic/explores.d.ts +5 -1
- package/dist/tools/semantic/explores.js +8 -1
- package/dist/tools/semantic/metrics.d.ts +3 -1
- package/dist/tools/semantic/metrics.js +6 -1
- package/dist/tools/semantic/query.d.ts +2 -1
- package/dist/tools/semantic/query.js +11 -3
- package/dist/tools/semantic/query.test.d.ts +4 -0
- package/dist/tools/semantic/query.test.js +134 -0
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +2 -2
- package/dist/tools/space/access.d.ts +2 -0
- package/dist/tools/space/access.js +5 -0
- package/dist/tools/types.d.ts +18 -0
- package/dist/tools/types.js +29 -0
- package/dist/tools/types.test.js +50 -0
- package/package.json +6 -6
- package/dist/index.test.js +0 -9
- package/dist/profiles/profile.membership.test.js +0 -36
- package/dist/tools/index.d.ts +0 -4
- package/dist/tools/index.js +0 -8
- package/dist/tools/index.test.js +0 -78
- /package/dist/{index.test.d.ts → cli-help.test.d.ts} +0 -0
- /package/dist/{profiles/profile.membership.test.d.ts → tools/registry.test.d.ts} +0 -0
- /package/dist/tools/{index.test.d.ts → types.test.d.ts} +0 -0
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.contentDeveloperProfile = exports.CONTENT_DEVELOPER_PROFILE_PATH = void 0;
|
|
9
|
+
const developer_content_preview_js_1 = require("../../../tools/project/developer-content-preview.js");
|
|
10
|
+
const developer_content_js_1 = require("../../../tools/project/developer-content.js");
|
|
11
|
+
const developer_get_chart_as_code_js_1 = require("../../../tools/project/developer-get-chart-as-code.js");
|
|
12
|
+
const projects_js_1 = require("../../../tools/project/projects.js");
|
|
13
|
+
const reader_content_js_1 = require("../../../tools/project/reader-content.js");
|
|
14
|
+
const spaces_js_1 = require("../../../tools/project/spaces.js");
|
|
9
15
|
const prompts_js_1 = require("./prompts.js");
|
|
10
16
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
11
17
|
exports.CONTENT_DEVELOPER_PROFILE_PATH = '/content-developer/v1/mcp';
|
|
@@ -13,10 +19,34 @@ exports.contentDeveloperProfile = {
|
|
|
13
19
|
id: 'content-developer',
|
|
14
20
|
path: exports.CONTENT_DEVELOPER_PROFILE_PATH,
|
|
15
21
|
serverName: 'lightdash-mcp-cdev',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
tools: [
|
|
23
|
+
projects_js_1.getProjectDeveloperTool,
|
|
24
|
+
reader_content_js_1.searchContentTool,
|
|
25
|
+
spaces_js_1.listSpacesTool,
|
|
26
|
+
spaces_js_1.getSpaceTool,
|
|
27
|
+
reader_content_js_1.getDashboardTool,
|
|
28
|
+
reader_content_js_1.getChartTool,
|
|
29
|
+
developer_content_preview_js_1.previewChartChangesTool,
|
|
30
|
+
developer_content_preview_js_1.previewDashboardChangesTool,
|
|
31
|
+
developer_content_preview_js_1.previewContentMoveTool,
|
|
32
|
+
developer_get_chart_as_code_js_1.getChartAsCodeTool,
|
|
33
|
+
developer_content_js_1.validateChartTool,
|
|
34
|
+
developer_content_js_1.validateDashboardTool,
|
|
35
|
+
developer_content_js_1.confirmPreviewTool,
|
|
36
|
+
developer_content_js_1.compareChartVersionsTool,
|
|
37
|
+
developer_content_js_1.compareDashboardVersionsTool,
|
|
38
|
+
developer_content_js_1.createChartTool,
|
|
39
|
+
developer_content_js_1.updateChartTool,
|
|
40
|
+
developer_content_js_1.duplicateChartTool,
|
|
41
|
+
developer_content_js_1.createDashboardTool,
|
|
42
|
+
developer_content_js_1.updateDashboardTool,
|
|
43
|
+
developer_content_js_1.duplicateDashboardTool,
|
|
44
|
+
developer_content_js_1.addDashboardTileTool,
|
|
45
|
+
developer_content_js_1.moveDashboardTileTool,
|
|
46
|
+
developer_content_js_1.removeDashboardTileTool,
|
|
47
|
+
developer_content_js_1.resizeDashboardTileTool,
|
|
48
|
+
developer_content_js_1.moveContentTool,
|
|
49
|
+
],
|
|
50
|
+
registerPrompts: prompts_js_1.registerContentDeveloperPrompts,
|
|
51
|
+
registerResources: playbooks_js_1.registerContentDeveloperPlaybook,
|
|
22
52
|
};
|
|
@@ -36,16 +36,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const common_1 = require("@lightdash-tools/common");
|
|
40
39
|
const vitest_1 = require("vitest");
|
|
40
|
+
const index_js_1 = require("../../index.js");
|
|
41
|
+
const playbook_invariants_js_1 = require("../../test-support/playbook-invariants.js");
|
|
41
42
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
42
43
|
(0, vitest_1.describe)('content-developer prompts/playbook', () => {
|
|
43
44
|
(0, vitest_1.it)('playbooks reference only registered tool short ids', () => {
|
|
44
45
|
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
45
|
-
|
|
46
|
-
(0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
|
|
47
|
-
}
|
|
48
|
-
(0, vitest_1.expect)(md).not.toMatch(/\bldt__/);
|
|
46
|
+
(0, playbook_invariants_js_1.expectPlaybookCoversProfileTools)('content-developer', md);
|
|
49
47
|
(0, vitest_1.expect)(md.toLowerCase()).toContain('hard bans');
|
|
50
48
|
(0, vitest_1.expect)(playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS.toLowerCase()).toContain('terraform');
|
|
51
49
|
});
|
|
@@ -60,9 +58,10 @@ const playbooks_js_1 = require("./resources/playbooks.js");
|
|
|
60
58
|
(0, vitest_1.expect)(md).toContain('chart-types');
|
|
61
59
|
(0, vitest_1.expect)(md).not.toMatch(/`create_space`/);
|
|
62
60
|
(0, vitest_1.expect)(md).not.toMatch(/`update_space`/);
|
|
63
|
-
(0,
|
|
64
|
-
(0, vitest_1.expect)(
|
|
65
|
-
(0, vitest_1.expect)(
|
|
61
|
+
const toolIds = (0, index_js_1.listToolIds)((0, index_js_1.getProfile)('content-developer'));
|
|
62
|
+
(0, vitest_1.expect)(toolIds).not.toContain('create_space');
|
|
63
|
+
(0, vitest_1.expect)(toolIds).not.toContain('update_space');
|
|
64
|
+
(0, vitest_1.expect)(toolIds).toContain('get_chart_as_code');
|
|
66
65
|
(0, vitest_1.expect)(playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS.toLowerCase()).toContain('dashboardslug');
|
|
67
66
|
(0, vitest_1.expect)(playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS.toLowerCase()).toContain('skinny');
|
|
68
67
|
});
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.contentGovernanceProfile = exports.CONTENT_GOVERNANCE_PROFILE_PATH = void 0;
|
|
8
|
+
const delete_chart_js_1 = require("../../../tools/project/delete-chart.js");
|
|
9
|
+
const delete_dashboard_js_1 = require("../../../tools/project/delete-dashboard.js");
|
|
10
|
+
const get_dashboard_promote_diff_js_1 = require("../../../tools/project/get-dashboard-promote-diff.js");
|
|
11
|
+
const promote_dashboard_js_1 = require("../../../tools/project/promote-dashboard.js");
|
|
8
12
|
const prompts_js_1 = require("./prompts.js");
|
|
9
13
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
10
14
|
exports.CONTENT_GOVERNANCE_PROFILE_PATH = '/content-governance/v1/mcp';
|
|
@@ -12,10 +16,7 @@ exports.contentGovernanceProfile = {
|
|
|
12
16
|
id: 'content-governance',
|
|
13
17
|
path: exports.CONTENT_GOVERNANCE_PROFILE_PATH,
|
|
14
18
|
serverName: 'lightdash-mcp-gov',
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
registerResources: (server) => {
|
|
19
|
-
(0, playbooks_js_1.registerContentGovernancePlaybook)(server);
|
|
20
|
-
},
|
|
19
|
+
tools: [delete_chart_js_1.deleteChartTool, delete_dashboard_js_1.deleteDashboardTool, get_dashboard_promote_diff_js_1.getDashboardPromoteDiffTool, promote_dashboard_js_1.promoteDashboardTool],
|
|
20
|
+
registerPrompts: prompts_js_1.registerContentGovernancePrompts,
|
|
21
|
+
registerResources: playbooks_js_1.registerContentGovernancePlaybook,
|
|
21
22
|
};
|
|
@@ -36,16 +36,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const common_1 = require("@lightdash-tools/common");
|
|
40
39
|
const vitest_1 = require("vitest");
|
|
40
|
+
const playbook_invariants_js_1 = require("../../test-support/playbook-invariants.js");
|
|
41
41
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
42
42
|
(0, vitest_1.describe)('content-governance prompts/playbook', () => {
|
|
43
43
|
(0, vitest_1.it)('playbooks reference only registered tool short ids', () => {
|
|
44
44
|
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
45
|
-
|
|
46
|
-
(0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
|
|
47
|
-
}
|
|
48
|
-
(0, vitest_1.expect)(md).not.toMatch(/\bldt__/);
|
|
45
|
+
(0, playbook_invariants_js_1.expectPlaybookCoversProfileTools)('content-governance', md);
|
|
49
46
|
(0, vitest_1.expect)(md.toLowerCase()).toContain('hard bans');
|
|
50
47
|
(0, vitest_1.expect)(playbooks_js_1.CONTENT_GOVERNANCE_HARD_BANS.toLowerCase()).toContain('permanently purge');
|
|
51
48
|
});
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.contentReaderProfile = exports.CONTENT_READER_PROFILE_PATH = void 0;
|
|
7
|
+
const explain_content_js_1 = require("../../../tools/composition/explain-content.js");
|
|
8
|
+
const parameters_js_1 = require("../../../tools/project/parameters.js");
|
|
9
|
+
const projects_js_1 = require("../../../tools/project/projects.js");
|
|
10
|
+
const reader_content_js_1 = require("../../../tools/project/reader-content.js");
|
|
11
|
+
const reader_execution_js_1 = require("../../../tools/project/reader-execution.js");
|
|
12
|
+
const reader_export_chart_image_js_1 = require("../../../tools/project/reader-export-chart-image.js");
|
|
13
|
+
const spaces_js_1 = require("../../../tools/project/spaces.js");
|
|
14
|
+
const lifecycle_js_1 = require("../../../tools/query/lifecycle.js");
|
|
7
15
|
const prompts_js_1 = require("./prompts.js");
|
|
8
16
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
17
|
exports.CONTENT_READER_PROFILE_PATH = '/content-reader/v1/mcp';
|
|
@@ -11,10 +19,22 @@ exports.contentReaderProfile = {
|
|
|
11
19
|
id: 'content-reader',
|
|
12
20
|
path: exports.CONTENT_READER_PROFILE_PATH,
|
|
13
21
|
serverName: 'lightdash-mcp-content',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
tools: [
|
|
23
|
+
projects_js_1.getProjectReaderTool,
|
|
24
|
+
reader_content_js_1.searchContentTool,
|
|
25
|
+
spaces_js_1.listSpacesTool,
|
|
26
|
+
spaces_js_1.getSpaceTool,
|
|
27
|
+
reader_content_js_1.getDashboardTool,
|
|
28
|
+
reader_content_js_1.getChartTool,
|
|
29
|
+
parameters_js_1.listProjectParametersTool,
|
|
30
|
+
parameters_js_1.getProjectParametersTool,
|
|
31
|
+
explain_content_js_1.explainContentTool,
|
|
32
|
+
reader_execution_js_1.runChartTool,
|
|
33
|
+
reader_export_chart_image_js_1.exportChartImageTool,
|
|
34
|
+
reader_execution_js_1.runDashboardTileTool,
|
|
35
|
+
lifecycle_js_1.getQueryResultTool,
|
|
36
|
+
lifecycle_js_1.cancelQueryTool,
|
|
37
|
+
],
|
|
38
|
+
registerPrompts: prompts_js_1.registerContentReaderPrompts,
|
|
39
|
+
registerResources: playbooks_js_1.registerContentReaderPlaybook,
|
|
20
40
|
};
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
* Content-reader prompt/playbook invariants.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const common_1 = require("@lightdash-tools/common");
|
|
7
6
|
const vitest_1 = require("vitest");
|
|
7
|
+
const playbook_invariants_js_1 = require("../../test-support/playbook-invariants.js");
|
|
8
8
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
9
|
(0, vitest_1.describe)('content-reader prompts/playbook', () => {
|
|
10
10
|
(0, vitest_1.it)('playbook references only registered tool short ids', () => {
|
|
11
11
|
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
12
|
-
|
|
13
|
-
(0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
|
|
14
|
-
}
|
|
15
|
-
(0, vitest_1.expect)(md).not.toMatch(/\bldt__/);
|
|
12
|
+
(0, playbook_invariants_js_1.expectPlaybookCoversProfileTools)('content-reader', md);
|
|
16
13
|
(0, vitest_1.expect)(md.toLowerCase()).toContain('hard bans');
|
|
17
14
|
(0, vitest_1.expect)(playbooks_js_1.CONTENT_READER_HARD_BANS.toLowerCase()).toContain('sql');
|
|
18
15
|
});
|
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.dataAnalystProfile = exports.DATA_ANALYST_PROFILE_PATH = void 0;
|
|
7
|
+
const projects_js_1 = require("../../../tools/project/projects.js");
|
|
8
|
+
const lifecycle_js_1 = require("../../../tools/query/lifecycle.js");
|
|
9
|
+
const run_metric_query_js_1 = require("../../../tools/query/run-metric-query.js");
|
|
10
|
+
const explores_js_1 = require("../../../tools/semantic/explores.js");
|
|
11
|
+
const metrics_js_1 = require("../../../tools/semantic/metrics.js");
|
|
12
|
+
const query_js_1 = require("../../../tools/semantic/query.js");
|
|
7
13
|
const prompts_js_1 = require("./prompts.js");
|
|
8
14
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
15
|
exports.DATA_ANALYST_PROFILE_PATH = '/data-analyst/v1/mcp';
|
|
@@ -11,10 +17,17 @@ exports.dataAnalystProfile = {
|
|
|
11
17
|
id: 'data-analyst',
|
|
12
18
|
path: exports.DATA_ANALYST_PROFILE_PATH,
|
|
13
19
|
serverName: 'lightdash-mcp-analyst',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
tools: [
|
|
21
|
+
projects_js_1.getProjectAnalystTool,
|
|
22
|
+
explores_js_1.listExploresTool,
|
|
23
|
+
explores_js_1.getExploreTool,
|
|
24
|
+
explores_js_1.listDimensionsTool,
|
|
25
|
+
metrics_js_1.listMetricsTool,
|
|
26
|
+
query_js_1.compileQueryTool,
|
|
27
|
+
lifecycle_js_1.getQueryResultTool,
|
|
28
|
+
lifecycle_js_1.cancelQueryTool,
|
|
29
|
+
run_metric_query_js_1.runMetricQueryTool,
|
|
30
|
+
],
|
|
31
|
+
registerPrompts: prompts_js_1.registerDataAnalystPrompts,
|
|
32
|
+
registerResources: playbooks_js_1.registerDataAnalystPlaybook,
|
|
20
33
|
};
|
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
* Data-analyst prompt/playbook invariants.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const common_1 = require("@lightdash-tools/common");
|
|
7
6
|
const vitest_1 = require("vitest");
|
|
7
|
+
const playbook_invariants_js_1 = require("../../test-support/playbook-invariants.js");
|
|
8
8
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
9
|
(0, vitest_1.describe)('data-analyst prompts/playbook', () => {
|
|
10
10
|
(0, vitest_1.it)('playbook references registered tools and hard bans', () => {
|
|
11
11
|
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
12
|
-
|
|
13
|
-
(0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
|
|
14
|
-
}
|
|
12
|
+
(0, playbook_invariants_js_1.expectPlaybookCoversProfileTools)('data-analyst', md);
|
|
15
13
|
(0, vitest_1.expect)(md.toLowerCase()).toContain('hard bans');
|
|
16
14
|
(0, vitest_1.expect)(playbooks_js_1.DATA_ANALYST_HARD_BANS.toLowerCase()).toContain('raw sql');
|
|
17
15
|
(0, vitest_1.expect)(playbooks_js_1.DATA_ANALYST_HARD_BANS.toLowerCase()).toContain('mutate');
|
package/dist/profiles/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { CONTENT_READER_PROFILE_PATH } from './content-reader/v1/index.js';
|
|
|
10
10
|
export { CONTENT_DEVELOPER_PROFILE_PATH } from './content-developer/v1/index.js';
|
|
11
11
|
export { CONTENT_GOVERNANCE_PROFILE_PATH } from './content-governance/v1/index.js';
|
|
12
12
|
export { DATA_ANALYST_PROFILE_PATH } from './data-analyst/v1/index.js';
|
|
13
|
-
/**
|
|
13
|
+
/** HTTP root / PRM anchor profile (not a stdio default). */
|
|
14
14
|
export declare const DEFAULT_PROFILE_ID: ProfileId;
|
|
15
15
|
export declare const PROFILES: Record<ProfileId, ProfileDefinition>;
|
|
16
16
|
export declare function getProfile(id: ProfileId): ProfileDefinition;
|
|
@@ -22,3 +22,5 @@ export declare function listProfilePaths(): string[];
|
|
|
22
22
|
export declare function parseProfileId(value: string): ProfileId | undefined;
|
|
23
23
|
/** MCP server display name for a profile. */
|
|
24
24
|
export declare function getProfileServerName(profile: ProfileDefinition): string;
|
|
25
|
+
/** Short tool ids mounted on a profile (sans `lightdash_` prefix). */
|
|
26
|
+
export declare function listToolIds(profile: ProfileDefinition): string[];
|
package/dist/profiles/index.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.getProfileByPath = getProfileByPath;
|
|
|
10
10
|
exports.listProfilePaths = listProfilePaths;
|
|
11
11
|
exports.parseProfileId = parseProfileId;
|
|
12
12
|
exports.getProfileServerName = getProfileServerName;
|
|
13
|
+
exports.listToolIds = listToolIds;
|
|
13
14
|
const common_1 = require("@lightdash-tools/common");
|
|
14
15
|
const normalize_url_js_1 = require("../config/normalize-url.js");
|
|
15
16
|
const index_js_1 = require("./ai-agent-ops/v1/index.js");
|
|
@@ -33,7 +34,7 @@ var index_js_13 = require("./content-governance/v1/index.js");
|
|
|
33
34
|
Object.defineProperty(exports, "CONTENT_GOVERNANCE_PROFILE_PATH", { enumerable: true, get: function () { return index_js_13.CONTENT_GOVERNANCE_PROFILE_PATH; } });
|
|
34
35
|
var index_js_14 = require("./data-analyst/v1/index.js");
|
|
35
36
|
Object.defineProperty(exports, "DATA_ANALYST_PROFILE_PATH", { enumerable: true, get: function () { return index_js_14.DATA_ANALYST_PROFILE_PATH; } });
|
|
36
|
-
/**
|
|
37
|
+
/** HTTP root / PRM anchor profile (not a stdio default). */
|
|
37
38
|
exports.DEFAULT_PROFILE_ID = 'semantic-layer';
|
|
38
39
|
exports.PROFILES = {
|
|
39
40
|
'semantic-layer': index_js_7.semanticLayerProfile,
|
|
@@ -71,3 +72,7 @@ function getProfileServerName(profile) {
|
|
|
71
72
|
var _a;
|
|
72
73
|
return (_a = profile.serverName) !== null && _a !== void 0 ? _a : `lightdash-mcp-${profile.id}`;
|
|
73
74
|
}
|
|
75
|
+
/** Short tool ids mounted on a profile (sans `lightdash_` prefix). */
|
|
76
|
+
function listToolIds(profile) {
|
|
77
|
+
return profile.tools.map((tool) => tool.id);
|
|
78
|
+
}
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const common_1 = require("@lightdash-tools/common");
|
|
4
4
|
const vitest_1 = require("vitest");
|
|
5
|
+
const projects_js_1 = require("../tools/project/projects.js");
|
|
5
6
|
const registry_js_1 = require("../tools/registry.js");
|
|
7
|
+
const query_js_1 = require("../tools/semantic/query.js");
|
|
6
8
|
const shared_js_1 = require("../tools/shared.js");
|
|
7
9
|
const index_js_1 = require("./index.js");
|
|
8
10
|
(0, vitest_1.describe)('profiles', () => {
|
|
9
|
-
(0, vitest_1.it)('ships seven profiles with fixed paths', () => {
|
|
11
|
+
(0, vitest_1.it)('ships seven profiles with fixed paths and matching keys', () => {
|
|
10
12
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
11
13
|
(0, vitest_1.expect)(Object.keys(index_js_1.PROFILES).sort()).toEqual([...common_1.PROFILE_IDS].sort());
|
|
14
|
+
for (const [key, profile] of Object.entries(index_js_1.PROFILES)) {
|
|
15
|
+
(0, vitest_1.expect)(profile.id).toBe(key);
|
|
16
|
+
(0, vitest_1.expect)(profile.tools.length).toBeGreaterThan(0);
|
|
17
|
+
}
|
|
12
18
|
(0, vitest_1.expect)(index_js_1.DEFAULT_PROFILE_ID).toBe('semantic-layer');
|
|
13
19
|
(0, vitest_1.expect)((0, index_js_1.listProfilePaths)().sort()).toEqual([
|
|
14
20
|
index_js_1.AI_AGENT_OPS_PROFILE_PATH,
|
|
@@ -38,25 +44,24 @@ const index_js_1 = require("./index.js");
|
|
|
38
44
|
(0, vitest_1.expect)((_f = (0, index_js_1.getProfileByPath)(`${index_js_1.AI_AGENT_OPS_PROFILE_PATH}/`)) === null || _f === void 0 ? void 0 : _f.id).toBe('ai-agent-ops');
|
|
39
45
|
(0, vitest_1.expect)((_g = (0, index_js_1.getProfileByPath)(`${index_js_1.DATA_ANALYST_PROFILE_PATH}/`)) === null || _g === void 0 ? void 0 : _g.id).toBe('data-analyst');
|
|
40
46
|
});
|
|
41
|
-
(0, vitest_1.it)('semantic-layer
|
|
42
|
-
|
|
43
|
-
(0, vitest_1.expect)(tools).toHaveLength(9);
|
|
47
|
+
(0, vitest_1.it)('semantic-layer mounts exactly nine tools', () => {
|
|
48
|
+
(0, vitest_1.expect)((0, index_js_1.listToolIds)((0, index_js_1.getProfile)('semantic-layer'))).toHaveLength(9);
|
|
44
49
|
(0, vitest_1.expect)((0, index_js_1.getDefaultProfile)().id).toBe('semantic-layer');
|
|
45
50
|
});
|
|
46
51
|
(0, vitest_1.it)('organization-audit membership and short server name', () => {
|
|
47
52
|
const profile = (0, index_js_1.getProfile)('organization-audit');
|
|
48
|
-
(0, vitest_1.expect)((0,
|
|
53
|
+
(0, vitest_1.expect)((0, index_js_1.listToolIds)(profile)).toHaveLength(18);
|
|
49
54
|
(0, vitest_1.expect)((0, index_js_1.getProfileServerName)(profile)).toBe('lightdash-mcp-org-audit');
|
|
50
55
|
});
|
|
51
56
|
(0, vitest_1.it)('content-reader membership and server name', () => {
|
|
52
57
|
const profile = (0, index_js_1.getProfile)('content-reader');
|
|
53
|
-
(0, vitest_1.expect)((0,
|
|
54
|
-
(0, vitest_1.expect)((0,
|
|
58
|
+
(0, vitest_1.expect)((0, index_js_1.listToolIds)(profile)).toHaveLength(14);
|
|
59
|
+
(0, vitest_1.expect)((0, index_js_1.listToolIds)(profile)).toContain('export_chart_image');
|
|
55
60
|
(0, vitest_1.expect)((0, index_js_1.getProfileServerName)(profile)).toBe('lightdash-mcp-content');
|
|
56
61
|
});
|
|
57
62
|
(0, vitest_1.it)('content-developer membership and short server name', () => {
|
|
58
63
|
const profile = (0, index_js_1.getProfile)('content-developer');
|
|
59
|
-
const tools = (0,
|
|
64
|
+
const tools = (0, index_js_1.listToolIds)(profile);
|
|
60
65
|
(0, vitest_1.expect)(tools).toContain('get_chart_as_code');
|
|
61
66
|
(0, vitest_1.expect)(tools).not.toContain('create_space');
|
|
62
67
|
(0, vitest_1.expect)(tools).not.toContain('update_space');
|
|
@@ -64,7 +69,7 @@ const index_js_1 = require("./index.js");
|
|
|
64
69
|
});
|
|
65
70
|
(0, vitest_1.it)('content-governance membership and short server name', () => {
|
|
66
71
|
const profile = (0, index_js_1.getProfile)('content-governance');
|
|
67
|
-
(0, vitest_1.expect)([...(0,
|
|
72
|
+
(0, vitest_1.expect)([...(0, index_js_1.listToolIds)(profile)].sort()).toEqual([
|
|
68
73
|
'delete_chart',
|
|
69
74
|
'delete_dashboard',
|
|
70
75
|
'get_dashboard_promote_diff',
|
|
@@ -74,7 +79,7 @@ const index_js_1 = require("./index.js");
|
|
|
74
79
|
});
|
|
75
80
|
(0, vitest_1.it)('ai-agent-ops membership and short server name', () => {
|
|
76
81
|
const profile = (0, index_js_1.getProfile)('ai-agent-ops');
|
|
77
|
-
const tools = (0,
|
|
82
|
+
const tools = (0, index_js_1.listToolIds)(profile);
|
|
78
83
|
(0, vitest_1.expect)(tools).toHaveLength(17);
|
|
79
84
|
(0, vitest_1.expect)(tools).not.toContain('create_project_agent');
|
|
80
85
|
(0, vitest_1.expect)(tools).not.toContain('generate_agent_message');
|
|
@@ -82,7 +87,7 @@ const index_js_1 = require("./index.js");
|
|
|
82
87
|
});
|
|
83
88
|
(0, vitest_1.it)('data-analyst membership and short server name', () => {
|
|
84
89
|
const profile = (0, index_js_1.getProfile)('data-analyst');
|
|
85
|
-
const tools = (0,
|
|
90
|
+
const tools = (0, index_js_1.listToolIds)(profile);
|
|
86
91
|
(0, vitest_1.expect)(tools).toHaveLength(9);
|
|
87
92
|
(0, vitest_1.expect)(tools).toContain('run_metric_query');
|
|
88
93
|
(0, vitest_1.expect)(tools).not.toContain('run_chart');
|
|
@@ -91,7 +96,7 @@ const index_js_1 = require("./index.js");
|
|
|
91
96
|
(0, vitest_1.it)('keeps combined server+tool wire names under 60 characters', () => {
|
|
92
97
|
for (const profile of Object.values(index_js_1.PROFILES)) {
|
|
93
98
|
const serverName = (0, index_js_1.getProfileServerName)(profile);
|
|
94
|
-
for (const id of (0,
|
|
99
|
+
for (const id of (0, index_js_1.listToolIds)(profile)) {
|
|
95
100
|
const combined = serverName.length + (shared_js_1.TOOL_PREFIX + id).length;
|
|
96
101
|
(0, vitest_1.expect)(combined, `${serverName}+${shared_js_1.TOOL_PREFIX}${id}`).toBeLessThanOrEqual(60);
|
|
97
102
|
}
|
|
@@ -107,7 +112,7 @@ const index_js_1 = require("./index.js");
|
|
|
107
112
|
(0, vitest_1.expect)((0, index_js_1.parseProfileId)('data-analyst')).toBe('data-analyst');
|
|
108
113
|
(0, vitest_1.expect)((0, index_js_1.parseProfileId)('nope')).toBeUndefined();
|
|
109
114
|
});
|
|
110
|
-
(0, vitest_1.it)('
|
|
115
|
+
(0, vitest_1.it)('registerTools registers mounted modules', () => {
|
|
111
116
|
const registered = [];
|
|
112
117
|
const mockServer = {
|
|
113
118
|
registerTool: vitest_1.vi.fn((name) => {
|
|
@@ -115,7 +120,17 @@ const index_js_1 = require("./index.js");
|
|
|
115
120
|
}),
|
|
116
121
|
};
|
|
117
122
|
const mockCtx = { getContext: async () => ({ lightdashClient: {} }) };
|
|
118
|
-
(0, registry_js_1.
|
|
123
|
+
(0, registry_js_1.registerTools)(mockServer, mockCtx, [projects_js_1.listProjectsTool, query_js_1.compileQueryTool]);
|
|
119
124
|
(0, vitest_1.expect)(registered).toEqual([`${shared_js_1.TOOL_PREFIX}list_projects`, `${shared_js_1.TOOL_PREFIX}compile_query`]);
|
|
120
125
|
});
|
|
126
|
+
(0, vitest_1.it)('profile tools have unique ids and are not on the denylist', () => {
|
|
127
|
+
const banned = new Set(common_1.IRRECOVERABLE_TOOL_DENYLIST);
|
|
128
|
+
for (const profile of Object.values(index_js_1.PROFILES)) {
|
|
129
|
+
const ids = (0, index_js_1.listToolIds)(profile);
|
|
130
|
+
(0, vitest_1.expect)(new Set(ids).size).toBe(ids.length);
|
|
131
|
+
for (const id of ids) {
|
|
132
|
+
(0, vitest_1.expect)(banned.has(id)).toBe(false);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
121
136
|
});
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.organizationAuditProfile = exports.ORGANIZATION_AUDIT_PROFILE_PATH = void 0;
|
|
7
|
+
const inventory_js_1 = require("../../../tools/organization/inventory.js");
|
|
8
|
+
const roles_js_1 = require("../../../tools/organization/roles.js");
|
|
9
|
+
const content_js_1 = require("../../../tools/project/content.js");
|
|
10
|
+
const schedulers_js_1 = require("../../../tools/project/schedulers.js");
|
|
11
|
+
const access_js_1 = require("../../../tools/space/access.js");
|
|
7
12
|
const prompts_js_1 = require("./prompts.js");
|
|
8
13
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
14
|
exports.ORGANIZATION_AUDIT_PROFILE_PATH = '/organization-audit/v1/mcp';
|
|
@@ -11,10 +16,26 @@ exports.organizationAuditProfile = {
|
|
|
11
16
|
id: 'organization-audit',
|
|
12
17
|
path: exports.ORGANIZATION_AUDIT_PROFILE_PATH,
|
|
13
18
|
serverName: 'lightdash-mcp-org-audit',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
tools: [
|
|
20
|
+
inventory_js_1.getOrgProfileTool,
|
|
21
|
+
inventory_js_1.listOrgMembersTool,
|
|
22
|
+
inventory_js_1.getOrgMemberTool,
|
|
23
|
+
inventory_js_1.listOrgGroupsTool,
|
|
24
|
+
inventory_js_1.listOrgProjectsTool,
|
|
25
|
+
roles_js_1.listOrgRoleAssignmentsTool,
|
|
26
|
+
roles_js_1.listCustomRolesTool,
|
|
27
|
+
roles_js_1.getCustomRoleTool,
|
|
28
|
+
roles_js_1.listProjectRolesTool,
|
|
29
|
+
roles_js_1.listProjectDirectAccessTool,
|
|
30
|
+
access_js_1.listSpaceAccessTool,
|
|
31
|
+
access_js_1.resolveEffectiveAccessTool,
|
|
32
|
+
content_js_1.listContentTool,
|
|
33
|
+
content_js_1.getDashboardMetaTool,
|
|
34
|
+
content_js_1.listValidationResultsTool,
|
|
35
|
+
content_js_1.getProjectUserActivityTool,
|
|
36
|
+
schedulers_js_1.listProjectSchedulersTool,
|
|
37
|
+
schedulers_js_1.getSchedulerTool,
|
|
38
|
+
],
|
|
39
|
+
registerPrompts: prompts_js_1.registerOrganizationAuditPrompts,
|
|
40
|
+
registerResources: playbooks_js_1.registerOrganizationAuditPlaybook,
|
|
20
41
|
};
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
* Organization-audit prompt/playbook invariants.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const common_1 = require("@lightdash-tools/common");
|
|
7
6
|
const vitest_1 = require("vitest");
|
|
7
|
+
const playbook_invariants_js_1 = require("../../test-support/playbook-invariants.js");
|
|
8
8
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
9
|
(0, vitest_1.describe)('organization-audit prompts/playbook', () => {
|
|
10
10
|
(0, vitest_1.it)('playbook references only registered tool short ids', () => {
|
|
11
11
|
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
12
|
-
|
|
13
|
-
(0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
|
|
14
|
-
}
|
|
15
|
-
(0, vitest_1.expect)(md).not.toMatch(/\bldt__/);
|
|
12
|
+
(0, playbook_invariants_js_1.expectPlaybookCoversProfileTools)('organization-audit', md);
|
|
16
13
|
(0, vitest_1.expect)(md.toLowerCase()).toContain('hard bans');
|
|
17
14
|
(0, vitest_1.expect)(playbooks_js_1.ORGANIZATION_AUDIT_HARD_BANS.toLowerCase()).toContain('compliance');
|
|
18
15
|
});
|
|
@@ -4,16 +4,27 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.semanticLayerProfile = exports.SEMANTIC_LAYER_PROFILE_PATH = void 0;
|
|
7
|
+
const projects_js_1 = require("../../../tools/project/projects.js");
|
|
8
|
+
const explores_js_1 = require("../../../tools/semantic/explores.js");
|
|
9
|
+
const metrics_js_1 = require("../../../tools/semantic/metrics.js");
|
|
10
|
+
const query_js_1 = require("../../../tools/semantic/query.js");
|
|
7
11
|
const prompts_js_1 = require("./prompts.js");
|
|
8
12
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
13
|
exports.SEMANTIC_LAYER_PROFILE_PATH = '/semantic-layer/v1/mcp';
|
|
10
14
|
exports.semanticLayerProfile = {
|
|
11
15
|
id: 'semantic-layer',
|
|
12
16
|
path: exports.SEMANTIC_LAYER_PROFILE_PATH,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
tools: [
|
|
18
|
+
projects_js_1.listProjectsTool,
|
|
19
|
+
projects_js_1.getProjectTool,
|
|
20
|
+
explores_js_1.listExploresTool,
|
|
21
|
+
explores_js_1.getExploreTool,
|
|
22
|
+
explores_js_1.listDimensionsTool,
|
|
23
|
+
explores_js_1.getFieldLineageTool,
|
|
24
|
+
metrics_js_1.listMetricsTool,
|
|
25
|
+
metrics_js_1.getMetricTool,
|
|
26
|
+
query_js_1.compileQueryTool,
|
|
27
|
+
],
|
|
28
|
+
registerPrompts: prompts_js_1.registerSemanticLayerPrompts,
|
|
29
|
+
registerResources: playbooks_js_1.registerSemanticLayerPlaybook,
|
|
19
30
|
};
|
|
@@ -62,7 +62,7 @@ Procedure:
|
|
|
62
62
|
1. If exploreId is missing, resolve it per explore playbook (search + disambiguation). Stay on this projectUuid.
|
|
63
63
|
2. Copy fieldIds from list_dimensions and {exploreId}_{metricName} from get_explore → tables[baseTable].metrics. Never invent grains.
|
|
64
64
|
3. If the user asked for N insights, reuse one explore and compile N diverse cuts.
|
|
65
|
-
4.
|
|
65
|
+
4. Build metricQuery from the compose-compile skeleton (fieldIds only; tool sets exploreName from exploreId and defaults missing tableCalculations to []). After each compile, verify every requested fieldId appears as a SELECT alias (missing alias = failure even without isError). Prefer SELECT aliases over metric name/label. ≤2 fix retries.
|
|
66
66
|
5. Deliverable: insight title(s) + fieldIds + compiled SQL (or errors). Never paste full explore/dimension/metric/lineage payloads.
|
|
67
67
|
|
|
68
68
|
Follow embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_COMPOSE_COMPILE_URI}).`, 'compose-compile');
|
|
@@ -86,7 +86,8 @@ ${err}
|
|
|
86
86
|
${playbooks_js_1.SEMANTIC_LAYER_HARD_BANS}
|
|
87
87
|
|
|
88
88
|
Checklist:
|
|
89
|
-
- unknown field id / empty SELECT / missing SELECT alias → use fieldIds from list_dimensions (base table) + explore-local metrics; re-compile (≤2 retries).
|
|
89
|
+
- unknown field id / empty SELECT / missing SELECT alias → use fieldIds from list_dimensions (base table) + explore-local metrics; re-compile (≤2 retries). Prefer SELECT aliases / compiledSql over metric name/label.
|
|
90
|
+
- Other OpenAPI-required keys still failing (filters, sorts, limit, …) → copy the compose-compile skeleton; MCP fills exploreName and missing tableCalculations.
|
|
90
91
|
- Wrong explore → re-disambiguate (schemaName; label or name __{table}; skip empty schema / eda unless asked).
|
|
91
92
|
- Metric not found / catalog empty → get_explore tables[baseTable].metrics; tableName must be the full explore id; compile as {exploreId}_{metricName}.
|
|
92
93
|
- Verify SELECT aliases after every compile. Stop after a good compile or a clear blocker.
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
* Semantic-layer prompt/playbook invariants.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const common_1 = require("@lightdash-tools/common");
|
|
7
6
|
const vitest_1 = require("vitest");
|
|
7
|
+
const playbook_invariants_js_1 = require("../../test-support/playbook-invariants.js");
|
|
8
8
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
9
|
(0, vitest_1.describe)('semantic-layer prompts/playbook', () => {
|
|
10
10
|
(0, vitest_1.it)('playbooks reference only registered tool short ids', () => {
|
|
11
11
|
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
12
|
-
|
|
13
|
-
(0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
|
|
14
|
-
}
|
|
15
|
-
(0, vitest_1.expect)(md).not.toMatch(/\bldt__/);
|
|
12
|
+
(0, playbook_invariants_js_1.expectPlaybookCoversProfileTools)('semantic-layer', md);
|
|
16
13
|
(0, vitest_1.expect)(md.toLowerCase()).toContain('hard bans');
|
|
17
14
|
(0, vitest_1.expect)(playbooks_js_1.SEMANTIC_LAYER_HARD_BANS.toLowerCase()).toContain('sql');
|
|
18
15
|
});
|
|
@@ -25,16 +25,21 @@ URI: `lightdash://playbooks/semantic-layer/compose-compile`
|
|
|
25
25
|
|
|
26
26
|
`metrics` may be `[]`. Every string in `dimensions` / `metrics` / `sorts[].fieldId` must appear in prior tool output.
|
|
27
27
|
|
|
28
|
+
MCP `compile_query` always sets `exploreName` from the tool `exploreId` (path is authoritative) and defaults missing `tableCalculations` to `[]`. Keep the full skeleton for other OpenAPI-required keys (`filters`, `sorts`, `limit`, …) and for CLI/JSON callers. Prefer SELECT aliases / metric `compiledSql` over metric **name/label** when they disagree.
|
|
29
|
+
|
|
28
30
|
## Field IDs — failure modes
|
|
29
31
|
|
|
30
|
-
| Symptom | Cause | Fix
|
|
31
|
-
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
32
|
-
| `unknown field id` / hard error | Short names or typos | Use full `fieldId` from `list_dimensions` / `{exploreId}_{metricName}`
|
|
33
|
-
| Server `isError` + empty SELECT | Upstream accepted bad ids with **zero** columns | Replace with real fieldIds; re-compile once
|
|
34
|
-
| SQL “succeeds” but a requested dim/metric is **missing** from SELECT | Invented or wrong fieldId (e.g. non-existent `*_session_day`) while another field still projected | Re-check against `list_dimensions` / metrics map; re-compile
|
|
35
|
-
| `
|
|
32
|
+
| Symptom | Cause | Fix |
|
|
33
|
+
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
34
|
+
| `unknown field id` / hard error | Short names or typos | Use full `fieldId` from `list_dimensions` / `{exploreId}_{metricName}` |
|
|
35
|
+
| Server `isError` + empty SELECT | Upstream accepted bad ids with **zero** columns | Replace with real fieldIds; re-compile once |
|
|
36
|
+
| SQL “succeeds” but a requested dim/metric is **missing** from SELECT | Invented or wrong fieldId (e.g. non-existent `*_session_day`) while another field still projected | Re-check against `list_dimensions` / metrics map; re-compile |
|
|
37
|
+
| `UPSTREAM_VALIDATION` / `'tableCalculations' is required` | Body omitted `tableCalculations` (pre-harden / non-MCP clients) | MCP defaults to `[]`; pass `tableCalculations: []` explicitly if needed |
|
|
38
|
+
| `UPSTREAM_VALIDATION` / `'exploreName' is required` | Body omitted `exploreName` (pre-harden / non-MCP clients) or wrong exploreId | Pass locked `exploreId`; MCP fills `exploreName` — re-compile once |
|
|
39
|
+
| `Metric not found` on `get_metric` | `tableName` was warehouse label | Use full explore id |
|
|
40
|
+
| Lineage works with short name but compile fails | `get_field_lineage` accepts short names; `compile_query` does not | Always copy full `fieldId` into `metricQuery` |
|
|
36
41
|
|
|
37
|
-
Compiled SQL may include **extra related metrics** the semantic layer pulls in — OK if every **requested** fieldId still appears as a SELECT alias.
|
|
42
|
+
Compiled SQL may include **extra related metrics** the semantic layer pulls in — OK if every **requested** fieldId still appears as a SELECT alias. Prefer SELECT aliases / metric `compiledSql` over metric **name/label** when they disagree (e.g. a metric named `num_unique_order_ids` that actually `COUNT(DISTINCT customer_id)`).
|
|
38
43
|
|
|
39
44
|
## Verify after every compile (mandatory)
|
|
40
45
|
|
|
@@ -54,7 +59,8 @@ When the user asks for N insights on one table/explore:
|
|
|
54
59
|
|
|
55
60
|
## Debug checklist
|
|
56
61
|
|
|
57
|
-
-
|
|
62
|
+
- Unknown field id / short names / empty SELECT / missing SELECT alias → fix fieldIds from `list_dimensions` + explore-local metrics; re-compile (≤2 retries). Prefer SELECT aliases / `compiledSql` over metric name/label.
|
|
63
|
+
- Other OpenAPI-required keys still failing (`filters`, `sorts`, `limit`, …) → copy the skeleton; MCP already fills `exploreName` and missing `tableCalculations`.
|
|
58
64
|
- Wrong explore → re-disambiguate (`schemaName`; exact `label` or `name` `__{table}`; skip empty schema / eda unless asked).
|
|
59
65
|
- Catalog empty / metric not found → `get_explore` `tables[baseTable].metrics`; compile as `{exploreId}_{metricName}`.
|
|
60
66
|
- Stop after a good verified compile or a clear blocker.
|