@lightdash-tools/mcp 0.8.0 → 0.9.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 +108 -237
- package/dist/audit/server-persona.d.ts +10 -0
- package/dist/audit/server-persona.js +19 -0
- package/dist/auth/oauth-broker/pending-store.d.ts +6 -7
- package/dist/auth/oauth-broker/pending-store.js +3 -4
- package/dist/auth/oauth-broker/pending-store.test.d.ts +2 -3
- package/dist/auth/oauth-broker/pending-store.test.js +2 -39
- package/dist/auth/oauth-broker/routes.d.ts +1 -1
- package/dist/auth/oauth-broker/routes.js +3 -3
- package/dist/auth/oauth-broker/routes.test.js +1 -1
- package/dist/auth/request-state-key.d.ts +19 -0
- package/dist/auth/request-state-key.js +49 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +0 -2
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +0 -19
- package/dist/auth/resource-server/www-authenticate.test.js +0 -2
- package/dist/bin.js +9 -2
- package/dist/config/env.d.ts +5 -15
- package/dist/config/env.js +6 -16
- package/dist/config/load-mcp-config.d.ts +0 -4
- package/dist/config/load-mcp-config.js +8 -9
- package/dist/config/normalize-url.test.js +14 -11
- package/dist/config/runtime.d.ts +3 -3
- package/dist/config/runtime.js +19 -23
- package/dist/config/runtime.test.js +23 -9
- package/dist/config/test-mcp-http-config.js +1 -1
- package/dist/destructive/content-promote.js +7 -1
- package/dist/destructive/promote-contract.test.js +106 -47
- package/dist/destructive/register-destructive-tool.js +6 -24
- package/dist/destructive/request-state.d.ts +2 -6
- package/dist/destructive/request-state.js +3 -38
- package/dist/destructive/types.d.ts +2 -1
- package/dist/governance/available-projects.d.ts +37 -0
- package/dist/governance/available-projects.js +132 -0
- package/dist/governance/available-projects.test.d.ts +4 -0
- package/dist/governance/available-projects.test.js +107 -0
- package/dist/governance/client-capabilities-cache.d.ts +44 -0
- package/dist/governance/client-capabilities-cache.js +142 -0
- package/dist/governance/client-capabilities-cache.test.js +148 -0
- package/dist/governance/mcp-client-session.d.ts +3 -2
- package/dist/governance/mcp-client-session.js +3 -2
- package/dist/governance/project-scope.d.ts +8 -22
- package/dist/governance/project-scope.js +36 -44
- package/dist/governance/project-scope.test.d.ts +1 -1
- package/dist/governance/project-scope.test.js +21 -44
- package/dist/governance/promote-allowlist.d.ts +18 -0
- package/dist/governance/promote-allowlist.js +66 -0
- package/dist/governance/promote-allowlist.test.d.ts +4 -0
- package/dist/governance/promote-allowlist.test.js +87 -0
- package/dist/http.integration.test.js +117 -262
- package/dist/http.test.js +0 -12
- package/dist/index.integration.test.js +0 -4
- package/dist/index.js +3 -1
- package/dist/personas/ai-agent-ops/v1/index.d.ts +8 -0
- package/dist/personas/ai-agent-ops/v1/index.js +41 -0
- package/dist/personas/ai-agent-ops/v1/prompts.d.ts +5 -0
- package/dist/personas/ai-agent-ops/v1/prompts.js +141 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.d.ts +4 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.js +26 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/core.md +39 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/evaluation.md +25 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +28 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/release-gate.md +22 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-developer/v1/index.d.ts +1 -1
- package/dist/personas/content-developer/v1/index.js +1 -0
- package/dist/personas/content-developer/v1/prompts.d.ts +3 -0
- package/dist/personas/content-developer/v1/prompts.js +80 -61
- package/dist/personas/content-developer/v1/prompts.test.js +159 -3
- package/dist/personas/content-developer/v1/resources/playbooks/chart-types.md +123 -0
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +13 -6
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +91 -49
- package/dist/personas/content-developer/v1/resources/playbooks/dashboard-design.md +153 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +82 -34
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +9 -7
- package/dist/personas/content-developer/v1/resources/playbooks.d.ts +1 -1
- package/dist/personas/content-developer/v1/resources/playbooks.js +29 -10
- package/dist/personas/content-governance/v1/resources/playbooks/core.md +1 -1
- package/dist/personas/content-governance/v1/resources/playbooks/dashboards.md +1 -1
- package/dist/personas/content-reader/v1/index.d.ts +1 -1
- package/dist/personas/content-reader/v1/index.js +1 -0
- package/dist/personas/content-reader/v1/prompts.js +64 -30
- package/dist/personas/content-reader/v1/resources/playbooks/compare.md +24 -9
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +56 -29
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +27 -5
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +38 -8
- package/dist/personas/content-reader/v1/resources/playbooks/index.md +8 -8
- package/dist/personas/content-reader/v1/resources/playbooks.js +2 -2
- package/dist/personas/index.d.ts +1 -0
- package/dist/personas/index.js +27 -22
- package/dist/personas/index.test.js +68 -53
- package/dist/personas/lib/playbook-resources.d.ts +4 -3
- package/dist/personas/lib/playbook-resources.js +14 -10
- package/dist/personas/organization-audit/v1/prompts.js +68 -36
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +12 -4
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +13 -3
- package/dist/personas/organization-audit/v1/resources/playbooks/core.md +49 -16
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +8 -3
- package/dist/personas/organization-audit/v1/resources/playbooks/index.md +8 -8
- package/dist/personas/organization-audit/v1/resources/playbooks.js +1 -1
- package/dist/personas/persona.parity.test.js +14 -10
- package/dist/personas/semantic-layer/v1/prompts.js +50 -39
- package/dist/personas/semantic-layer/v1/resources/playbooks/compose-compile.md +36 -31
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +53 -21
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +42 -39
- package/dist/personas/semantic-layer/v1/resources/playbooks/index.md +6 -6
- package/dist/personas/semantic-layer/v1/resources/playbooks.js +2 -2
- package/dist/personas/types.d.ts +1 -1
- package/dist/policy/content-developer.d.ts +3 -3
- package/dist/policy/content-developer.js +3 -3
- package/dist/policy/content-developer.test.js +10 -4
- package/dist/policy/content-reader.d.ts +5 -1
- package/dist/policy/content-reader.js +18 -3
- package/dist/policy/content-reader.test.js +2 -1
- package/dist/policy/preview-ledger-fault.test.js +101 -426
- package/dist/policy/preview-ledger.d.ts +38 -74
- package/dist/policy/preview-ledger.js +108 -186
- package/dist/policy/preview-ledger.test.js +237 -111
- package/dist/policy/result-limits.d.ts +6 -1
- package/dist/policy/result-limits.js +28 -29
- package/dist/policy/result-limits.test.js +10 -1
- package/dist/server/capabilities.js +2 -0
- package/dist/server/capabilities.test.js +2 -0
- package/dist/server/server.js +12 -8
- package/dist/server/upstream-errors.d.ts +17 -0
- package/dist/server/upstream-errors.js +60 -0
- package/dist/server/upstream-errors.test.js +50 -0
- package/dist/stdio.process.test.js +4 -2
- package/dist/tools/ai-agents/agents.d.ts +7 -0
- package/dist/tools/ai-agents/agents.js +32 -0
- package/dist/tools/ai-agents/agents.test.js +176 -0
- package/dist/tools/ai-agents/discovery.d.ts +9 -0
- package/dist/tools/ai-agents/discovery.js +73 -0
- package/dist/tools/ai-agents/evaluations.d.ts +14 -0
- package/dist/tools/ai-agents/evaluations.js +177 -0
- package/dist/tools/ai-agents/helpers.d.ts +64 -0
- package/dist/tools/ai-agents/helpers.js +323 -0
- package/dist/tools/ai-agents/threads.d.ts +7 -0
- package/dist/tools/ai-agents/threads.js +40 -0
- package/dist/tools/organization/inventory.js +2 -1
- package/dist/tools/project/content.js +5 -1
- package/dist/tools/project/developer-content-preview.d.ts +2 -1
- package/dist/tools/project/developer-content-preview.js +40 -35
- package/dist/tools/project/developer-content-shared.d.ts +8 -2
- package/dist/tools/project/developer-content-shared.js +7 -3
- package/dist/tools/project/developer-content.d.ts +7 -8
- package/dist/tools/project/developer-content.js +72 -67
- package/dist/tools/project/developer-get-chart-as-code.d.ts +9 -0
- package/dist/tools/project/developer-get-chart-as-code.js +39 -0
- package/dist/tools/project/developer-get-chart-as-code.test.d.ts +4 -0
- package/dist/tools/project/developer-get-chart-as-code.test.js +70 -0
- package/dist/tools/project/developer-helpers.d.ts +1 -1
- package/dist/tools/project/developer-helpers.js +1 -1
- package/dist/tools/project/get-dashboard-promote-diff.js +12 -2
- package/dist/tools/project/invariants.test.js +5 -3
- package/dist/tools/project/projects.js +6 -4
- package/dist/tools/project/projects.test.js +44 -5
- package/dist/tools/project/reader-export-chart-image.d.ts +6 -0
- package/dist/tools/project/reader-export-chart-image.js +78 -0
- package/dist/tools/project/reader-export-chart-image.test.d.ts +4 -0
- package/dist/tools/project/reader-export-chart-image.test.js +149 -0
- package/dist/tools/query/bounded-saved-query.js +1 -1
- package/dist/tools/query/lifecycle.d.ts +1 -1
- package/dist/tools/query/lifecycle.js +17 -25
- package/dist/tools/query/query-ledger.d.ts +15 -8
- package/dist/tools/query/query-ledger.js +21 -15
- package/dist/tools/query/query-ledger.test.js +13 -11
- package/dist/tools/query/reader-tool-helpers.js +4 -6
- package/dist/tools/query/reader-tool-helpers.test.js +8 -4
- package/dist/tools/registry.d.ts +63 -0
- package/dist/tools/registry.js +26 -0
- package/dist/tools/shared.d.ts +27 -8
- package/dist/tools/shared.js +61 -28
- package/dist/tools/shared.test.js +100 -4
- package/dist/transports/streamable-http.js +48 -206
- package/dist/transports/streamable-http.test.js +10 -3
- package/package.json +5 -6
- package/dist/destructive/confirmation-claim.d.ts +0 -21
- package/dist/destructive/confirmation-claim.js +0 -87
- package/dist/destructive/confirmation-claim.test.js +0 -50
- package/dist/store/config.d.ts +0 -11
- package/dist/store/config.js +0 -50
- package/dist/store/config.test.js +0 -56
- package/dist/store/create-oauth-broker-store.d.ts +0 -6
- package/dist/store/create-oauth-broker-store.js +0 -16
- package/dist/store/create-preview-store.d.ts +0 -10
- package/dist/store/create-preview-store.js +0 -30
- package/dist/store/create-session-store.d.ts +0 -19
- package/dist/store/create-session-store.js +0 -24
- package/dist/store/in-memory-preview-store.d.ts +0 -17
- package/dist/store/in-memory-preview-store.js +0 -72
- package/dist/store/redis-client.d.ts +0 -11
- package/dist/store/redis-client.js +0 -48
- package/dist/store/redis-oauth-broker-store.d.ts +0 -42
- package/dist/store/redis-oauth-broker-store.js +0 -167
- package/dist/store/redis-oauth-broker-store.test.js +0 -80
- package/dist/store/redis-preview-store.d.ts +0 -23
- package/dist/store/redis-preview-store.js +0 -94
- package/dist/store/redis-preview-store.test.d.ts +0 -1
- package/dist/store/redis-preview-store.test.js +0 -39
- package/dist/store/redis-session-index.d.ts +0 -33
- package/dist/store/redis-session-index.js +0 -49
- package/dist/store/types.d.ts +0 -13
- package/dist/store/types.js +0 -8
- package/dist/transports/http-request-utils.d.ts +0 -2
- package/dist/transports/http-request-utils.js +0 -13
- package/dist/transports/session-store.d.ts +0 -72
- package/dist/transports/session-store.js +0 -143
- package/dist/transports/session-store.test.d.ts +0 -1
- package/dist/transports/session-store.test.js +0 -111
- /package/dist/{destructive/confirmation-claim.test.d.ts → governance/client-capabilities-cache.test.d.ts} +0 -0
- /package/dist/{store/config.test.d.ts → server/upstream-errors.test.d.ts} +0 -0
- /package/dist/{store/redis-oauth-broker-store.test.d.ts → tools/ai-agents/agents.test.d.ts} +0 -0
|
@@ -2,25 +2,29 @@
|
|
|
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 index_js_1 = require("./
|
|
6
|
-
const index_js_2 = require("./content-
|
|
7
|
-
const index_js_3 = require("./content-
|
|
8
|
-
const index_js_4 = require("./
|
|
9
|
-
const index_js_5 = require("./
|
|
5
|
+
const index_js_1 = require("./ai-agent-ops/v1/index.js");
|
|
6
|
+
const index_js_2 = require("./content-developer/v1/index.js");
|
|
7
|
+
const index_js_3 = require("./content-governance/v1/index.js");
|
|
8
|
+
const index_js_4 = require("./content-reader/v1/index.js");
|
|
9
|
+
const index_js_5 = require("./organization-audit/v1/index.js");
|
|
10
|
+
const index_js_6 = require("./semantic-layer/v1/index.js");
|
|
10
11
|
(0, vitest_1.describe)('persona catalog parity', () => {
|
|
12
|
+
(0, vitest_1.it)('ai-agent-ops allowlist matches catalog ai-agent-ops profile', () => {
|
|
13
|
+
(0, vitest_1.expect)([...index_js_1.AI_AGENT_OPS_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('ai-agent-ops')].sort());
|
|
14
|
+
});
|
|
11
15
|
(0, vitest_1.it)('semantic-layer allowlist matches catalog semantic-discovery profile', () => {
|
|
12
|
-
(0, vitest_1.expect)([...
|
|
16
|
+
(0, vitest_1.expect)([...index_js_6.SEMANTIC_LAYER_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('semantic-discovery')].sort());
|
|
13
17
|
});
|
|
14
18
|
(0, vitest_1.it)('organization-audit allowlist matches catalog org-audit-readonly profile', () => {
|
|
15
|
-
(0, vitest_1.expect)([...
|
|
19
|
+
(0, vitest_1.expect)([...index_js_5.ORGANIZATION_AUDIT_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('org-audit-readonly')].sort());
|
|
16
20
|
});
|
|
17
21
|
(0, vitest_1.it)('content-reader allowlist matches catalog content-reader profile', () => {
|
|
18
|
-
(0, vitest_1.expect)([...
|
|
22
|
+
(0, vitest_1.expect)([...index_js_4.CONTENT_READER_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('content-reader')].sort());
|
|
19
23
|
});
|
|
20
24
|
(0, vitest_1.it)('content-developer allowlist matches catalog content-developer profile', () => {
|
|
21
|
-
(0, vitest_1.expect)([...
|
|
25
|
+
(0, vitest_1.expect)([...index_js_2.CONTENT_DEVELOPER_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('content-developer')].sort());
|
|
22
26
|
});
|
|
23
27
|
(0, vitest_1.it)('content-governance allowlist matches catalog content-governance profile', () => {
|
|
24
|
-
(0, vitest_1.expect)([...
|
|
28
|
+
(0, vitest_1.expect)([...index_js_3.CONTENT_GOVERNANCE_TOOL_IDS].sort()).toEqual([...(0, common_1.listMcpToolNamesByProfile)('content-governance')].sort());
|
|
25
29
|
});
|
|
26
30
|
});
|
|
@@ -22,18 +22,22 @@ function registerSemanticLayerPrompts(server) {
|
|
|
22
22
|
question: zod_1.z.string().optional().describe('Natural-language question or topic'),
|
|
23
23
|
}),
|
|
24
24
|
}, async ({ projectUuid, question }) => {
|
|
25
|
-
const topic = question ? `
|
|
26
|
-
return userMessages(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
const topic = question ? `Question/topic: ${question}.` : '';
|
|
26
|
+
return userMessages(`Discover the Lightdash semantic layer for this project. Compile is out of scope unless asked.
|
|
27
|
+
|
|
28
|
+
Project UUID (required on every tool): ${projectUuid}.
|
|
29
|
+
${topic}
|
|
30
|
+
|
|
31
|
+
${playbooks_js_1.SEMANTIC_LAYER_HARD_BANS}
|
|
32
|
+
|
|
33
|
+
Procedure:
|
|
34
|
+
1. get_project once to confirm name. Do not switch projects from org-wide list_projects.
|
|
35
|
+
2. list_explores with search+limit (≤15). Disambiguate: skip empty schemaName / errors; prefer exact label or name __{table}; deprioritize eda_/reporting_ unless asked.
|
|
36
|
+
3. list_dimensions (base table) → shortlist ≤12 fieldIds by role (time/channel/segment/entity). Copy fieldIds literally.
|
|
37
|
+
4. get_explore → tables[baseTable].metrics only (≤8 names/labels). Skip list_metrics once explore is known. Skip get_metric / get_field_lineage unless needed.
|
|
38
|
+
5. Deliverable: chosen explore (name/label/schemaName/databaseName + why) + field shortlist. Never dump full explore/dimension/metric/lineage payloads.
|
|
39
|
+
|
|
40
|
+
Follow embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_EXPLORE_URI}). Use only lightdash_* tools.`, 'explore');
|
|
37
41
|
});
|
|
38
42
|
server.registerPrompt('lightdash_semantic_compose_compile', {
|
|
39
43
|
title: 'Compose and compile query',
|
|
@@ -44,20 +48,24 @@ function registerSemanticLayerPrompts(server) {
|
|
|
44
48
|
exploreId: (0, schema_fields_js_2.exploreIdField)().optional(),
|
|
45
49
|
}),
|
|
46
50
|
}, async ({ projectUuid, question, exploreId }) => {
|
|
47
|
-
const topic = question ? `
|
|
48
|
-
const explore = exploreId ? `
|
|
49
|
-
return userMessages(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
const topic = question ? `Goal: ${question}.` : '';
|
|
52
|
+
const explore = exploreId ? `Preferred explore: ${exploreId}.` : '';
|
|
53
|
+
return userMessages(`Compose a Lightdash metric query and compile it with lightdash_compile_query. Do not run the query.
|
|
54
|
+
|
|
55
|
+
Project UUID: ${projectUuid}.
|
|
56
|
+
${topic}
|
|
57
|
+
${explore}
|
|
58
|
+
|
|
59
|
+
${playbooks_js_1.SEMANTIC_LAYER_HARD_BANS}
|
|
60
|
+
|
|
61
|
+
Procedure:
|
|
62
|
+
1. If exploreId is missing, resolve it per explore playbook (search + disambiguation). Stay on this projectUuid.
|
|
63
|
+
2. Copy fieldIds from list_dimensions and {exploreId}_{metricName} from get_explore → tables[baseTable].metrics. Never invent grains.
|
|
64
|
+
3. If the user asked for N insights, reuse one explore and compile N diverse cuts.
|
|
65
|
+
4. compile_query with fieldIds only. After each compile, verify every requested fieldId appears as a SELECT alias (missing alias = failure even without isError). ≤2 fix retries.
|
|
66
|
+
5. Deliverable: insight title(s) + fieldIds + compiled SQL (or errors). Never paste full explore/dimension/metric/lineage payloads.
|
|
67
|
+
|
|
68
|
+
Follow embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_COMPOSE_COMPILE_URI}).`, 'compose-compile');
|
|
61
69
|
});
|
|
62
70
|
server.registerPrompt('lightdash_semantic_compile_debug', {
|
|
63
71
|
title: 'Debug compile errors',
|
|
@@ -68,18 +76,21 @@ function registerSemanticLayerPrompts(server) {
|
|
|
68
76
|
errorText: zod_1.z.string().optional().describe('Compile error text if already known'),
|
|
69
77
|
}),
|
|
70
78
|
}, async ({ projectUuid, exploreId, errorText }) => {
|
|
71
|
-
const err = errorText ? `
|
|
72
|
-
return userMessages(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
const err = errorText ? `Known error: ${errorText}` : '';
|
|
80
|
+
return userMessages(`Debug a failing lightdash_compile_query call and re-compile until it succeeds or you explain blockers.
|
|
81
|
+
|
|
82
|
+
Project UUID: ${projectUuid}
|
|
83
|
+
Explore: ${exploreId}
|
|
84
|
+
${err}
|
|
85
|
+
|
|
86
|
+
${playbooks_js_1.SEMANTIC_LAYER_HARD_BANS}
|
|
87
|
+
|
|
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).
|
|
90
|
+
- Wrong explore → re-disambiguate (schemaName; label or name __{table}; skip empty schema / eda unless asked).
|
|
91
|
+
- Metric not found / catalog empty → get_explore tables[baseTable].metrics; tableName must be the full explore id; compile as {exploreId}_{metricName}.
|
|
92
|
+
- Verify SELECT aliases after every compile. Stop after a good compile or a clear blocker.
|
|
93
|
+
|
|
94
|
+
Follow embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_COMPOSE_COMPILE_URI}).`, 'compose-compile');
|
|
84
95
|
});
|
|
85
96
|
}
|
|
@@ -2,25 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
URI: `lightdash://playbooks/semantic-layer/compose-compile`
|
|
4
4
|
|
|
5
|
-
##
|
|
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.
|
|
5
|
+
## Recommended sequence
|
|
22
6
|
|
|
23
|
-
|
|
7
|
+
1. Scope: `get_project` with the user-given project UUID (do not switch from org-wide `list_projects`).
|
|
8
|
+
2. Discover: search explores → disambiguate → `list_dimensions` shortlist + `get_explore` → `tables[baseTable].metrics`.
|
|
9
|
+
3. Build `metricQuery` using **only** copied `fieldId`s.
|
|
10
|
+
4. `compile_query` → **verify SELECT aliases** → stop (or ≤2 fix retries).
|
|
24
11
|
|
|
25
12
|
## metricQuery skeleton
|
|
26
13
|
|
|
@@ -36,20 +23,38 @@ Compiled SQL may include **extra related metrics** the semantic layer pulls in
|
|
|
36
23
|
}
|
|
37
24
|
```
|
|
38
25
|
|
|
39
|
-
`metrics` may be `[]`.
|
|
26
|
+
`metrics` may be `[]`. Every string in `dimensions` / `metrics` / `sorts[].fieldId` must appear in prior tool output.
|
|
40
27
|
|
|
41
|
-
##
|
|
28
|
+
## Field IDs — failure modes
|
|
29
|
+
|
|
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
|
+
| `Metric not found` on `get_metric` | `tableName` was warehouse label | Use full explore id |
|
|
36
|
+
|
|
37
|
+
Compiled SQL may include **extra related metrics** the semantic layer pulls in — OK if every **requested** fieldId still appears as a SELECT alias.
|
|
38
|
+
|
|
39
|
+
## Verify after every compile (mandatory)
|
|
42
40
|
|
|
43
|
-
1.
|
|
44
|
-
2.
|
|
45
|
-
3.
|
|
46
|
-
4.
|
|
41
|
+
1. Parse the compiled `query` SELECT list (aliases / AS names).
|
|
42
|
+
2. Confirm **each** requested dimension and metric `fieldId` is present.
|
|
43
|
+
3. If any are missing → treat as failure even when the tool did not set `isError`.
|
|
44
|
+
4. Confirm `ORDER BY` / sorts only reference fields that exist in the SELECT (or known group keys).
|
|
45
|
+
|
|
46
|
+
## Multi-insight composition
|
|
47
|
+
|
|
48
|
+
When the user asks for N insights on one table/explore:
|
|
49
|
+
|
|
50
|
+
1. Disambiguate explore **once**; reuse the same `exploreId` and metric shortlist.
|
|
51
|
+
2. Pick **diverse** cuts from available fields (trend, categorical breakdown, rate/quality, outcome, acquisition) — only when those fields exist. Don’t repeat the same grain N times.
|
|
52
|
+
3. Compile each; verify aliases; present **title + fieldIds + SQL** (or errors).
|
|
53
|
+
4. Metrics that join other tables may produce large CTE SQL — still OK; mention the join briefly.
|
|
47
54
|
|
|
48
|
-
##
|
|
55
|
+
## Debug checklist
|
|
49
56
|
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
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}`.
|
|
57
|
+
- Empty SELECT / unknown field id / missing alias → fix fieldIds from `list_dimensions` + explore-local metrics; re-compile (≤2 retries).
|
|
58
|
+
- Wrong explore → re-disambiguate (`schemaName`; exact `label` or `name` `__{table}`; skip empty schema / eda unless asked).
|
|
59
|
+
- Catalog empty / metric not found → `get_explore` `tables[baseTable].metrics`; compile as `{exploreId}_{metricName}`.
|
|
60
|
+
- Stop after a good verified compile or a clear blocker.
|
|
@@ -4,36 +4,68 @@ URI: `lightdash://playbooks/semantic-layer/core`
|
|
|
4
4
|
|
|
5
5
|
## Purpose
|
|
6
6
|
|
|
7
|
-
Discover the Lightdash semantic layer and **compose + compile** metric queries. Stop after a good compile (or clear
|
|
7
|
+
Discover the Lightdash semantic layer and **compose + compile** metric queries. Stop after a good compile (or a clear blocker). This server never runs warehouse queries or mutates content.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Hard bans
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 |
|
|
11
|
+
- Do **not** run / execute metric queries, SQL runner, charts, dashboards, or underlying data.
|
|
12
|
+
- Do **not** invent tools for validation jobs, spaces, users, groups, ACL, AI agents, or agentops — they are not on this server.
|
|
13
|
+
- Do **not** switch away from the user-given **Lightdash project UUID** after seeing `list_projects` (org-wide) or explore tags that mention other warehouses.
|
|
14
|
+
- Do **not** paste full `get_explore`, full dimension arrays, full `get_metric`, or full lineage JSON into the answer.
|
|
15
|
+
- Do **not** invent `fieldId`s or time-grain names — copy them from tool output only.
|
|
20
16
|
|
|
21
|
-
##
|
|
17
|
+
## Default budgets (override only if the user expands scope)
|
|
18
|
+
|
|
19
|
+
| Resource | Default |
|
|
20
|
+
| ----------------------------------- | ------------------------------------------------------------------------ |
|
|
21
|
+
| Explore search candidates inspected | **≤10** rows from `list_explores` (`search` + `limit≤15`) |
|
|
22
|
+
| Explores opened with `get_explore` | **1** chosen explore (retry only if wrong explore) |
|
|
23
|
+
| Dimension shortlist in the answer | **≤12** fieldIds |
|
|
24
|
+
| Metrics shortlisted / used | **≤8** (from `tables[baseTable].metrics`) |
|
|
25
|
+
| `list_metrics` catalog pages | **0** once explore is known; else **≤1** page (`pageSize≤20`) and filter |
|
|
26
|
+
| `get_metric` | **0** by default; **≤2** only when SQL/definition is required |
|
|
27
|
+
| `get_field_lineage` | **0** by default; **≤1** and summarize as “N upstream models” |
|
|
28
|
+
| Compile retries | **≤2** after the first attempt (fix fieldIds / explore, then stop) |
|
|
29
|
+
|
|
30
|
+
Record when a budget stopped you.
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
## Allowed tools (`lightdash_` prefix)
|
|
24
33
|
|
|
25
|
-
|
|
34
|
+
| Tool | Use for |
|
|
35
|
+
| ------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
36
|
+
| `list_projects` / `get_project` | Confirm UUID ↔ name. Credentials never returned (`REDACTED` warning is normal). |
|
|
37
|
+
| `list_explores` | Summaries only. **Always** pass `search` + `limit`. |
|
|
38
|
+
| `list_dimensions` | Compact `{ name, label, table, type, fieldId }`. Default = base table only. |
|
|
39
|
+
| `get_explore` | **Preferred** metric menu: `tables[baseTable].metrics` names/labels only. Ignore join tables. |
|
|
40
|
+
| `list_metrics` / `get_metric` | Optional catalog / definition dig. Filter `tableName === exploreId`. |
|
|
41
|
+
| `compile_query` | Compile only — never “run”. |
|
|
42
|
+
| `get_field_lineage` | Optional provenance; summarize, don’t dump. |
|
|
26
43
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
## Project scope (critical)
|
|
45
|
+
|
|
46
|
+
1. Every tool call uses the **user-given Lightdash `projectUuid`**. Prefer `get_project` once to confirm the name.
|
|
47
|
+
2. Without HTTP pin `X-Lightdash-Project`, `list_projects` may list the **entire org**. Do **not** switch projects because a sibling name looks related.
|
|
48
|
+
3. Lightdash **project UUID** ≠ BigQuery/GCP project. Explores carry `databaseName` / `schemaName` (warehouse). One Lightdash project often embeds explores whose `databaseName` points at another warehouse project — that is normal; stay on the given UUID.
|
|
49
|
+
4. Optional ceiling `LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS` may already filter `list_projects`; still pass the user’s UUID on tools.
|
|
30
50
|
|
|
31
51
|
## Answer shape
|
|
32
52
|
|
|
33
|
-
|
|
53
|
+
- Explore: `name` / `label` / `schemaName` / `databaseName` + why chosen.
|
|
54
|
+
- Fields: short names + **full `fieldId`** (+ role: time / channel / segment / metric).
|
|
55
|
+
- Compile: insight title(s) + fieldIds + compiled SQL (or errors). Verify every requested fieldId appears as a SELECT alias.
|
|
56
|
+
- Gaps: budget hits, empty explore search, compile blockers.
|
|
34
57
|
|
|
35
58
|
## Stop / deliverables
|
|
36
59
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
| Prompt | Stop when |
|
|
61
|
+
| --------------- | ----------------------------------------------------------------- |
|
|
62
|
+
| Explore | Shortlist delivered; **do not compile** unless asked |
|
|
63
|
+
| Compose / debug | Good compile (aliases verified) or clear blocker after ≤2 retries |
|
|
64
|
+
| Multi-insight | N titled compiles on **one** explore; shared discovery |
|
|
65
|
+
|
|
66
|
+
## Tool order (default)
|
|
67
|
+
|
|
68
|
+
1. `get_project` (confirm) → `list_explores` (`search`+`limit`) → disambiguate
|
|
69
|
+
2. `list_dimensions` (base table) → shortlist by role
|
|
70
|
+
3. `get_explore` → extract **only** `tables[baseTable].metrics` (names/labels)
|
|
71
|
+
4. `compile_query` with copied fieldIds → verify SELECT aliases → stop
|
|
@@ -2,75 +2,78 @@
|
|
|
2
2
|
|
|
3
3
|
URI: `lightdash://playbooks/semantic-layer/explore`
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Always search explores
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
On large projects, **never** rely on an unfiltered explore list (alphabetical noise across domains). Always call `lightdash_list_explores` with **`search` + `limit` (≤15)**.
|
|
8
8
|
|
|
9
|
-
|
|
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 |
|
|
9
|
+
Warehouse table / dataset names are **search hints**, not explore IDs. Explore `name` is usually compound (often `{warehouse}__{dataset}__{table}`-style).
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
## From warehouse inventory → explore
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
| Inventory hint | MCP use |
|
|
14
|
+
| ---------------------------- | ----------------------------------------------------------------- |
|
|
15
|
+
| Dataset | Prefer matching **`schemaName`** |
|
|
16
|
+
| TABLE | `search` = table token; prefer **exact `label`** = table |
|
|
17
|
+
| Partition / time field | Candidate dimension for time-grain compiles |
|
|
18
|
+
| Full `project.dataset.table` | `databaseName` ≈ project, `schemaName` ≈ dataset, `label` ≈ table |
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Some inventory tables have **no** explore. Empty or irrelevant search → say so; try a related curated/summary table the user cares about.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
## Explore disambiguation (do not pick the first hit)
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Search for `{table}` often returns siblings (staging / EDA / reporting variants, and the warehouse table). **Do not pick the first hit.**
|
|
24
|
+
Search for `{table}` often returns siblings: staging / EDA / reporting / MRE variants, empty-schema stubs, and the warehouse table.
|
|
27
25
|
|
|
28
26
|
1. Skip explores with non-empty `errors`.
|
|
29
|
-
2.
|
|
30
|
-
3.
|
|
31
|
-
4.
|
|
32
|
-
5.
|
|
33
|
-
6. Duplicate labels
|
|
34
|
-
7. State chosen explore **`name`**, `label`, and `
|
|
27
|
+
2. Skip rows with **empty `schemaName`** / empty tags / junk `name` (e.g. `_`) unless nothing else matches.
|
|
28
|
+
3. If the user named a dataset, prefer matching **`schemaName`**.
|
|
29
|
+
4. Match table via **exact `label`** = `{table}` **or** explore **`name`** containing `__{table}`.
|
|
30
|
+
5. Prefer tags such as `lightdash` when still tied; deprioritize `eda_` / `reporting_` / staging-style prefixes unless asked.
|
|
31
|
+
6. Duplicate labels / `_vN` suffixes: prefer the explore **`name`** without an extra version suffix unless the user asked for that version.
|
|
32
|
+
7. State chosen explore **`name`**, `label`, `schemaName`, and `databaseName` in the answer.
|
|
33
|
+
|
|
34
|
+
Remember: `databaseName` may differ from the Lightdash project’s usual warehouse — stay on the given `projectUuid`.
|
|
35
35
|
|
|
36
36
|
## Progressive discovery
|
|
37
37
|
|
|
38
|
-
1. `
|
|
39
|
-
2. `
|
|
40
|
-
3.
|
|
41
|
-
4. Stop at a shortlist unless the user asked to compile
|
|
38
|
+
1. `list_explores` → disambiguate → lock `exploreId` (= explore `name`).
|
|
39
|
+
2. `list_dimensions` (default `baseTableOnly=true`). Set `baseTableOnly=false` only if you need joined-table fields (payload grows a lot).
|
|
40
|
+
3. Metrics: **`get_explore` → `tables[baseTable].metrics` only** (see below). Do not dump the explore JSON.
|
|
41
|
+
4. Stop at a shortlist unless the user asked to compile.
|
|
42
42
|
|
|
43
43
|
## Metrics: catalog vs explore-local (critical)
|
|
44
44
|
|
|
45
|
-
`
|
|
45
|
+
`list_metrics` searches the **project catalog**, not “metrics on this explore”.
|
|
46
46
|
|
|
47
|
-
| Search token
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
47
|
+
| Search token | Typical result |
|
|
48
|
+
| -------------------------------------------- | --------------------------------------------------- |
|
|
49
|
+
| Full explore id | **Often zero** hits |
|
|
50
|
+
| Warehouse table label alone | **Often zero** |
|
|
51
|
+
| Broad domain tokens (`session`, `medico`, …) | Hundreds of **other** tables — flood |
|
|
52
|
+
| Goal keyword from the question | May hit this explore **and** siblings — must filter |
|
|
52
53
|
|
|
53
54
|
Rules:
|
|
54
55
|
|
|
55
|
-
1. Once the explore is known, prefer **`
|
|
56
|
-
2. Optional:
|
|
57
|
-
3. `
|
|
58
|
-
4. Compile metric ids as `{exploreId}_{metricName}` (same pattern as dimension `fieldId`).
|
|
56
|
+
1. Once the explore is known, prefer **`get_explore` → `tables[baseTable].metrics`** for the local menu (names + labels only). Ignore other keys under `tables` (joins).
|
|
57
|
+
2. Optional catalog: at most **one** `list_metrics` page. Keep rows where `tableName` **equals the full explore id**.
|
|
58
|
+
3. `get_metric` `tableName` must be the full explore id. Short labels → “Metric not found”. Call only when definition/SQL is needed; summarize — payloads include huge `availableTimeDimensions` from joins.
|
|
59
|
+
4. Compile metric ids as `{exploreId}_{metricName}` (same pattern as dimension `fieldId` from `list_dimensions`).
|
|
59
60
|
5. Dimension-only (`metrics: []`) is valid for volume-by-time; for “insights” prefer real explore metrics when available.
|
|
60
61
|
|
|
61
62
|
## Dimension shortlist (large explores)
|
|
62
63
|
|
|
63
|
-
Base tables can expose **hundreds** of dimensions
|
|
64
|
+
Base tables can expose **hundreds** of dimensions; many are nested (`a.b.c` paths / event arrays). Do **not** dump the list.
|
|
64
65
|
|
|
65
|
-
Prefer high-signal fields that appear in `list_dimensions
|
|
66
|
+
Prefer high-signal fields that **appear in `list_dimensions`**, by **role**:
|
|
66
67
|
|
|
67
|
-
- Time grains (day / week / month; prefer local timezone grains when both UTC and local exist)
|
|
68
|
+
- Time grains that exist as real `fieldId`s (day / week / month; prefer local timezone grains when both UTC and local exist — e.g. `*_jst_day`)
|
|
68
69
|
- Channel / platform / traffic source
|
|
69
70
|
- Segment / demographic / cohort dimensions relevant to the question
|
|
70
71
|
- Core product or entity attributes named in the question
|
|
71
72
|
|
|
72
73
|
Skip nested event dumps and deep struct paths unless the question targets them.
|
|
73
74
|
|
|
75
|
+
**Copy `fieldId` literally.** Do not invent grains like `{explore}_session_day` if that string is not in `list_dimensions`.
|
|
76
|
+
|
|
74
77
|
## Field lineage
|
|
75
78
|
|
|
76
|
-
`
|
|
79
|
+
`get_field_lineage` accepts full `fieldId` or short `name`. Default: skip. If used once, answer with a short summary (e.g. “upstream models: A → B → explore”) — never paste the graph.
|
|
@@ -4,10 +4,10 @@ URI: `lightdash://playbooks/semantic-layer`
|
|
|
4
4
|
|
|
5
5
|
Workflow-scoped playbooks (always load **core** plus one topic with a prompt):
|
|
6
6
|
|
|
7
|
-
| Topic
|
|
8
|
-
|
|
|
9
|
-
| Core (
|
|
10
|
-
| Explore / discover
|
|
11
|
-
| Compose & compile
|
|
7
|
+
| Topic | URI |
|
|
8
|
+
| --------------------------------- | ------------------------------------------------------ |
|
|
9
|
+
| Core (bans, budgets, scope, stop) | `lightdash://playbooks/semantic-layer/core` |
|
|
10
|
+
| Explore / discover | `lightdash://playbooks/semantic-layer/explore` |
|
|
11
|
+
| Compose & compile | `lightdash://playbooks/semantic-layer/compose-compile` |
|
|
12
12
|
|
|
13
|
-
Discover the Lightdash semantic layer and **compose + compile** metric queries. Stop after a
|
|
13
|
+
Discover the Lightdash semantic layer and **compose + compile** metric queries under default budgets. Stop after a verified compile (or clear compile errors). Do **not** run warehouse queries or mutate content.
|
|
@@ -10,8 +10,8 @@ const playbooks = (0, playbook_resources_js_1.definePersonaPlaybooks)({
|
|
|
10
10
|
personaId: 'semantic-layer',
|
|
11
11
|
moduleDir: __dirname,
|
|
12
12
|
/** Shared hard-ban text for prompts (keep in sync with playbooks/core.md Hard bans section). */
|
|
13
|
-
hardBans: 'Do not run metric/SQL/chart queries, use SQL runner, trigger validation jobs, mutate content, or call AI/identity tools. Those are not available on this server.',
|
|
14
|
-
coreDescription: 'Hard bans, allowed tools, project scope, and stop criteria',
|
|
13
|
+
hardBans: 'Do not run metric/SQL/chart queries, use SQL runner, trigger validation jobs, mutate content, switch away from the given projectUuid, invent fieldIds, dump full explore/metric/lineage payloads, or call AI/identity tools. Those are not available on this server.',
|
|
14
|
+
coreDescription: 'Hard bans, budgets, allowed tools, project scope, and stop criteria',
|
|
15
15
|
topics: [
|
|
16
16
|
{
|
|
17
17
|
id: 'explore',
|
package/dist/personas/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ToolId } from '../tools/registry.js';
|
|
5
5
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
|
-
export type PersonaId = 'content-developer' | 'content-governance' | 'content-reader' | 'organization-audit' | 'semantic-layer';
|
|
6
|
+
export type PersonaId = 'ai-agent-ops' | 'content-developer' | 'content-governance' | 'content-reader' | 'organization-audit' | 'semantic-layer';
|
|
7
7
|
export type PersonaDefinition = {
|
|
8
8
|
id: PersonaId;
|
|
9
9
|
/** Fixed Streamable HTTP MCP endpoint path for this persona. */
|
|
@@ -15,13 +15,13 @@ export type DeveloperOperationSafety = {
|
|
|
15
15
|
};
|
|
16
16
|
/** Discovery / passthrough reads (get_project, search_content, list_spaces, ...). */
|
|
17
17
|
export declare const DISCOVERY_SAFETY: DeveloperOperationSafety;
|
|
18
|
-
/** preview_* — computes a diff and issues a
|
|
18
|
+
/** preview_* — computes a diff and issues a HMAC-signed previewToken (ADR-0019), never persists. */
|
|
19
19
|
export declare const PREVIEW_SAFETY: DeveloperOperationSafety;
|
|
20
|
-
/** validate_* — optional saved-resource health check; never unlocks the preview
|
|
20
|
+
/** validate_* — optional saved-resource health check; never unlocks the preview. */
|
|
21
21
|
export declare const VALIDATE_SAFETY: DeveloperOperationSafety;
|
|
22
22
|
/** compare_*_versions — reads two historical versions and returns a diff, never persists. */
|
|
23
23
|
export declare const COMPARE_SAFETY: DeveloperOperationSafety;
|
|
24
|
-
/** SAFE_WRITE apply tools gated by a validated
|
|
24
|
+
/** SAFE_WRITE apply tools gated by a validated previewToken. */
|
|
25
25
|
export declare const WRITE_SAFETY: DeveloperOperationSafety;
|
|
26
26
|
/** Throws when a tool violates content-developer capability policy. */
|
|
27
27
|
export declare function assertContentDeveloperSafe(safety: DeveloperOperationSafety): void;
|
|
@@ -22,14 +22,14 @@ exports.DISCOVERY_SAFETY = {
|
|
|
22
22
|
resultCapability: 'metadata',
|
|
23
23
|
agentExposure: 'agent',
|
|
24
24
|
};
|
|
25
|
-
/** preview_* — computes a diff and issues a
|
|
25
|
+
/** preview_* — computes a diff and issues a HMAC-signed previewToken (ADR-0019), never persists. */
|
|
26
26
|
exports.PREVIEW_SAFETY = {
|
|
27
27
|
mutability: 'preview',
|
|
28
28
|
queryCapability: 'none',
|
|
29
29
|
resultCapability: 'diff',
|
|
30
30
|
agentExposure: 'agent',
|
|
31
31
|
};
|
|
32
|
-
/** validate_* — optional saved-resource health check; never unlocks the preview
|
|
32
|
+
/** validate_* — optional saved-resource health check; never unlocks the preview. */
|
|
33
33
|
exports.VALIDATE_SAFETY = {
|
|
34
34
|
mutability: 'none',
|
|
35
35
|
queryCapability: 'none',
|
|
@@ -43,7 +43,7 @@ exports.COMPARE_SAFETY = {
|
|
|
43
43
|
resultCapability: 'diff',
|
|
44
44
|
agentExposure: 'agent',
|
|
45
45
|
};
|
|
46
|
-
/** SAFE_WRITE apply tools gated by a validated
|
|
46
|
+
/** SAFE_WRITE apply tools gated by a validated previewToken. */
|
|
47
47
|
exports.WRITE_SAFETY = {
|
|
48
48
|
mutability: MUTABILITY_WRITE_NONDESTRUCTIVE,
|
|
49
49
|
queryCapability: 'none',
|
|
@@ -31,16 +31,22 @@ const preview_ledger_js_1 = require("./preview-ledger.js");
|
|
|
31
31
|
});
|
|
32
32
|
(0, vitest_1.describe)('developerErrorResult', () => {
|
|
33
33
|
(0, vitest_1.it)('maps ProjectScopeError to a coded blocked result', () => {
|
|
34
|
-
var _a;
|
|
35
34
|
const result = (0, content_developer_js_1.developerErrorResult)(new project_scope_js_1.ProjectScopeError('PROJECT_SCOPE_REQUIRED', 'no project'));
|
|
36
35
|
(0, vitest_1.expect)(result.isError).toBe(true);
|
|
37
|
-
|
|
36
|
+
const first = result.content[0];
|
|
37
|
+
(0, vitest_1.expect)(first === null || first === void 0 ? void 0 : first.type).toBe('text');
|
|
38
|
+
if ((first === null || first === void 0 ? void 0 : first.type) === 'text') {
|
|
39
|
+
(0, vitest_1.expect)(first.text).toContain('PROJECT_SCOPE_REQUIRED');
|
|
40
|
+
}
|
|
38
41
|
});
|
|
39
42
|
(0, vitest_1.it)('maps PreviewLedgerError to a coded blocked result', () => {
|
|
40
|
-
var _a;
|
|
41
43
|
const result = (0, content_developer_js_1.developerErrorResult)(new preview_ledger_js_1.PreviewLedgerError('PREVIEW_STALE', 'stale preview'));
|
|
42
44
|
(0, vitest_1.expect)(result.isError).toBe(true);
|
|
43
|
-
|
|
45
|
+
const first = result.content[0];
|
|
46
|
+
(0, vitest_1.expect)(first === null || first === void 0 ? void 0 : first.type).toBe('text');
|
|
47
|
+
if ((first === null || first === void 0 ? void 0 : first.type) === 'text') {
|
|
48
|
+
(0, vitest_1.expect)(first.text).toContain('PREVIEW_STALE');
|
|
49
|
+
}
|
|
44
50
|
});
|
|
45
51
|
(0, vitest_1.it)('rethrows unrelated errors', () => {
|
|
46
52
|
(0, vitest_1.expect)(() => (0, content_developer_js_1.developerErrorResult)(new Error('boom'))).toThrow('boom');
|
|
@@ -7,14 +7,18 @@ import type { McpServer } from '@modelcontextprotocol/server';
|
|
|
7
7
|
export type ReaderOperationSafety = {
|
|
8
8
|
mutability: 'none' | 'transient';
|
|
9
9
|
queryCapability: 'arbitrary_semantic' | 'none' | 'raw_sql' | 'saved_content' | 'underlying_data';
|
|
10
|
-
resultCapability: 'bounded_aggregate_rows' | 'bulk_export' | 'metadata' | 'row_level';
|
|
10
|
+
resultCapability: 'bounded_aggregate_rows' | 'bulk_export' | 'image_snapshot' | 'metadata' | 'row_level';
|
|
11
11
|
usesWarehouse: boolean;
|
|
12
12
|
agentExposure: 'agent' | 'client-only';
|
|
13
13
|
};
|
|
14
14
|
/** Computational read-only (warehouse run) but not idempotent — run/cancel/poll. */
|
|
15
15
|
export declare const SAVED_EXECUTION_ANNOTATIONS: ToolAnnotations;
|
|
16
|
+
/** Headless PNG export — read-only but not idempotent (expensive render). */
|
|
17
|
+
export declare const IMAGE_SNAPSHOT_ANNOTATIONS: ToolAnnotations;
|
|
16
18
|
export declare const METADATA_SAFETY: ReaderOperationSafety;
|
|
17
19
|
export declare const SAVED_EXECUTION_SAFETY: ReaderOperationSafety;
|
|
20
|
+
/** Single saved-chart PNG snapshot via headless export (ADR-0012 carve-out). */
|
|
21
|
+
export declare const IMAGE_SNAPSHOT_SAFETY: ReaderOperationSafety;
|
|
18
22
|
/** Throws when a tool violates content-reader capability policy. */
|
|
19
23
|
export declare function assertContentReaderSafe(safety: ReaderOperationSafety): void;
|
|
20
24
|
/** Register a content-reader tool after safety asserts. */
|