@lightdash-tools/mcp 0.7.0 → 0.8.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 +98 -26
- package/dist/auth/oauth-broker/pending-store.d.ts +70 -19
- package/dist/auth/oauth-broker/pending-store.js +53 -26
- package/dist/auth/oauth-broker/pending-store.test.d.ts +6 -0
- package/dist/auth/oauth-broker/pending-store.test.js +146 -0
- package/dist/auth/oauth-broker/routes.d.ts +6 -2
- package/dist/auth/oauth-broker/routes.js +26 -21
- package/dist/auth/oauth-broker/routes.test.js +32 -27
- package/dist/auth/resource-server/www-authenticate.test.js +12 -6
- package/dist/bin.js +23 -2
- package/dist/config/env.d.ts +7 -0
- package/dist/config/env.js +8 -1
- package/dist/config/load-mcp-config.js +4 -0
- package/dist/config/load-mcp-config.test.js +7 -0
- package/dist/config/normalize-url.test.js +13 -7
- package/dist/destructive/capability.d.ts +13 -0
- package/dist/destructive/capability.js +37 -0
- package/dist/destructive/capability.test.d.ts +1 -0
- package/dist/destructive/capability.test.js +46 -0
- package/dist/destructive/confirmation-claim.d.ts +21 -0
- package/dist/destructive/confirmation-claim.js +87 -0
- package/dist/destructive/confirmation-claim.test.d.ts +1 -0
- package/dist/destructive/confirmation-claim.test.js +50 -0
- package/dist/destructive/confirmation.d.ts +58 -0
- package/dist/destructive/confirmation.js +99 -0
- package/dist/destructive/confirmation.test.d.ts +1 -0
- package/dist/destructive/confirmation.test.js +75 -0
- package/dist/destructive/content-promote.d.ts +8 -0
- package/dist/destructive/content-promote.js +144 -0
- package/dist/destructive/content-soft-delete.d.ts +7 -0
- package/dist/destructive/content-soft-delete.js +106 -0
- package/dist/destructive/destructive-contract.test.d.ts +1 -0
- package/dist/destructive/destructive-contract.test.js +269 -0
- package/dist/destructive/precondition.d.ts +14 -0
- package/dist/destructive/precondition.js +31 -0
- package/dist/destructive/precondition.test.d.ts +1 -0
- package/dist/destructive/precondition.test.js +72 -0
- package/dist/destructive/promote-contract.test.d.ts +1 -0
- package/dist/destructive/promote-contract.test.js +339 -0
- package/dist/destructive/register-destructive-tool.d.ts +54 -0
- package/dist/destructive/register-destructive-tool.js +301 -0
- package/dist/destructive/request-state.d.ts +16 -0
- package/dist/destructive/request-state.js +76 -0
- package/dist/destructive/types.d.ts +64 -0
- package/dist/destructive/types.js +10 -0
- package/dist/governance/mcp-client-session.d.ts +9 -0
- package/dist/governance/mcp-client-session.js +30 -0
- package/dist/governance/mcp-client-session.test.d.ts +1 -0
- package/dist/governance/mcp-client-session.test.js +31 -0
- package/dist/governance/project-scope.d.ts +38 -0
- package/dist/governance/project-scope.js +79 -0
- package/dist/governance/project-scope.test.d.ts +4 -0
- package/dist/governance/project-scope.test.js +103 -0
- package/dist/http.integration.test.js +34 -0
- package/dist/index.js +1 -1
- package/dist/personas/content-developer/v1/index.d.ts +10 -0
- package/dist/personas/content-developer/v1/index.js +51 -0
- package/dist/personas/content-developer/v1/prompts.d.ts +5 -0
- package/dist/personas/content-developer/v1/prompts.js +138 -0
- package/dist/personas/content-developer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-developer/v1/prompts.test.js +75 -0
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +15 -0
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +63 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +55 -0
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/content-developer/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-developer/v1/resources/playbooks.js +44 -0
- package/dist/personas/content-governance/v1/index.d.ts +9 -0
- package/dist/personas/content-governance/v1/index.js +29 -0
- package/dist/personas/content-governance/v1/prompts.d.ts +5 -0
- package/dist/personas/content-governance/v1/prompts.js +87 -0
- package/dist/personas/content-governance/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-governance/v1/prompts.test.js +75 -0
- package/dist/personas/content-governance/v1/resources/playbooks/charts.md +29 -0
- package/dist/personas/content-governance/v1/resources/playbooks/core.md +52 -0
- package/dist/personas/content-governance/v1/resources/playbooks/dashboards.md +48 -0
- package/dist/personas/content-governance/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/content-governance/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-governance/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-reader/v1/index.d.ts +8 -0
- package/dist/personas/content-reader/v1/index.js +37 -0
- package/dist/personas/content-reader/v1/prompts.d.ts +5 -0
- package/dist/personas/content-reader/v1/prompts.js +128 -0
- package/dist/personas/content-reader/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-reader/v1/prompts.test.js +25 -0
- package/dist/personas/content-reader/v1/resources/playbooks/compare.md +21 -0
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +40 -0
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +13 -0
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +19 -0
- package/dist/personas/content-reader/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/content-reader/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-reader/v1/resources/playbooks.js +49 -0
- package/dist/personas/index.d.ts +3 -0
- package/dist/personas/index.js +26 -10
- package/dist/personas/index.test.js +77 -26
- package/dist/personas/lib/playbook-resources.d.ts +79 -0
- package/dist/personas/lib/playbook-resources.js +165 -0
- package/dist/personas/organization-audit/v1/index.js +2 -2
- package/dist/personas/organization-audit/v1/prompts.js +14 -33
- package/dist/personas/organization-audit/v1/prompts.test.js +4 -4
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +13 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +9 -0
- package/dist/personas/organization-audit/v1/resources/{playbook.md → playbooks/core.md} +6 -22
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +9 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.js +41 -0
- package/dist/personas/persona.parity.test.d.ts +1 -0
- package/dist/personas/persona.parity.test.js +26 -0
- package/dist/personas/semantic-layer/v1/index.js +2 -2
- package/dist/personas/semantic-layer/v1/prompts.js +15 -37
- package/dist/personas/semantic-layer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/semantic-layer/v1/prompts.test.js +19 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/compose-compile.md +55 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +39 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +76 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.d.ts +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.js +39 -0
- package/dist/personas/types.d.ts +1 -1
- package/dist/policy/content-developer.d.ts +35 -0
- package/dist/policy/content-developer.js +91 -0
- package/dist/policy/content-developer.test.d.ts +4 -0
- package/dist/policy/content-developer.test.js +48 -0
- package/dist/policy/content-reader.d.ts +24 -0
- package/dist/policy/content-reader.js +52 -0
- package/dist/policy/content-reader.test.d.ts +4 -0
- package/dist/policy/content-reader.test.js +22 -0
- package/dist/policy/envelope.d.ts +31 -0
- package/dist/policy/envelope.js +24 -0
- package/dist/policy/preview-ledger-fault.test.d.ts +1 -0
- package/dist/policy/preview-ledger-fault.test.js +527 -0
- package/dist/policy/preview-ledger.d.ts +118 -0
- package/dist/policy/preview-ledger.js +243 -0
- package/dist/policy/preview-ledger.test.d.ts +1 -0
- package/dist/policy/preview-ledger.test.js +267 -0
- package/dist/policy/result-limits.d.ts +27 -0
- package/dist/policy/result-limits.js +107 -0
- package/dist/policy/result-limits.test.d.ts +4 -0
- package/dist/policy/result-limits.test.js +28 -0
- package/dist/server/capabilities.js +1 -1
- package/dist/server/capabilities.test.js +3 -1
- package/dist/server/server.js +12 -1
- package/dist/stdio.process.test.js +148 -0
- package/dist/store/config.d.ts +11 -0
- package/dist/store/config.js +50 -0
- package/dist/store/config.test.d.ts +1 -0
- package/dist/store/config.test.js +56 -0
- package/dist/store/create-oauth-broker-store.d.ts +6 -0
- package/dist/store/create-oauth-broker-store.js +16 -0
- package/dist/store/create-preview-store.d.ts +10 -0
- package/dist/store/create-preview-store.js +30 -0
- package/dist/store/create-session-store.d.ts +19 -0
- package/dist/store/create-session-store.js +24 -0
- package/dist/store/in-memory-preview-store.d.ts +17 -0
- package/dist/store/in-memory-preview-store.js +72 -0
- package/dist/store/redis-client.d.ts +11 -0
- package/dist/store/redis-client.js +48 -0
- package/dist/store/redis-oauth-broker-store.d.ts +42 -0
- package/dist/store/redis-oauth-broker-store.js +167 -0
- package/dist/store/redis-oauth-broker-store.test.d.ts +1 -0
- package/dist/store/redis-oauth-broker-store.test.js +80 -0
- package/dist/store/redis-preview-store.d.ts +23 -0
- package/dist/store/redis-preview-store.js +94 -0
- package/dist/store/redis-preview-store.test.d.ts +1 -0
- package/dist/store/redis-preview-store.test.js +39 -0
- package/dist/store/redis-session-index.d.ts +33 -0
- package/dist/store/redis-session-index.js +49 -0
- package/dist/store/types.d.ts +13 -0
- package/dist/store/types.js +8 -0
- package/dist/tools/composition/explain-content.d.ts +6 -0
- package/dist/tools/composition/explain-content.js +108 -0
- package/dist/tools/lib/api-errors.d.ts +2 -0
- package/dist/tools/lib/api-errors.js +5 -0
- package/dist/tools/lib/stable-stringify.d.ts +9 -0
- package/dist/tools/lib/stable-stringify.js +35 -0
- package/dist/tools/project/delete-chart.d.ts +4 -0
- package/dist/tools/project/delete-chart.js +8 -0
- package/dist/tools/project/delete-dashboard.d.ts +4 -0
- package/dist/tools/project/delete-dashboard.js +8 -0
- package/dist/tools/project/developer-content-preview.d.ts +12 -0
- package/dist/tools/project/developer-content-preview.js +286 -0
- package/dist/tools/project/developer-content-shared.d.ts +18 -0
- package/dist/tools/project/developer-content-shared.js +46 -0
- package/dist/tools/project/developer-content-shared.test.d.ts +1 -0
- package/dist/tools/project/developer-content-shared.test.js +25 -0
- package/dist/tools/project/developer-content.d.ts +39 -0
- package/dist/tools/project/developer-content.js +584 -0
- package/dist/tools/project/developer-helpers.d.ts +180 -0
- package/dist/tools/project/developer-helpers.js +484 -0
- package/dist/tools/project/developer-helpers.test.d.ts +1 -0
- package/dist/tools/project/developer-helpers.test.js +509 -0
- package/dist/tools/project/get-dashboard-promote-diff.d.ts +6 -0
- package/dist/tools/project/get-dashboard-promote-diff.js +42 -0
- package/dist/tools/project/invariants.test.d.ts +4 -0
- package/dist/tools/project/invariants.test.js +42 -0
- package/dist/tools/project/parameters.d.ts +7 -0
- package/dist/tools/project/parameters.js +74 -0
- package/dist/tools/project/projects.d.ts +4 -1
- package/dist/tools/project/projects.js +64 -4
- package/dist/tools/project/projects.test.js +38 -1
- package/dist/tools/project/promote-dashboard.d.ts +4 -0
- package/dist/tools/project/promote-dashboard.js +8 -0
- package/dist/tools/project/reader-content.d.ts +9 -0
- package/dist/tools/project/reader-content.js +208 -0
- package/dist/tools/project/reader-execution.d.ts +7 -0
- package/dist/tools/project/reader-execution.js +214 -0
- package/dist/tools/project/schemas/chart-upsert.d.ts +33 -0
- package/dist/tools/project/schemas/chart-upsert.js +66 -0
- package/dist/tools/project/schemas/dashboard-tile.d.ts +29 -0
- package/dist/tools/project/schemas/dashboard-tile.js +57 -0
- package/dist/tools/project/schemas/dashboard.d.ts +70 -0
- package/dist/tools/project/schemas/dashboard.js +101 -0
- package/dist/tools/project/schemas/duplicate.d.ts +30 -0
- package/dist/tools/project/schemas/duplicate.js +86 -0
- package/dist/tools/project/schemas/index.d.ts +7 -0
- package/dist/tools/project/schemas/index.js +26 -0
- package/dist/tools/project/schemas/parse-helpers.d.ts +14 -0
- package/dist/tools/project/schemas/parse-helpers.js +34 -0
- package/dist/tools/project/schemas/payload-schemas.test.d.ts +1 -0
- package/dist/tools/project/schemas/payload-schemas.test.js +204 -0
- package/dist/tools/project/spaces.d.ts +7 -0
- package/dist/tools/project/spaces.js +101 -0
- package/dist/tools/query/bounded-saved-query.d.ts +37 -0
- package/dist/tools/query/bounded-saved-query.js +80 -0
- package/dist/tools/query/bounded-saved-query.test.d.ts +4 -0
- package/dist/tools/query/bounded-saved-query.test.js +82 -0
- package/dist/tools/query/chart-source.d.ts +10 -0
- package/dist/tools/query/chart-source.js +36 -0
- package/dist/tools/query/chart-source.test.d.ts +1 -0
- package/dist/tools/query/chart-source.test.js +62 -0
- package/dist/tools/query/filter-overrides.d.ts +34 -0
- package/dist/tools/query/filter-overrides.js +75 -0
- package/dist/tools/query/filter-overrides.test.d.ts +1 -0
- package/dist/tools/query/filter-overrides.test.js +21 -0
- package/dist/tools/query/lifecycle.d.ts +7 -0
- package/dist/tools/query/lifecycle.js +112 -0
- package/dist/tools/query/query-ledger.d.ts +34 -0
- package/dist/tools/query/query-ledger.js +86 -0
- package/dist/tools/query/query-ledger.test.d.ts +1 -0
- package/dist/tools/query/query-ledger.test.js +73 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +12 -0
- package/dist/tools/query/reader-tool-helpers.js +59 -0
- package/dist/tools/query/reader-tool-helpers.test.d.ts +1 -0
- package/dist/tools/query/reader-tool-helpers.test.js +49 -0
- package/dist/tools/query/result-normalizer.d.ts +27 -0
- package/dist/tools/query/result-normalizer.js +133 -0
- package/dist/tools/query/result-normalizer.test.d.ts +1 -0
- package/dist/tools/query/result-normalizer.test.js +41 -0
- package/dist/tools/query/wait-for-async.d.ts +10 -0
- package/dist/tools/query/wait-for-async.js +46 -0
- package/dist/tools/query/wait-for-async.test.d.ts +1 -0
- package/dist/tools/query/wait-for-async.test.js +45 -0
- package/dist/tools/registry.d.ts +124 -3
- package/dist/tools/registry.js +63 -7
- package/dist/tools/shared.d.ts +25 -2
- package/dist/tools/shared.js +66 -13
- package/dist/tools/shared.test.js +6 -2
- package/dist/transports/session-store.d.ts +33 -1
- package/dist/transports/session-store.js +56 -1
- package/dist/transports/streamable-http.js +10 -3
- package/dist/transports/streamable-http.test.js +11 -6
- package/package.json +6 -5
- package/dist/personas/organization-audit/v1/resources/playbook.d.ts +0 -11
- package/dist/personas/organization-audit/v1/resources/playbook.js +0 -40
- package/dist/personas/semantic-layer/v1/resources/playbook.d.ts +0 -12
- package/dist/personas/semantic-layer/v1/resources/playbook.js +0 -42
- package/dist/personas/semantic-layer/v1/resources/playbook.md +0 -153
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.organizationAuditPersona = exports.ORGANIZATION_AUDIT_TOOL_IDS = exports.ORGANIZATION_AUDIT_PERSONA_PATH = void 0;
|
|
7
7
|
const prompts_js_1 = require("./prompts.js");
|
|
8
|
-
const
|
|
8
|
+
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
9
|
exports.ORGANIZATION_AUDIT_PERSONA_PATH = '/organization-audit/v1/mcp';
|
|
10
10
|
/** Explicit allowlist — must stay a deliberate subset of the shared registry. */
|
|
11
11
|
exports.ORGANIZATION_AUDIT_TOOL_IDS = [
|
|
@@ -37,6 +37,6 @@ exports.organizationAuditPersona = {
|
|
|
37
37
|
(0, prompts_js_1.registerOrganizationAuditPrompts)(server);
|
|
38
38
|
},
|
|
39
39
|
registerResources: (server) => {
|
|
40
|
-
(0,
|
|
40
|
+
(0, playbooks_js_1.registerOrganizationAuditPlaybook)(server);
|
|
41
41
|
},
|
|
42
42
|
};
|
|
@@ -6,31 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.registerOrganizationAuditPrompts = registerOrganizationAuditPrompts;
|
|
7
7
|
/* eslint-disable @typescript-eslint/no-deprecated -- matches semantic-layer prompt registration pattern */
|
|
8
8
|
const zod_1 = require("zod");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
mimeType: playbook_js_1.ORGANIZATION_AUDIT_PLAYBOOK_MIME,
|
|
16
|
-
text: (0, playbook_js_1.getPlaybookMarkdown)(),
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function userMessages(text) {
|
|
21
|
-
return {
|
|
22
|
-
messages: [
|
|
23
|
-
{
|
|
24
|
-
role: 'user',
|
|
25
|
-
content: { type: 'text', text },
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
role: 'user',
|
|
29
|
-
content: playbookEmbeddedResource(),
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|
|
33
|
-
}
|
|
9
|
+
const playbook_resources_js_1 = require("../../lib/playbook-resources.js");
|
|
10
|
+
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
11
|
+
const userMessages = (0, playbook_resources_js_1.createPromptPlaybookEmbedder)({
|
|
12
|
+
core: playbooks_js_1.ORGANIZATION_AUDIT_CORE_PLAYBOOK,
|
|
13
|
+
topics: playbooks_js_1.ORGANIZATION_AUDIT_TOPIC_PLAYBOOKS,
|
|
14
|
+
});
|
|
34
15
|
function registerOrganizationAuditPrompts(server) {
|
|
35
16
|
server.registerPrompt('audit_organization', {
|
|
36
17
|
title: 'Audit organization',
|
|
@@ -44,7 +25,7 @@ function registerOrganizationAuditPrompts(server) {
|
|
|
44
25
|
},
|
|
45
26
|
}, ({ projectUuids, allowedEmailDomains }) => userMessages(`Perform an evidence-backed, read-only audit of the current Lightdash organization.
|
|
46
27
|
|
|
47
|
-
${
|
|
28
|
+
${playbooks_js_1.ORGANIZATION_AUDIT_HARD_BANS}
|
|
48
29
|
|
|
49
30
|
Scope:
|
|
50
31
|
- Use only the organization and projects visible to the authenticated caller.
|
|
@@ -65,22 +46,22 @@ Procedure (primitives only — there are no lightdash_audit_* tools):
|
|
|
65
46
|
argsSchema: {},
|
|
66
47
|
}, () => userMessages(`Review Lightdash identity and access governance.
|
|
67
48
|
|
|
68
|
-
${
|
|
49
|
+
${playbooks_js_1.ORGANIZATION_AUDIT_HARD_BANS}
|
|
69
50
|
|
|
70
51
|
Use lightdash_list_org_members, lightdash_list_org_role_assignments, lightdash_list_project_roles, lightdash_list_project_direct_access, lightdash_list_space_access, and lightdash_resolve_effective_access.
|
|
71
52
|
Do not treat lightdash_list_project_direct_access as complete effective access.
|
|
72
|
-
State assumptions and coverage gaps
|
|
53
|
+
State assumptions and coverage gaps.`, 'access'));
|
|
73
54
|
server.registerPrompt('review_content_governance', {
|
|
74
55
|
title: 'Review content governance',
|
|
75
56
|
description: 'Inventory content health and ownership risks via list tools',
|
|
76
57
|
argsSchema: {},
|
|
77
58
|
}, () => userMessages(`Inventory charts, dashboards, and spaces; evaluate validation, ownership, and usage.
|
|
78
59
|
|
|
79
|
-
${
|
|
60
|
+
${playbooks_js_1.ORGANIZATION_AUDIT_HARD_BANS}
|
|
80
61
|
|
|
81
62
|
Use lightdash_list_content, lightdash_list_validation_results, and lightdash_get_project_user_activity (plus lightdash_get_dashboard_meta when needed).
|
|
82
63
|
Join results in the conversation — do not assume a server-side audit tool.
|
|
83
|
-
Do not recommend deletion solely because content is unused
|
|
64
|
+
Do not recommend deletion solely because content is unused.`, 'content'));
|
|
84
65
|
server.registerPrompt('review_scheduled_deliveries', {
|
|
85
66
|
title: 'Review scheduled deliveries',
|
|
86
67
|
description: 'Inspect schedulers without executing them',
|
|
@@ -89,11 +70,11 @@ Do not recommend deletion solely because content is unused.`));
|
|
|
89
70
|
},
|
|
90
71
|
}, ({ allowedEmailDomains }) => userMessages(`Inspect scheduled deliveries without creating, editing, executing, enabling, disabling, or deleting schedules.
|
|
91
72
|
|
|
92
|
-
${
|
|
73
|
+
${playbooks_js_1.ORGANIZATION_AUDIT_HARD_BANS}
|
|
93
74
|
|
|
94
75
|
Allowed email domains: ${allowedEmailDomains !== null && allowedEmailDomains !== void 0 ? allowedEmailDomains : '(none provided)'}.
|
|
95
76
|
Use lightdash_list_project_schedulers and lightdash_get_scheduler.
|
|
96
|
-
Redact destinations by default. External destinations are review signals, not automatic violations
|
|
77
|
+
Redact destinations by default. External destinations are review signals, not automatic violations.`, 'deliveries'));
|
|
97
78
|
server.registerPrompt('investigate_audit_finding', {
|
|
98
79
|
title: 'Investigate audit finding',
|
|
99
80
|
description: 'Validate or refute one previously reported finding',
|
|
@@ -104,7 +85,7 @@ Redact destinations by default. External destinations are review signals, not au
|
|
|
104
85
|
|
|
105
86
|
${findingSummary}
|
|
106
87
|
|
|
107
|
-
${
|
|
88
|
+
${playbooks_js_1.ORGANIZATION_AUDIT_HARD_BANS}
|
|
108
89
|
|
|
109
90
|
Use only primitive list/get tools. Report supporting evidence, contradictory evidence, remaining uncertainty, and whether severity/confidence changed.`));
|
|
110
91
|
}
|
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const vitest_1 = require("vitest");
|
|
7
|
-
const
|
|
7
|
+
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
8
8
|
const index_js_1 = require("./index.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
|
-
const md = (0,
|
|
11
|
+
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
12
12
|
for (const id of index_js_1.ORGANIZATION_AUDIT_TOOL_IDS) {
|
|
13
13
|
(0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
|
|
14
14
|
}
|
|
15
15
|
(0, vitest_1.expect)(md).not.toMatch(/\bldt__/);
|
|
16
16
|
(0, vitest_1.expect)(md.toLowerCase()).toContain('hard bans');
|
|
17
|
-
(0, vitest_1.expect)(
|
|
17
|
+
(0, vitest_1.expect)(playbooks_js_1.ORGANIZATION_AUDIT_HARD_BANS.toLowerCase()).toContain('compliance');
|
|
18
18
|
});
|
|
19
19
|
(0, vitest_1.it)('playbook forbids mutation and warehouse queries', () => {
|
|
20
|
-
const md = (0,
|
|
20
|
+
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)().toLowerCase();
|
|
21
21
|
(0, vitest_1.expect)(md).toContain('do not mutate');
|
|
22
22
|
(0, vitest_1.expect)(md).toContain('warehouse');
|
|
23
23
|
(0, vitest_1.expect)(md).toContain('deletion');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Organization-audit — access governance
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/organization-audit/access`
|
|
4
|
+
|
|
5
|
+
## Phase 1 — Identity
|
|
6
|
+
|
|
7
|
+
Call `list_org_members` (paginate while `pagination.complete` is false, or stop after a small page budget). Optionally `list_org_groups`, `list_org_role_assignments`, `list_custom_roles`, `get_org_member` for spot checks.
|
|
8
|
+
|
|
9
|
+
## Phase 2 — Projects and access
|
|
10
|
+
|
|
11
|
+
Call `list_org_projects`, then for a capped set of projects: `list_project_roles`, `list_project_direct_access`, `list_space_access`, and `resolve_effective_access`. Treat `list_project_direct_access` as direct grants only; emails are masked by default — pass `includeEmail=true` only when required. Pass `allowedEmailDomains` when classifying external direct-access principals. Honor incomplete flags and truncation warnings.
|
|
12
|
+
|
|
13
|
+
Do not treat `list_project_direct_access` as complete effective access. State assumptions and coverage gaps.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Organization-audit — content and health
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/organization-audit/content`
|
|
4
|
+
|
|
5
|
+
## Phase 3 — Content and health
|
|
6
|
+
|
|
7
|
+
Per project (capped): `list_content` (use `sortBy`/`sortDirection`/`page` intentionally), `list_validation_results`, `get_project_user_activity`. Use `get_dashboard_meta` only when needed. Host joins validation, views, and ownership into findings — do not invent a server-side crawler.
|
|
8
|
+
|
|
9
|
+
Do not recommend deletion solely because content is unused. Join results in the conversation — do not assume a server-side audit tool.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
# Organization-audit
|
|
1
|
+
# Organization-audit core
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/organization-audit/core`
|
|
2
4
|
|
|
3
5
|
Read-only evidence collection for Lightdash organization administrators. Findings are review signals synthesized by the host from primitive tool results — not compliance certifications. There are no composed `audit_*` MCP tools; chain bounded `lightdash_*` reads instead.
|
|
4
6
|
|
|
@@ -23,30 +25,12 @@ Content / health: `list_content`, `get_dashboard_meta`, `list_validation_results
|
|
|
23
25
|
|
|
24
26
|
Delivery: `list_project_schedulers`, `get_scheduler`
|
|
25
27
|
|
|
26
|
-
##
|
|
27
|
-
|
|
28
|
-
### Phase 0 — Scope
|
|
28
|
+
## Phase 0 — Scope
|
|
29
29
|
|
|
30
30
|
1. Call `lightdash_get_org_profile`.
|
|
31
31
|
2. Record organization UUID, project pin (`X-Lightdash-Project`), thresholds, and `auditVisibility`.
|
|
32
32
|
3. Downgrade organization-wide claims when visibility is `partial`.
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Call `list_org_members` (paginate while `pagination.complete` is false, or stop after a small page budget). Optionally `list_org_groups`, `list_org_role_assignments`, `list_custom_roles`, `get_org_member` for spot checks.
|
|
37
|
-
|
|
38
|
-
### Phase 2 — Projects and access
|
|
39
|
-
|
|
40
|
-
Call `list_org_projects`, then for a capped set of projects: `list_project_roles`, `list_project_direct_access`, `list_space_access`, and `resolve_effective_access`. Treat `list_project_direct_access` as direct grants only; emails are masked by default — pass `includeEmail=true` only when required. Pass `allowedEmailDomains` when classifying external direct-access principals. Honor incomplete flags and truncation warnings.
|
|
41
|
-
|
|
42
|
-
### Phase 3 — Content and health
|
|
43
|
-
|
|
44
|
-
Per project (capped): `list_content` (use `sortBy`/`sortDirection`/`page` intentionally), `list_validation_results`, `get_project_user_activity`. Use `get_dashboard_meta` only when needed. Host joins validation, views, and ownership into findings — do not invent a server-side crawler.
|
|
45
|
-
|
|
46
|
-
### Phase 4 — Deliveries
|
|
47
|
-
|
|
48
|
-
Per project (capped): `list_project_schedulers` (destinations redacted by default; pass `revealDestinations` only when required). Use `get_scheduler` with `projectUuid` + `schedulerUuid` for one schedule. Pass `allowedEmailDomains` when reviewing external email destinations.
|
|
49
|
-
|
|
50
|
-
### Phase 5 — Report
|
|
34
|
+
## Phase 5 — Report
|
|
51
35
|
|
|
52
|
-
Synthesize findings from tool evidence in the conversation. Always include coverage gaps, assumptions, truncation, and resource UUIDs. Never claim the inventory was exhaustive when `pagination.complete` is false.
|
|
36
|
+
Synthesize findings from tool evidence in the conversation. Always include coverage gaps, assumptions, truncation, and resource UUIDs. Never claim the inventory was exhaustive when `pagination.complete` is false. Distinguish facts, inferred risks, assumptions, inaccessible areas, and truncation. Cite every finding with `lightdash_*` tool names and resource UUIDs. Do not claim formal compliance certification.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Organization-audit — scheduled deliveries
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/organization-audit/deliveries`
|
|
4
|
+
|
|
5
|
+
## Phase 4 — Deliveries
|
|
6
|
+
|
|
7
|
+
Per project (capped): `list_project_schedulers` (destinations redacted by default; pass `revealDestinations` only when required). Use `get_scheduler` with `projectUuid` + `schedulerUuid` for one schedule. Pass `allowedEmailDomains` when reviewing external email destinations.
|
|
8
|
+
|
|
9
|
+
Inspect scheduled deliveries without creating, editing, executing, enabling, disabling, or deleting schedules. Redact destinations by default. External destinations are review signals, not automatic violations.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Organization-audit playbooks
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/organization-audit`
|
|
4
|
+
|
|
5
|
+
Workflow-scoped playbooks. Prompts always embed **core**; topic prompts also embed one topic (overview prompts may be core-only):
|
|
6
|
+
|
|
7
|
+
| Topic | URI |
|
|
8
|
+
| --------------------- | ----------------------------------------------------- |
|
|
9
|
+
| Core (gates & report) | `lightdash://playbooks/organization-audit/core` |
|
|
10
|
+
| Access governance | `lightdash://playbooks/organization-audit/access` |
|
|
11
|
+
| Content and health | `lightdash://playbooks/organization-audit/content` |
|
|
12
|
+
| Scheduled deliveries | `lightdash://playbooks/organization-audit/deliveries` |
|
|
13
|
+
|
|
14
|
+
Read-only evidence collection for Lightdash organization administrators. Findings are review signals synthesized by the host from primitive tool results — not compliance certifications. There are no composed `audit_*` MCP tools; chain bounded `lightdash_*` reads instead.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization-audit multi-playbook resources (core + topics + index).
|
|
3
|
+
*/
|
|
4
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
5
|
+
export type OrganizationAuditPlaybookTopic = 'access' | 'content' | 'deliveries';
|
|
6
|
+
export declare const ORGANIZATION_AUDIT_HARD_BANS: string;
|
|
7
|
+
export declare const getAllPlaybookMarkdown: () => string;
|
|
8
|
+
export declare const ORGANIZATION_AUDIT_CORE_PLAYBOOK: import("../../../lib/playbook-resources.js").EmbeddedPlaybook;
|
|
9
|
+
export declare const ORGANIZATION_AUDIT_TOPIC_PLAYBOOKS: Readonly<Record<OrganizationAuditPlaybookTopic, import("../../../lib/playbook-resources.js").EmbeddedPlaybook>>;
|
|
10
|
+
export declare function registerOrganizationAuditPlaybook(server: McpServer): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Organization-audit multi-playbook resources (core + topics + index).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ORGANIZATION_AUDIT_TOPIC_PLAYBOOKS = exports.ORGANIZATION_AUDIT_CORE_PLAYBOOK = exports.getAllPlaybookMarkdown = exports.ORGANIZATION_AUDIT_HARD_BANS = void 0;
|
|
7
|
+
exports.registerOrganizationAuditPlaybook = registerOrganizationAuditPlaybook;
|
|
8
|
+
const playbook_resources_js_1 = require("../../../lib/playbook-resources.js");
|
|
9
|
+
const playbooks = (0, playbook_resources_js_1.definePersonaPlaybooks)({
|
|
10
|
+
personaId: 'organization-audit',
|
|
11
|
+
moduleDir: __dirname,
|
|
12
|
+
hardBans: 'Do not mutate users/groups/roles/content/schedulers, execute warehouse or chart queries, download user-activity CSV, reveal secrets, or claim compliance certification. Those capabilities are not available on this server.',
|
|
13
|
+
coreDescription: 'Hard bans, tool catalog, scope, and report rules',
|
|
14
|
+
topics: [
|
|
15
|
+
{
|
|
16
|
+
id: 'access',
|
|
17
|
+
title: 'Organization-audit access playbook',
|
|
18
|
+
description: 'Identity and project/access governance phases',
|
|
19
|
+
file: 'access.md',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'content',
|
|
23
|
+
title: 'Organization-audit content playbook',
|
|
24
|
+
description: 'Content inventory, validation, and usage health',
|
|
25
|
+
file: 'content.md',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'deliveries',
|
|
29
|
+
title: 'Organization-audit deliveries playbook',
|
|
30
|
+
description: 'Scheduled delivery review without mutation',
|
|
31
|
+
file: 'deliveries.md',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
exports.ORGANIZATION_AUDIT_HARD_BANS = playbooks.HARD_BANS;
|
|
36
|
+
exports.getAllPlaybookMarkdown = playbooks.getAllPlaybookMarkdown;
|
|
37
|
+
exports.ORGANIZATION_AUDIT_CORE_PLAYBOOK = playbooks.CORE_PLAYBOOK;
|
|
38
|
+
exports.ORGANIZATION_AUDIT_TOPIC_PLAYBOOKS = playbooks.TOPIC_PLAYBOOKS;
|
|
39
|
+
function registerOrganizationAuditPlaybook(server) {
|
|
40
|
+
playbooks.registerPlaybooks(server);
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_1 = require("@lightdash-tools/common");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const index_js_1 = require("./content-developer/v1/index.js");
|
|
6
|
+
const index_js_2 = require("./content-governance/v1/index.js");
|
|
7
|
+
const index_js_3 = require("./content-reader/v1/index.js");
|
|
8
|
+
const index_js_4 = require("./organization-audit/v1/index.js");
|
|
9
|
+
const index_js_5 = require("./semantic-layer/v1/index.js");
|
|
10
|
+
(0, vitest_1.describe)('persona catalog parity', () => {
|
|
11
|
+
(0, vitest_1.it)('semantic-layer allowlist matches catalog semantic-discovery profile', () => {
|
|
12
|
+
(0, vitest_1.expect)([...index_js_5.SEMANTIC_LAYER_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('semantic-discovery')].sort());
|
|
13
|
+
});
|
|
14
|
+
(0, vitest_1.it)('organization-audit allowlist matches catalog org-audit-readonly profile', () => {
|
|
15
|
+
(0, vitest_1.expect)([...index_js_4.ORGANIZATION_AUDIT_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('org-audit-readonly')].sort());
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.it)('content-reader allowlist matches catalog content-reader profile', () => {
|
|
18
|
+
(0, vitest_1.expect)([...index_js_3.CONTENT_READER_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('content-reader')].sort());
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.it)('content-developer allowlist matches catalog content-developer profile', () => {
|
|
21
|
+
(0, vitest_1.expect)([...index_js_1.CONTENT_DEVELOPER_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('content-developer')].sort());
|
|
22
|
+
});
|
|
23
|
+
(0, vitest_1.it)('content-governance allowlist matches catalog content-governance profile', () => {
|
|
24
|
+
(0, vitest_1.expect)([...index_js_2.CONTENT_GOVERNANCE_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('content-governance')].sort());
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.semanticLayerPersona = exports.SEMANTIC_LAYER_TOOL_IDS = exports.SEMANTIC_LAYER_PERSONA_PATH = void 0;
|
|
7
7
|
const prompts_js_1 = require("./prompts.js");
|
|
8
|
-
const
|
|
8
|
+
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
9
|
exports.SEMANTIC_LAYER_PERSONA_PATH = '/semantic-layer/v1/mcp';
|
|
10
10
|
/** Explicit allowlist — must stay a deliberate subset of the shared registry. */
|
|
11
11
|
exports.SEMANTIC_LAYER_TOOL_IDS = [
|
|
@@ -27,6 +27,6 @@ exports.semanticLayerPersona = {
|
|
|
27
27
|
(0, prompts_js_1.registerSemanticLayerPrompts)(server);
|
|
28
28
|
},
|
|
29
29
|
registerResources: (server) => {
|
|
30
|
-
(0,
|
|
30
|
+
(0, playbooks_js_1.registerSemanticLayerPlaybook)(server);
|
|
31
31
|
},
|
|
32
32
|
};
|
|
@@ -7,34 +7,12 @@ exports.registerSemanticLayerPrompts = registerSemanticLayerPrompts;
|
|
|
7
7
|
const zod_1 = require("zod");
|
|
8
8
|
const schema_fields_js_1 = require("../../../tools/lib/schema-fields.js");
|
|
9
9
|
const schema_fields_js_2 = require("../../../tools/semantic/schema-fields.js");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
mimeType: playbook_js_1.SEMANTIC_LAYER_PLAYBOOK_MIME,
|
|
17
|
-
text: (0, playbook_js_1.getPlaybookMarkdown)(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function userMessages(text) {
|
|
22
|
-
return {
|
|
23
|
-
messages: [
|
|
24
|
-
{
|
|
25
|
-
role: 'user',
|
|
26
|
-
content: {
|
|
27
|
-
type: 'text',
|
|
28
|
-
text,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
role: 'user',
|
|
33
|
-
content: playbookEmbeddedResource(),
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
};
|
|
37
|
-
}
|
|
10
|
+
const playbook_resources_js_1 = require("../../lib/playbook-resources.js");
|
|
11
|
+
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
12
|
+
const userMessages = (0, playbook_resources_js_1.createPromptPlaybookEmbedder)({
|
|
13
|
+
core: playbooks_js_1.SEMANTIC_LAYER_CORE_PLAYBOOK,
|
|
14
|
+
topics: playbooks_js_1.SEMANTIC_LAYER_TOPIC_PLAYBOOKS,
|
|
15
|
+
});
|
|
38
16
|
function registerSemanticLayerPrompts(server) {
|
|
39
17
|
server.registerPrompt('lightdash_semantic_explore', {
|
|
40
18
|
title: 'Explore semantic layer',
|
|
@@ -48,14 +26,14 @@ function registerSemanticLayerPrompts(server) {
|
|
|
48
26
|
return userMessages([
|
|
49
27
|
'Discover the Lightdash semantic layer for this project. Compile is out of scope unless asked.',
|
|
50
28
|
`Project: ${projectUuid}.${topic}`,
|
|
51
|
-
|
|
29
|
+
playbooks_js_1.SEMANTIC_LAYER_HARD_BANS,
|
|
52
30
|
'Procedure:',
|
|
53
31
|
'1) Stick to this projectUuid (do not switch from an org-wide list_projects). Warehouse/dataset/table hints are search keys only.',
|
|
54
32
|
'2) Always lightdash_list_explores with search+limit; disambiguate per playbook (schemaName, label or name __{table}, skip empty schema when dataset known).',
|
|
55
33
|
'3) Shortlist base-table dimensions by role; once explore is known prefer get_explore → tables[baseTable].metrics only (catalog keyword optional, still filter tableName === explore id).',
|
|
56
34
|
'Deliverable: shortlist name/label/schemaName/fieldId (+ why). Do not dump full explore/dimension/metric/lineage payloads.',
|
|
57
|
-
`Follow the embedded
|
|
58
|
-
].join('\n'));
|
|
35
|
+
`Follow the embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_EXPLORE_URI}). Use only lightdash_* tools.`,
|
|
36
|
+
].join('\n'), 'explore');
|
|
59
37
|
});
|
|
60
38
|
server.registerPrompt('lightdash_semantic_compose_compile', {
|
|
61
39
|
title: 'Compose and compile query',
|
|
@@ -71,15 +49,15 @@ function registerSemanticLayerPrompts(server) {
|
|
|
71
49
|
return userMessages([
|
|
72
50
|
'Compose a Lightdash metric query and compile it with lightdash_compile_query. Do not run the query.',
|
|
73
51
|
`Project: ${projectUuid}.${topic}${explore}`,
|
|
74
|
-
|
|
52
|
+
playbooks_js_1.SEMANTIC_LAYER_HARD_BANS,
|
|
75
53
|
'Procedure:',
|
|
76
54
|
'1) If exploreId is missing, resolve it per playbook (search + disambiguation).',
|
|
77
55
|
'2) Use full fieldIds from list_dimensions / {exploreId}_{metricName}; prefer get_explore → tables[baseTable].metrics once explore is known.',
|
|
78
56
|
'3) If the user asked for N insights, reuse one explore and compile N diverse cuts from available fields.',
|
|
79
57
|
'4) Compile with fieldIds only; on empty SELECT or unknown field id, fix fieldIds and re-compile once. Extra related metrics in SQL can be OK. Stop after a good compile.',
|
|
80
58
|
'Deliverable: insight title(s) + fieldIds + compiled SQL (or errors). Never paste full explore/dimension/metric/lineage payloads.',
|
|
81
|
-
`Follow the embedded
|
|
82
|
-
].join('\n'));
|
|
59
|
+
`Follow the embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_COMPOSE_COMPILE_URI}).`,
|
|
60
|
+
].join('\n'), 'compose-compile');
|
|
83
61
|
});
|
|
84
62
|
server.registerPrompt('lightdash_semantic_compile_debug', {
|
|
85
63
|
title: 'Debug compile errors',
|
|
@@ -95,13 +73,13 @@ function registerSemanticLayerPrompts(server) {
|
|
|
95
73
|
'Debug a failing lightdash_compile_query call and re-compile until it succeeds or you explain blockers.',
|
|
96
74
|
`Project: ${projectUuid}`,
|
|
97
75
|
`Explore: ${exploreId}.${err}`,
|
|
98
|
-
|
|
76
|
+
playbooks_js_1.SEMANTIC_LAYER_HARD_BANS,
|
|
99
77
|
'Checklist:',
|
|
100
78
|
'- Empty SELECT or unknown field id → use fieldIds from lightdash_list_dimensions (base table).',
|
|
101
79
|
'- Wrong explore → re-disambiguate per playbook (schemaName; label or name __{table}).',
|
|
102
80
|
'- Metric not found / catalog empty → get_explore tables[baseTable].metrics; tableName must be the full explore id; compile as {exploreId}_{metricName}.',
|
|
103
81
|
'Deliverable: successful compile (SQL with expected columns) or a clear blocker. Stop after a good compile.',
|
|
104
|
-
`Follow the embedded
|
|
105
|
-
].join('\n'));
|
|
82
|
+
`Follow the embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_COMPOSE_COMPILE_URI}).`,
|
|
83
|
+
].join('\n'), 'compose-compile');
|
|
106
84
|
});
|
|
107
85
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Semantic-layer prompt/playbook invariants.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
8
|
+
const index_js_1 = require("./index.js");
|
|
9
|
+
(0, vitest_1.describe)('semantic-layer prompts/playbook', () => {
|
|
10
|
+
(0, vitest_1.it)('playbooks reference only registered tool short ids', () => {
|
|
11
|
+
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
12
|
+
for (const id of index_js_1.SEMANTIC_LAYER_TOOL_IDS) {
|
|
13
|
+
(0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
|
|
14
|
+
}
|
|
15
|
+
(0, vitest_1.expect)(md).not.toMatch(/\bldt__/);
|
|
16
|
+
(0, vitest_1.expect)(md.toLowerCase()).toContain('hard bans');
|
|
17
|
+
(0, vitest_1.expect)(playbooks_js_1.SEMANTIC_LAYER_HARD_BANS.toLowerCase()).toContain('sql');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Semantic-layer — compose & compile
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/semantic-layer/compose-compile`
|
|
4
|
+
|
|
5
|
+
## Multi-insight composition (“compose N queries”)
|
|
6
|
+
|
|
7
|
+
When the user asks for several insights on one table/explore:
|
|
8
|
+
|
|
9
|
+
1. Disambiguate explore once; reuse the same `exploreId` and metric shortlist.
|
|
10
|
+
2. Pick **diverse** cuts from available metrics/dims (don’t repeat the same grain N times)—e.g. trend, breakdown by a categorical dim, quality/rate metrics, outcome metrics, acquisition/source—only when those fields exist.
|
|
11
|
+
3. Compile each with `lightdash_compile_query`; verify SELECT columns; present **insight title + metric/dimension fieldIds + compiled SQL** (or errors). Do not paste full dimension/explore payloads.
|
|
12
|
+
4. Metrics that join other tables may produce large CTE SQL — still OK; mention the join briefly.
|
|
13
|
+
|
|
14
|
+
## Field IDs and empty SELECT
|
|
15
|
+
|
|
16
|
+
Prefer `fieldId` from `lightdash_list_dimensions` / `{exploreId}_{metricName}`.
|
|
17
|
+
|
|
18
|
+
Short names alone are unsafe:
|
|
19
|
+
|
|
20
|
+
1. Upstream may “succeed” with an **empty `SELECT`** — this server returns **`isError`**. Fix to `fieldId`s and re-compile once.
|
|
21
|
+
2. Or hard-error on unknown field id.
|
|
22
|
+
|
|
23
|
+
Compiled SQL may include **extra related metrics** the semantic layer pulls in — verify columns against the goal; unexpected helpers can be OK if the requested fields are present.
|
|
24
|
+
|
|
25
|
+
## metricQuery skeleton
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"exploreName": "{exploreId}",
|
|
30
|
+
"dimensions": ["{exploreId}_{dim}"],
|
|
31
|
+
"metrics": ["{exploreId}_{metric}"],
|
|
32
|
+
"filters": {},
|
|
33
|
+
"sorts": [{ "fieldId": "{exploreId}_{dim}", "descending": false }],
|
|
34
|
+
"limit": 50,
|
|
35
|
+
"tableCalculations": []
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`metrics` may be `[]`.
|
|
40
|
+
|
|
41
|
+
## Recommended sequence
|
|
42
|
+
|
|
43
|
+
1. Scope: `lightdash_get_project` with the user-given project UUID (do not switch from an org-wide list)
|
|
44
|
+
2. Discover: search explores → disambiguate → base-table dimensions (shortlist) + explore-local metrics (`get_explore` metrics map; catalog keyword optional)
|
|
45
|
+
3. `lightdash_compile_query` with `fieldId`s (repeat for multi-insight)
|
|
46
|
+
4. Verify SELECT columns; stop
|
|
47
|
+
|
|
48
|
+
## Compose / debug stop criteria
|
|
49
|
+
|
|
50
|
+
- Deliverable: insight title(s) + fieldIds + compiled SQL (or errors). Never paste full explore/dimension/metric/lineage payloads.
|
|
51
|
+
- Stop after a good compile. Re-compile only while debugging (empty SELECT / unknown field id / wrong explore / metric not found).
|
|
52
|
+
- Multi-insight: N titled queries with fieldIds + SQL; one explore resolution shared across them.
|
|
53
|
+
- Empty SELECT or unknown field id → use fieldIds from `lightdash_list_dimensions` (base table) and re-compile once.
|
|
54
|
+
- Wrong explore → re-disambiguate (schemaName; label or name `__{table}`).
|
|
55
|
+
- Metric not found / catalog empty → `get_explore` `tables[baseTable].metrics`; `tableName` must be the full explore id; compile as `{exploreId}_{metricName}`.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Semantic-layer core
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/semantic-layer/core`
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Discover the Lightdash semantic layer and **compose + compile** metric queries. Stop after a good compile (or clear compile errors). Do **not** run warehouse queries or mutate content.
|
|
8
|
+
|
|
9
|
+
## Allowed tools (always `lightdash_` prefix)
|
|
10
|
+
|
|
11
|
+
| Tool | Use for |
|
|
12
|
+
| --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `lightdash_list_projects` / `lightdash_get_project` | Confirm project UUID ↔ name via `{ data, warnings }` metadata (no warehouse/dbt credentials) |
|
|
14
|
+
| `lightdash_list_explores` | Summaries (`name`, `label`, `tags`, `databaseName`, `schemaName`, `errors?`); **always** pass `search` + `limit` |
|
|
15
|
+
| `lightdash_list_dimensions` | Compact `{ name, label, table, type, fieldId }`; **default = `table === explore.baseTable`** |
|
|
16
|
+
| `lightdash_list_metrics` / `lightdash_get_metric` | Catalog search; **always** filter `tableName === exploreId` client-side |
|
|
17
|
+
| `lightdash_compile_query` | Compile only — never “run” |
|
|
18
|
+
| `lightdash_get_explore` | Use when catalog filter yields **zero** explore-local metrics; extract `tables[baseTable].metrics` only |
|
|
19
|
+
| `lightdash_get_field_lineage` | Optional; summarize, don’t dump |
|
|
20
|
+
|
|
21
|
+
## Hard bans
|
|
22
|
+
|
|
23
|
+
Do **not** attempt or invent: run-query / SQL runner / validation jobs / charts / dashboards / spaces / users / groups / ACL / AI agents / agentops. Those tools are not on this server. Use Lightdash **compile** only (not warehouse execution).
|
|
24
|
+
|
|
25
|
+
## Project scope
|
|
26
|
+
|
|
27
|
+
1. If the user gave a **project UUID**, use it on every tool. Prefer `lightdash_get_project` to confirm the name.
|
|
28
|
+
2. Without an HTTP project pin, `lightdash_list_projects` may return the **entire org** — do **not** switch to another project from that list.
|
|
29
|
+
3. Lightdash **project UUID** ≠ warehouse cloud project. `list_projects` / `get_project` return metadata only (no `warehouseConnection` / `dbtConnection`). Match inventory project/dataset to explore **`databaseName`** / **`schemaName`** from `list_explores`.
|
|
30
|
+
|
|
31
|
+
## Answer shape
|
|
32
|
+
|
|
33
|
+
Shortlists only: explore `name` / `label` / `schemaName` / why chosen; metric/dimension names + `fieldId`; compiled SQL or compile errors. Never paste full `get_explore`, full dimension arrays, full `get_metric`, or full lineage JSON.
|
|
34
|
+
|
|
35
|
+
## Stop / deliverables
|
|
36
|
+
|
|
37
|
+
- **Explore prompt:** shortlist only — do not compile unless asked.
|
|
38
|
+
- **Compose / debug:** compiled SQL or errors; stop after a good compile (re-compile only while debugging).
|
|
39
|
+
- **Multi-insight:** N titled queries with fieldIds + SQL; one explore resolution shared across them.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Semantic-layer — explore / discover
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/semantic-layer/explore`
|
|
4
|
+
|
|
5
|
+
## From warehouse inventory → explore
|
|
6
|
+
|
|
7
|
+
When the user pastes warehouse inventory (dataset / table / partition field):
|
|
8
|
+
|
|
9
|
+
| Inventory hint | MCP use |
|
|
10
|
+
| ------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
11
|
+
| Dataset (`{dataset}`) | Prefer explores with matching **`schemaName`** |
|
|
12
|
+
| TABLE (`{table}`) | `lightdash_list_explores` **`search`** = that table token; prefer **exact `label` match** |
|
|
13
|
+
| Partition / time field | Candidate **dimension** `fieldId` for time-grain compiles |
|
|
14
|
+
| Full id `project.dataset.table` | `databaseName` ≈ project, `schemaName` ≈ dataset, `label` ≈ table |
|
|
15
|
+
|
|
16
|
+
Warehouse names are **search hints**, not explore IDs. Explore ids are usually compound (often `{project}__{dataset}__{table}`-style); use the explore `name` returned by tools.
|
|
17
|
+
|
|
18
|
+
Some inventory tables have **no** explore. Empty `list_explores` → say so; try a related curated/summary table the user cares about.
|
|
19
|
+
|
|
20
|
+
## Always search explores
|
|
21
|
+
|
|
22
|
+
On large projects, **never** use the default first-N explore list (alphabetical across unrelated domains). Always `search` + `limit`.
|
|
23
|
+
|
|
24
|
+
## Explore disambiguation
|
|
25
|
+
|
|
26
|
+
Search for `{table}` often returns siblings (staging / EDA / reporting variants, and the warehouse table). **Do not pick the first hit.**
|
|
27
|
+
|
|
28
|
+
1. Skip explores with non-empty `errors`.
|
|
29
|
+
2. If the user named a dataset, prefer matching **`schemaName`**. Skip rows with **empty** `schemaName` unless nothing else matches.
|
|
30
|
+
3. Match warehouse table via **exact `label`** = `{table}`, **or** explore **`name`** ending with / containing `__{table}` (labels may be humanized).
|
|
31
|
+
4. Prefer tags such as `lightdash` when still tied.
|
|
32
|
+
5. Deprioritize staging / EDA / reporting-style name prefixes unless the user asked for them.
|
|
33
|
+
6. Duplicate labels with version suffixes: prefer the explore **`name`** without an extra `_vN` unless the user asked for that version.
|
|
34
|
+
7. State chosen explore **`name`**, `label`, and `schemaName` in the answer.
|
|
35
|
+
|
|
36
|
+
## Progressive discovery
|
|
37
|
+
|
|
38
|
+
1. `lightdash_list_explores` with search → disambiguate → note explore id (`name`, `label`, `schemaName`).
|
|
39
|
+
2. `lightdash_list_dimensions` (default: `table === explore.baseTable`, which may differ from explore id) for `fieldId`s. Set `baseTableOnly=false` only if you need joined-table fields (payload grows a lot).
|
|
40
|
+
3. Discover metrics (see below). Prefer **explore-local** metrics on the base table over unrelated catalog hits.
|
|
41
|
+
4. Stop at a shortlist unless the user asked to compile (compose/compile topic).
|
|
42
|
+
|
|
43
|
+
## Metrics: catalog vs explore-local (critical)
|
|
44
|
+
|
|
45
|
+
`lightdash_list_metrics` searches the **org catalog**, not “metrics on this explore”.
|
|
46
|
+
|
|
47
|
+
| Search token | Typical result |
|
|
48
|
+
| ------------------------------ | --------------------------------------------------- |
|
|
49
|
+
| Warehouse table / explore id | **Often zero** hits |
|
|
50
|
+
| Broad domain / entity tokens | Hundreds of **other** tables — flood |
|
|
51
|
+
| Goal keyword from the question | May hit this explore **and** siblings — must filter |
|
|
52
|
+
|
|
53
|
+
Rules:
|
|
54
|
+
|
|
55
|
+
1. Once the explore is known, prefer **`lightdash_get_explore` → `tables[baseTable].metrics` only** for the full local menu (names + labels). Do **not** paste the full explore JSON. Ignore join tables under `tables`.
|
|
56
|
+
2. Optional: keyword `lightdash_list_metrics` for discovery. Response shape `{ pagination, data: Metric[] }`. Keep rows where `tableName` **equals the full explore id**. Table/explore-id search often returns **zero**.
|
|
57
|
+
3. `lightdash_get_metric` `tableName` must be the full explore id. Short warehouse labels → “Metric not found”. Summarize; do not paste huge `availableTimeDimensions` payloads.
|
|
58
|
+
4. Compile metric ids as `{exploreId}_{metricName}` (same pattern as dimension `fieldId`).
|
|
59
|
+
5. Dimension-only (`metrics: []`) is valid for volume-by-time; for “insights” prefer real explore metrics when available.
|
|
60
|
+
|
|
61
|
+
## Dimension shortlist (large explores)
|
|
62
|
+
|
|
63
|
+
Base tables can expose **hundreds** of dimensions (nested structs, event arrays). Do **not** dump the full list.
|
|
64
|
+
|
|
65
|
+
Prefer high-signal fields that appear in `list_dimensions`, by **role**:
|
|
66
|
+
|
|
67
|
+
- Time grains (day / week / month; prefer local timezone grains when both UTC and local exist)
|
|
68
|
+
- Channel / platform / traffic source
|
|
69
|
+
- Segment / demographic / cohort dimensions relevant to the question
|
|
70
|
+
- Core product or entity attributes named in the question
|
|
71
|
+
|
|
72
|
+
Skip nested event dumps and deep struct paths unless the question targets them.
|
|
73
|
+
|
|
74
|
+
## Field lineage
|
|
75
|
+
|
|
76
|
+
`lightdash_get_field_lineage` accepts full `fieldId` or short `name`. Summarize; do not paste the full graph.
|