@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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Content-reader 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)('content-reader prompts/playbook', () => {
|
|
10
|
+
(0, vitest_1.it)('playbook references only registered tool short ids', () => {
|
|
11
|
+
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
12
|
+
for (const id of index_js_1.CONTENT_READER_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.CONTENT_READER_HARD_BANS.toLowerCase()).toContain('sql');
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.it)('playbook forbids mutation and arbitrary queries', () => {
|
|
20
|
+
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)().toLowerCase();
|
|
21
|
+
(0, vitest_1.expect)(md).toContain('do not mutate');
|
|
22
|
+
(0, vitest_1.expect)(md).toContain('underlying-data');
|
|
23
|
+
(0, vitest_1.expect)(md).toContain('sql charts');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Content-reader — compare / investigate
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/content-reader/compare`
|
|
4
|
+
|
|
5
|
+
Focus phases 3–6 on **diffs** between saved content definitions and (optionally) values.
|
|
6
|
+
|
|
7
|
+
## Phase 3 — Inspect both sides
|
|
8
|
+
|
|
9
|
+
Retrieve metadata first (`get_chart`, `get_dashboard`, `explain_content`, parameter tools). Compare definitions, dimensions, filters, time grains, parameters, verification, and update state before values.
|
|
10
|
+
|
|
11
|
+
## Phase 4 — Decide whether values help
|
|
12
|
+
|
|
13
|
+
Execute only when structurally comparable or when differences are the subject of analysis. Do not assume matching labels mean matching definitions.
|
|
14
|
+
|
|
15
|
+
## Phase 5 — Execute with equivalent context
|
|
16
|
+
|
|
17
|
+
When needed, run with equivalent valid filters/parameters/context (`run_chart` / `run_dashboard_tile`). Check metrics, fields, filters, dashboard context, date ranges, time grains, parameters, sorts, limits, pivots, table calculations, verification, cache timestamps, and semantic-versus-SQL behavior.
|
|
18
|
+
|
|
19
|
+
## Phase 6 — Report causes
|
|
20
|
+
|
|
21
|
+
Separate confirmed, plausible, ruled-out, and unresolved causes. Cite content UUIDs, query UUIDs, truncation, and caveats.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Content-reader core
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/content-reader/core`
|
|
4
|
+
|
|
5
|
+
## Hard bans
|
|
6
|
+
|
|
7
|
+
- Do not mutate Lightdash resources.
|
|
8
|
+
- Do not execute arbitrary metric queries, raw SQL, or underlying-data queries.
|
|
9
|
+
- Do not download or bulk-export results.
|
|
10
|
+
- Do not execute saved SQL charts (disabled by default).
|
|
11
|
+
- Do not override filter targets, operators, required-filter behavior, fields, metrics, dimensions, SQL, table calculations, or sorts.
|
|
12
|
+
- Do not execute content outside the resolved project.
|
|
13
|
+
- Do not present truncated results as complete.
|
|
14
|
+
- Do not claim metric equivalence from matching labels alone.
|
|
15
|
+
- Do not reveal secrets, warehouse credentials, hidden SQL, or inaccessible content.
|
|
16
|
+
|
|
17
|
+
## Tools
|
|
18
|
+
|
|
19
|
+
Use only these `lightdash_*` tools:
|
|
20
|
+
|
|
21
|
+
- `get_project`
|
|
22
|
+
- `search_content`
|
|
23
|
+
- `list_spaces`
|
|
24
|
+
- `get_space`
|
|
25
|
+
- `get_dashboard`
|
|
26
|
+
- `get_chart`
|
|
27
|
+
- `list_project_parameters`
|
|
28
|
+
- `get_project_parameters`
|
|
29
|
+
- `explain_content`
|
|
30
|
+
- `run_chart`
|
|
31
|
+
- `run_dashboard_tile`
|
|
32
|
+
- `get_query_result`
|
|
33
|
+
- `cancel_query`
|
|
34
|
+
|
|
35
|
+
## Phase 0 — Resolve project
|
|
36
|
+
|
|
37
|
+
1. Call `lightdash_get_project` (pin / `LIGHTDASH_TOOLS_PROJECT_UUID` / explicit UUID).
|
|
38
|
+
2. Record project UUID, pin, and `readerCapabilities`.
|
|
39
|
+
3. Stop when project scope is unresolved (`PROJECT_SCOPE_REQUIRED`).
|
|
40
|
+
4. Never enumerate organization projects.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Content-reader — discover
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/content-reader/discover`
|
|
4
|
+
|
|
5
|
+
## Phase 1 — Classify intent
|
|
6
|
+
|
|
7
|
+
Classify as find / explain / retrieve value / summarize dashboard / compare / investigate.
|
|
8
|
+
|
|
9
|
+
## Phase 2 — Discover
|
|
10
|
+
|
|
11
|
+
Use `search_content`, `list_spaces`, `get_space`. Prefer verified content when equally relevant.
|
|
12
|
+
|
|
13
|
+
Return at most five candidates with name/type, UUID, space path, verification, relevance, and warnings. Do not execute content unless values or analysis are requested.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Content-reader — explain & run
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/content-reader/explain-run`
|
|
4
|
+
|
|
5
|
+
## Phase 3 — Inspect metadata
|
|
6
|
+
|
|
7
|
+
Use `get_dashboard`, `get_chart`, parameter tools, `explain_content`. Do not invent unsupported business semantics. Distinguish explicit metadata from inferred business meaning.
|
|
8
|
+
|
|
9
|
+
## Phase 4 — Decide on execution
|
|
10
|
+
|
|
11
|
+
Execute only for values, trends, rankings, summaries, comparisons, or discrepancy validation. Skip execution for discovery/description.
|
|
12
|
+
|
|
13
|
+
## Phase 5 — Execute bounded saved content
|
|
14
|
+
|
|
15
|
+
Use `run_chart` / `run_dashboard_tile` with cache-first defaults, limit 100, values-only overrides. SQL charts return `CONTENT_NOT_EXECUTABLE`. Record query UUID; cancel unnecessary queries via `cancel_query`.
|
|
16
|
+
|
|
17
|
+
## Phase 6 — Interpret and report
|
|
18
|
+
|
|
19
|
+
Report answer, evidence, content UUIDs, filters/parameters, cache/time context, truncation, and caveats. Cite chart/dashboard UUID and query UUID. Do not construct a new query or retrieve underlying data. Do not claim unexecuted tiles support a conclusion.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Content-reader playbooks
|
|
2
|
+
|
|
3
|
+
URI: `lightdash://playbooks/content-reader`
|
|
4
|
+
|
|
5
|
+
Workflow-scoped playbooks (always load **core** plus one topic with a prompt):
|
|
6
|
+
|
|
7
|
+
| Topic | URI |
|
|
8
|
+
| --------------------- | -------------------------------------------------- |
|
|
9
|
+
| Core (gates & bans) | `lightdash://playbooks/content-reader/core` |
|
|
10
|
+
| Discover | `lightdash://playbooks/content-reader/discover` |
|
|
11
|
+
| Explain & run | `lightdash://playbooks/content-reader/explain-run` |
|
|
12
|
+
| Compare / investigate | `lightdash://playbooks/content-reader/compare` |
|
|
13
|
+
|
|
14
|
+
Discover, explain, and execute saved Lightdash charts and dashboards safely within a resolved project.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-reader multi-playbook resources (core + topics + index).
|
|
3
|
+
*/
|
|
4
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
5
|
+
export type ContentReaderPlaybookTopic = 'compare' | 'discover' | 'explain-run';
|
|
6
|
+
export declare const CONTENT_READER_HARD_BANS: string;
|
|
7
|
+
export declare const getAllPlaybookMarkdown: () => string;
|
|
8
|
+
export declare const CONTENT_READER_CORE_PLAYBOOK: import("../../../lib/playbook-resources.js").EmbeddedPlaybook;
|
|
9
|
+
export declare const CONTENT_READER_TOPIC_PLAYBOOKS: Readonly<Record<ContentReaderPlaybookTopic, import("../../../lib/playbook-resources.js").EmbeddedPlaybook>>;
|
|
10
|
+
export declare function registerContentReaderPlaybook(server: McpServer): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Content-reader multi-playbook resources (core + topics + index).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CONTENT_READER_TOPIC_PLAYBOOKS = exports.CONTENT_READER_CORE_PLAYBOOK = exports.getAllPlaybookMarkdown = exports.CONTENT_READER_HARD_BANS = void 0;
|
|
7
|
+
exports.registerContentReaderPlaybook = registerContentReaderPlaybook;
|
|
8
|
+
const playbook_resources_js_1 = require("../../../lib/playbook-resources.js");
|
|
9
|
+
const playbooks = (0, playbook_resources_js_1.definePersonaPlaybooks)({
|
|
10
|
+
personaId: 'content-reader',
|
|
11
|
+
moduleDir: __dirname,
|
|
12
|
+
hardBans: `Do not mutate Lightdash resources.
|
|
13
|
+
Do not execute arbitrary metric queries, raw SQL, or underlying-data queries.
|
|
14
|
+
Do not download or bulk-export results.
|
|
15
|
+
Do not execute saved SQL charts (disabled by default on content-reader).
|
|
16
|
+
Do not override filter targets, operators, required-filter behavior, fields, metrics, dimensions, SQL, table calculations, or sorts.
|
|
17
|
+
Do not execute content outside the resolved project.
|
|
18
|
+
Do not present truncated results as complete.
|
|
19
|
+
Do not claim metric equivalence from matching labels alone.
|
|
20
|
+
Do not reveal secrets, warehouse credentials, hidden SQL, or inaccessible content.`,
|
|
21
|
+
coreDescription: 'Hard bans, tools, and project scope',
|
|
22
|
+
topics: [
|
|
23
|
+
{
|
|
24
|
+
id: 'discover',
|
|
25
|
+
title: 'Content-reader discover playbook',
|
|
26
|
+
description: 'Intent classification and content discovery',
|
|
27
|
+
file: 'discover.md',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'explain-run',
|
|
31
|
+
title: 'Content-reader explain/run playbook',
|
|
32
|
+
description: 'Inspect metadata and execute bounded saved content',
|
|
33
|
+
file: 'explain-run.md',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'compare',
|
|
37
|
+
title: 'Content-reader compare playbook',
|
|
38
|
+
description: 'Compare and investigate differences between saved content',
|
|
39
|
+
file: 'compare.md',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
exports.CONTENT_READER_HARD_BANS = playbooks.HARD_BANS;
|
|
44
|
+
exports.getAllPlaybookMarkdown = playbooks.getAllPlaybookMarkdown;
|
|
45
|
+
exports.CONTENT_READER_CORE_PLAYBOOK = playbooks.CORE_PLAYBOOK;
|
|
46
|
+
exports.CONTENT_READER_TOPIC_PLAYBOOKS = playbooks.TOPIC_PLAYBOOKS;
|
|
47
|
+
function registerContentReaderPlaybook(server) {
|
|
48
|
+
playbooks.registerPlaybooks(server);
|
|
49
|
+
}
|
package/dist/personas/index.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ import type { PersonaDefinition, PersonaId } from './types.js';
|
|
|
5
5
|
export type { PersonaDefinition, PersonaId } from './types.js';
|
|
6
6
|
export { SEMANTIC_LAYER_PERSONA_PATH } from './semantic-layer/v1/index.js';
|
|
7
7
|
export { ORGANIZATION_AUDIT_PERSONA_PATH } from './organization-audit/v1/index.js';
|
|
8
|
+
export { CONTENT_READER_PERSONA_PATH } from './content-reader/v1/index.js';
|
|
9
|
+
export { CONTENT_DEVELOPER_PERSONA_PATH } from './content-developer/v1/index.js';
|
|
10
|
+
export { CONTENT_GOVERNANCE_PERSONA_PATH } from './content-governance/v1/index.js';
|
|
8
11
|
/** Default stdio persona (backward compatible). */
|
|
9
12
|
export declare const DEFAULT_PERSONA_ID: PersonaId;
|
|
10
13
|
export declare const PERSONAS: Record<PersonaId, PersonaDefinition>;
|
package/dist/personas/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Shipped MCP personas (path → definition). No PERSONA/PATH env knobs.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PERSONAS = exports.DEFAULT_PERSONA_ID = exports.ORGANIZATION_AUDIT_PERSONA_PATH = exports.SEMANTIC_LAYER_PERSONA_PATH = void 0;
|
|
6
|
+
exports.PERSONAS = exports.DEFAULT_PERSONA_ID = exports.CONTENT_GOVERNANCE_PERSONA_PATH = exports.CONTENT_DEVELOPER_PERSONA_PATH = exports.CONTENT_READER_PERSONA_PATH = exports.ORGANIZATION_AUDIT_PERSONA_PATH = exports.SEMANTIC_LAYER_PERSONA_PATH = void 0;
|
|
7
7
|
exports.getPersona = getPersona;
|
|
8
8
|
exports.getDefaultPersona = getDefaultPersona;
|
|
9
9
|
exports.getPersonaByPath = getPersonaByPath;
|
|
@@ -11,17 +11,29 @@ exports.listPersonaPaths = listPersonaPaths;
|
|
|
11
11
|
exports.parsePersonaId = parsePersonaId;
|
|
12
12
|
exports.getPersonaServerName = getPersonaServerName;
|
|
13
13
|
const normalize_url_js_1 = require("../config/normalize-url.js");
|
|
14
|
-
const index_js_1 = require("./
|
|
15
|
-
const index_js_2 = require("./
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const index_js_1 = require("./content-developer/v1/index.js");
|
|
15
|
+
const index_js_2 = require("./content-governance/v1/index.js");
|
|
16
|
+
const index_js_3 = require("./content-reader/v1/index.js");
|
|
17
|
+
const index_js_4 = require("./organization-audit/v1/index.js");
|
|
18
|
+
const index_js_5 = require("./semantic-layer/v1/index.js");
|
|
19
|
+
var index_js_6 = require("./semantic-layer/v1/index.js");
|
|
20
|
+
Object.defineProperty(exports, "SEMANTIC_LAYER_PERSONA_PATH", { enumerable: true, get: function () { return index_js_6.SEMANTIC_LAYER_PERSONA_PATH; } });
|
|
21
|
+
var index_js_7 = require("./organization-audit/v1/index.js");
|
|
22
|
+
Object.defineProperty(exports, "ORGANIZATION_AUDIT_PERSONA_PATH", { enumerable: true, get: function () { return index_js_7.ORGANIZATION_AUDIT_PERSONA_PATH; } });
|
|
23
|
+
var index_js_8 = require("./content-reader/v1/index.js");
|
|
24
|
+
Object.defineProperty(exports, "CONTENT_READER_PERSONA_PATH", { enumerable: true, get: function () { return index_js_8.CONTENT_READER_PERSONA_PATH; } });
|
|
25
|
+
var index_js_9 = require("./content-developer/v1/index.js");
|
|
26
|
+
Object.defineProperty(exports, "CONTENT_DEVELOPER_PERSONA_PATH", { enumerable: true, get: function () { return index_js_9.CONTENT_DEVELOPER_PERSONA_PATH; } });
|
|
27
|
+
var index_js_10 = require("./content-governance/v1/index.js");
|
|
28
|
+
Object.defineProperty(exports, "CONTENT_GOVERNANCE_PERSONA_PATH", { enumerable: true, get: function () { return index_js_10.CONTENT_GOVERNANCE_PERSONA_PATH; } });
|
|
20
29
|
/** Default stdio persona (backward compatible). */
|
|
21
30
|
exports.DEFAULT_PERSONA_ID = 'semantic-layer';
|
|
22
31
|
exports.PERSONAS = {
|
|
23
|
-
'semantic-layer':
|
|
24
|
-
'organization-audit':
|
|
32
|
+
'semantic-layer': index_js_5.semanticLayerPersona,
|
|
33
|
+
'organization-audit': index_js_4.organizationAuditPersona,
|
|
34
|
+
'content-reader': index_js_3.contentReaderPersona,
|
|
35
|
+
'content-developer': index_js_1.contentDeveloperPersona,
|
|
36
|
+
'content-governance': index_js_2.contentGovernancePersona,
|
|
25
37
|
};
|
|
26
38
|
const PERSONAS_BY_PATH = new Map(Object.values(exports.PERSONAS).map((persona) => [persona.path, persona]));
|
|
27
39
|
function getPersona(id) {
|
|
@@ -45,7 +57,11 @@ function listPersonaPaths() {
|
|
|
45
57
|
}
|
|
46
58
|
/** Parse a CLI persona id; returns undefined when invalid. */
|
|
47
59
|
function parsePersonaId(value) {
|
|
48
|
-
if (value === 'semantic-layer' ||
|
|
60
|
+
if (value === 'semantic-layer' ||
|
|
61
|
+
value === 'organization-audit' ||
|
|
62
|
+
value === 'content-reader' ||
|
|
63
|
+
value === 'content-developer' ||
|
|
64
|
+
value === 'content-governance') {
|
|
49
65
|
return value;
|
|
50
66
|
}
|
|
51
67
|
return undefined;
|
|
@@ -3,46 +3,97 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const vitest_1 = require("vitest");
|
|
4
4
|
const registry_js_1 = require("../tools/registry.js");
|
|
5
5
|
const shared_js_1 = require("../tools/shared.js");
|
|
6
|
-
const index_js_1 = require("./
|
|
7
|
-
const index_js_2 = require("./index.js");
|
|
6
|
+
const index_js_1 = require("./content-developer/v1/index.js");
|
|
7
|
+
const index_js_2 = require("./content-governance/v1/index.js");
|
|
8
|
+
const index_js_3 = require("./content-reader/v1/index.js");
|
|
9
|
+
const index_js_4 = require("./organization-audit/v1/index.js");
|
|
10
|
+
const index_js_5 = require("./index.js");
|
|
8
11
|
(0, vitest_1.describe)('personas', () => {
|
|
9
|
-
(0, vitest_1.it)('ships
|
|
10
|
-
var _a, _b;
|
|
11
|
-
(0, vitest_1.expect)(Object.keys(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
(0, vitest_1.it)('ships five personas with fixed paths', () => {
|
|
13
|
+
var _a, _b, _c, _d, _e;
|
|
14
|
+
(0, vitest_1.expect)(Object.keys(index_js_5.PERSONAS).sort()).toEqual([
|
|
15
|
+
'content-developer',
|
|
16
|
+
'content-governance',
|
|
17
|
+
'content-reader',
|
|
18
|
+
'organization-audit',
|
|
19
|
+
'semantic-layer',
|
|
20
|
+
]);
|
|
21
|
+
(0, vitest_1.expect)(index_js_5.DEFAULT_PERSONA_ID).toBe('semantic-layer');
|
|
22
|
+
(0, vitest_1.expect)((0, index_js_5.listPersonaPaths)().sort()).toEqual([
|
|
23
|
+
index_js_5.CONTENT_DEVELOPER_PERSONA_PATH,
|
|
24
|
+
index_js_5.CONTENT_GOVERNANCE_PERSONA_PATH,
|
|
25
|
+
index_js_5.CONTENT_READER_PERSONA_PATH,
|
|
26
|
+
index_js_5.ORGANIZATION_AUDIT_PERSONA_PATH,
|
|
27
|
+
index_js_5.SEMANTIC_LAYER_PERSONA_PATH,
|
|
28
|
+
].sort());
|
|
29
|
+
(0, vitest_1.expect)((_a = (0, index_js_5.getPersonaByPath)(index_js_5.SEMANTIC_LAYER_PERSONA_PATH)) === null || _a === void 0 ? void 0 : _a.id).toBe('semantic-layer');
|
|
30
|
+
(0, vitest_1.expect)((_b = (0, index_js_5.getPersonaByPath)(index_js_5.ORGANIZATION_AUDIT_PERSONA_PATH)) === null || _b === void 0 ? void 0 : _b.id).toBe('organization-audit');
|
|
31
|
+
(0, vitest_1.expect)((_c = (0, index_js_5.getPersonaByPath)(index_js_5.CONTENT_READER_PERSONA_PATH)) === null || _c === void 0 ? void 0 : _c.id).toBe('content-reader');
|
|
32
|
+
(0, vitest_1.expect)((_d = (0, index_js_5.getPersonaByPath)(index_js_5.CONTENT_DEVELOPER_PERSONA_PATH)) === null || _d === void 0 ? void 0 : _d.id).toBe('content-developer');
|
|
33
|
+
(0, vitest_1.expect)((_e = (0, index_js_5.getPersonaByPath)(index_js_5.CONTENT_GOVERNANCE_PERSONA_PATH)) === null || _e === void 0 ? void 0 : _e.id).toBe('content-governance');
|
|
34
|
+
(0, vitest_1.expect)((0, index_js_5.getPersonaByPath)('/mcp')).toBeUndefined();
|
|
17
35
|
});
|
|
18
36
|
(0, vitest_1.it)('normalizes trailing slashes when resolving path', () => {
|
|
19
|
-
var _a, _b;
|
|
20
|
-
(0, vitest_1.expect)((_a = (0,
|
|
21
|
-
(0, vitest_1.expect)((_b = (0,
|
|
37
|
+
var _a, _b, _c, _d, _e;
|
|
38
|
+
(0, vitest_1.expect)((_a = (0, index_js_5.getPersonaByPath)(`${index_js_5.SEMANTIC_LAYER_PERSONA_PATH}/`)) === null || _a === void 0 ? void 0 : _a.id).toBe('semantic-layer');
|
|
39
|
+
(0, vitest_1.expect)((_b = (0, index_js_5.getPersonaByPath)(`${index_js_5.ORGANIZATION_AUDIT_PERSONA_PATH}/`)) === null || _b === void 0 ? void 0 : _b.id).toBe('organization-audit');
|
|
40
|
+
(0, vitest_1.expect)((_c = (0, index_js_5.getPersonaByPath)(`${index_js_5.CONTENT_READER_PERSONA_PATH}/`)) === null || _c === void 0 ? void 0 : _c.id).toBe('content-reader');
|
|
41
|
+
(0, vitest_1.expect)((_d = (0, index_js_5.getPersonaByPath)(`${index_js_5.CONTENT_DEVELOPER_PERSONA_PATH}/`)) === null || _d === void 0 ? void 0 : _d.id).toBe('content-developer');
|
|
42
|
+
(0, vitest_1.expect)((_e = (0, index_js_5.getPersonaByPath)(`${index_js_5.CONTENT_GOVERNANCE_PERSONA_PATH}/`)) === null || _e === void 0 ? void 0 : _e.id).toBe('content-governance');
|
|
22
43
|
});
|
|
23
44
|
(0, vitest_1.it)('semantic-layer allowlists exactly nine tools', () => {
|
|
24
|
-
const persona = (0,
|
|
45
|
+
const persona = (0, index_js_5.getPersona)('semantic-layer');
|
|
25
46
|
(0, vitest_1.expect)(persona.toolIds).toHaveLength(9);
|
|
26
|
-
(0, vitest_1.expect)((0,
|
|
47
|
+
(0, vitest_1.expect)((0, index_js_5.getDefaultPersona)().toolIds).toEqual(persona.toolIds);
|
|
27
48
|
});
|
|
28
49
|
(0, vitest_1.it)('organization-audit allowlists 18 tools and short server name', () => {
|
|
29
|
-
const persona = (0,
|
|
50
|
+
const persona = (0, index_js_5.getPersona)('organization-audit');
|
|
30
51
|
(0, vitest_1.expect)(persona.toolIds).toHaveLength(18);
|
|
31
|
-
(0, vitest_1.expect)(persona.toolIds).toEqual([...
|
|
32
|
-
(0, vitest_1.expect)((0,
|
|
52
|
+
(0, vitest_1.expect)(persona.toolIds).toEqual([...index_js_4.ORGANIZATION_AUDIT_TOOL_IDS]);
|
|
53
|
+
(0, vitest_1.expect)((0, index_js_5.getPersonaServerName)(persona)).toBe('lightdash-mcp-org-audit');
|
|
54
|
+
});
|
|
55
|
+
(0, vitest_1.it)('content-reader allowlists 13 tools and server name', () => {
|
|
56
|
+
const persona = (0, index_js_5.getPersona)('content-reader');
|
|
57
|
+
(0, vitest_1.expect)(persona.toolIds).toHaveLength(13);
|
|
58
|
+
(0, vitest_1.expect)(persona.toolIds).toEqual([...index_js_3.CONTENT_READER_TOOL_IDS]);
|
|
59
|
+
(0, vitest_1.expect)((0, index_js_5.getPersonaServerName)(persona)).toBe('lightdash-mcp-content');
|
|
60
|
+
});
|
|
61
|
+
(0, vitest_1.it)('content-developer allowlists 25 tools and short server name', () => {
|
|
62
|
+
const persona = (0, index_js_5.getPersona)('content-developer');
|
|
63
|
+
(0, vitest_1.expect)(persona.toolIds).toHaveLength(25);
|
|
64
|
+
(0, vitest_1.expect)(persona.toolIds).toEqual([...index_js_1.CONTENT_DEVELOPER_TOOL_IDS]);
|
|
65
|
+
(0, vitest_1.expect)(persona.toolIds).not.toContain('create_space');
|
|
66
|
+
(0, vitest_1.expect)(persona.toolIds).not.toContain('update_space');
|
|
67
|
+
(0, vitest_1.expect)((0, index_js_5.getPersonaServerName)(persona)).toBe('lightdash-mcp-cdev');
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.it)('content-governance allowlists soft-delete + promote tools and short server name', () => {
|
|
70
|
+
const persona = (0, index_js_5.getPersona)('content-governance');
|
|
71
|
+
(0, vitest_1.expect)(persona.toolIds).toHaveLength(4);
|
|
72
|
+
(0, vitest_1.expect)(persona.toolIds).toEqual([...index_js_2.CONTENT_GOVERNANCE_TOOL_IDS]);
|
|
73
|
+
(0, vitest_1.expect)(persona.toolIds).toEqual([
|
|
74
|
+
'delete_chart',
|
|
75
|
+
'delete_dashboard',
|
|
76
|
+
'get_dashboard_promote_diff',
|
|
77
|
+
'promote_dashboard',
|
|
78
|
+
]);
|
|
79
|
+
(0, vitest_1.expect)((0, index_js_5.getPersonaServerName)(persona)).toBe('lightdash-mcp-gov');
|
|
33
80
|
});
|
|
34
81
|
(0, vitest_1.it)('keeps combined server+tool wire names under 60 characters', () => {
|
|
35
|
-
const persona
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
82
|
+
for (const persona of Object.values(index_js_5.PERSONAS)) {
|
|
83
|
+
const serverName = (0, index_js_5.getPersonaServerName)(persona);
|
|
84
|
+
for (const id of persona.toolIds) {
|
|
85
|
+
const combined = serverName.length + (shared_js_1.TOOL_PREFIX + id).length;
|
|
86
|
+
(0, vitest_1.expect)(combined, `${serverName}+${shared_js_1.TOOL_PREFIX}${id}`).toBeLessThanOrEqual(60);
|
|
87
|
+
}
|
|
40
88
|
}
|
|
41
89
|
});
|
|
42
90
|
(0, vitest_1.it)('parsePersonaId validates known ids only', () => {
|
|
43
|
-
(0, vitest_1.expect)((0,
|
|
44
|
-
(0, vitest_1.expect)((0,
|
|
45
|
-
(0, vitest_1.expect)((0,
|
|
91
|
+
(0, vitest_1.expect)((0, index_js_5.parsePersonaId)('semantic-layer')).toBe('semantic-layer');
|
|
92
|
+
(0, vitest_1.expect)((0, index_js_5.parsePersonaId)('organization-audit')).toBe('organization-audit');
|
|
93
|
+
(0, vitest_1.expect)((0, index_js_5.parsePersonaId)('content-reader')).toBe('content-reader');
|
|
94
|
+
(0, vitest_1.expect)((0, index_js_5.parsePersonaId)('content-developer')).toBe('content-developer');
|
|
95
|
+
(0, vitest_1.expect)((0, index_js_5.parsePersonaId)('content-governance')).toBe('content-governance');
|
|
96
|
+
(0, vitest_1.expect)((0, index_js_5.parsePersonaId)('nope')).toBeUndefined();
|
|
46
97
|
});
|
|
47
98
|
(0, vitest_1.it)('registerToolsByIds registers only allowlisted ids', () => {
|
|
48
99
|
const registered = [];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for registering markdown playbook MCP resources and
|
|
3
|
+
* embedding core + topic playbooks into prompt messages.
|
|
4
|
+
*/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
|
+
export declare const PLAYBOOK_MIME: "text/markdown";
|
|
7
|
+
export type PlaybookResourceSpec = {
|
|
8
|
+
/** MCP resource name (stable id for resources/list). */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Canonical URI, e.g. lightdash://playbooks/content-developer/core */
|
|
11
|
+
uri: string;
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
getMarkdown: () => string;
|
|
15
|
+
};
|
|
16
|
+
export type EmbeddedPlaybook = {
|
|
17
|
+
uri: string;
|
|
18
|
+
mimeType?: string;
|
|
19
|
+
getMarkdown: () => string;
|
|
20
|
+
};
|
|
21
|
+
declare function embedResource(playbook: EmbeddedPlaybook): {
|
|
22
|
+
type: "resource";
|
|
23
|
+
resource: {
|
|
24
|
+
uri: string;
|
|
25
|
+
mimeType: string;
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
type PromptUserMessage = {
|
|
30
|
+
role: 'user';
|
|
31
|
+
content: ReturnType<typeof embedResource> | {
|
|
32
|
+
type: 'text';
|
|
33
|
+
text: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Build prompt message helpers that embed core, and optionally one topic playbook,
|
|
38
|
+
* after the user text message. When `topicId` is omitted, only core is embedded.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createPromptPlaybookEmbedder<TopicId extends string>(options: {
|
|
41
|
+
core: EmbeddedPlaybook;
|
|
42
|
+
topics: Readonly<Record<TopicId, EmbeddedPlaybook>>;
|
|
43
|
+
}): (text: string, topicId?: TopicId) => {
|
|
44
|
+
messages: PromptUserMessage[];
|
|
45
|
+
};
|
|
46
|
+
export type PersonaPlaybookTopicDef<TopicId extends string = string> = {
|
|
47
|
+
id: TopicId;
|
|
48
|
+
title: string;
|
|
49
|
+
description: string;
|
|
50
|
+
/** Filename under `playbooks/`, e.g. `dashboards.md`. */
|
|
51
|
+
file: string;
|
|
52
|
+
};
|
|
53
|
+
export type DefinePersonaPlaybooksOptions<TopicId extends string> = {
|
|
54
|
+
personaId: string;
|
|
55
|
+
moduleDir: string;
|
|
56
|
+
hardBans: string;
|
|
57
|
+
topics: readonly PersonaPlaybookTopicDef<TopicId>[];
|
|
58
|
+
indexTitle?: string;
|
|
59
|
+
indexDescription?: string;
|
|
60
|
+
coreTitle?: string;
|
|
61
|
+
coreDescription?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Factory for persona multi-playbook resources (index + core + topics).
|
|
65
|
+
* Callers re-export the returned fields under persona-specific names.
|
|
66
|
+
*/
|
|
67
|
+
export declare function definePersonaPlaybooks<TopicId extends string>(options: DefinePersonaPlaybooksOptions<TopicId>): {
|
|
68
|
+
URIs: {
|
|
69
|
+
index: string;
|
|
70
|
+
core: string;
|
|
71
|
+
topics: Readonly<Record<TopicId, string>>;
|
|
72
|
+
};
|
|
73
|
+
HARD_BANS: string;
|
|
74
|
+
getAllPlaybookMarkdown: () => string;
|
|
75
|
+
CORE_PLAYBOOK: EmbeddedPlaybook;
|
|
76
|
+
TOPIC_PLAYBOOKS: Readonly<Record<TopicId, EmbeddedPlaybook>>;
|
|
77
|
+
registerPlaybooks: (server: McpServer) => void;
|
|
78
|
+
};
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared helpers for registering markdown playbook MCP resources and
|
|
4
|
+
* embedding core + topic playbooks into prompt messages.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PLAYBOOK_MIME = void 0;
|
|
8
|
+
exports.createPromptPlaybookEmbedder = createPromptPlaybookEmbedder;
|
|
9
|
+
exports.definePersonaPlaybooks = definePersonaPlaybooks;
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
exports.PLAYBOOK_MIME = 'text/markdown';
|
|
13
|
+
const markdownCache = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Load a playbook markdown file from a directory adjacent to the compiled module.
|
|
16
|
+
* `moduleDir` should be `__dirname` of the persona's `resources/` folder.
|
|
17
|
+
*/
|
|
18
|
+
function loadPlaybookMarkdown(moduleDir, relativePath) {
|
|
19
|
+
const key = `${moduleDir}::${relativePath}`;
|
|
20
|
+
const cached = markdownCache.get(key);
|
|
21
|
+
if (cached !== undefined) {
|
|
22
|
+
return cached;
|
|
23
|
+
}
|
|
24
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- moduleDir + relativePath from persona constants
|
|
25
|
+
const text = (0, node_fs_1.readFileSync)((0, node_path_1.join)(moduleDir, relativePath), 'utf8');
|
|
26
|
+
markdownCache.set(key, text);
|
|
27
|
+
return text;
|
|
28
|
+
}
|
|
29
|
+
function registerMarkdownPlaybooks(server, specs) {
|
|
30
|
+
for (const spec of specs) {
|
|
31
|
+
const markdown = spec.getMarkdown();
|
|
32
|
+
server.registerResource(spec.name, spec.uri, {
|
|
33
|
+
title: spec.title,
|
|
34
|
+
description: spec.description,
|
|
35
|
+
mimeType: exports.PLAYBOOK_MIME,
|
|
36
|
+
}, async (uri) => ({
|
|
37
|
+
contents: [
|
|
38
|
+
{
|
|
39
|
+
uri: typeof uri === 'string' ? uri : uri.href,
|
|
40
|
+
mimeType: exports.PLAYBOOK_MIME,
|
|
41
|
+
text: markdown,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function embedResource(playbook) {
|
|
48
|
+
var _a;
|
|
49
|
+
return {
|
|
50
|
+
type: 'resource',
|
|
51
|
+
resource: {
|
|
52
|
+
uri: playbook.uri,
|
|
53
|
+
mimeType: (_a = playbook.mimeType) !== null && _a !== void 0 ? _a : exports.PLAYBOOK_MIME,
|
|
54
|
+
text: playbook.getMarkdown(),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Build prompt message helpers that embed core, and optionally one topic playbook,
|
|
60
|
+
* after the user text message. When `topicId` is omitted, only core is embedded.
|
|
61
|
+
*/
|
|
62
|
+
function createPromptPlaybookEmbedder(options) {
|
|
63
|
+
const { core, topics } = options;
|
|
64
|
+
return (text, topicId) => {
|
|
65
|
+
const messages = [
|
|
66
|
+
{
|
|
67
|
+
role: 'user',
|
|
68
|
+
content: { type: 'text', text },
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
role: 'user',
|
|
72
|
+
content: embedResource(core),
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
if (topicId === undefined) {
|
|
76
|
+
return { messages };
|
|
77
|
+
}
|
|
78
|
+
// eslint-disable-next-line security/detect-object-injection -- topicId from persona PROMPT_TOPICS constants
|
|
79
|
+
const topic = topics[topicId];
|
|
80
|
+
if (!topic) {
|
|
81
|
+
throw new Error(`Unknown playbook topic '${topicId}'`);
|
|
82
|
+
}
|
|
83
|
+
messages.push({
|
|
84
|
+
role: 'user',
|
|
85
|
+
content: embedResource(topic),
|
|
86
|
+
});
|
|
87
|
+
return { messages };
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Title-case the first segment only: `content-developer` → `Content-developer`. */
|
|
91
|
+
function titleCasePersona(personaId) {
|
|
92
|
+
const [first = '', ...rest] = personaId.split('-');
|
|
93
|
+
if (first.length === 0) {
|
|
94
|
+
return personaId;
|
|
95
|
+
}
|
|
96
|
+
return [first[0].toUpperCase() + first.slice(1), ...rest].join('-');
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Factory for persona multi-playbook resources (index + core + topics).
|
|
100
|
+
* Callers re-export the returned fields under persona-specific names.
|
|
101
|
+
*/
|
|
102
|
+
function definePersonaPlaybooks(options) {
|
|
103
|
+
const { personaId, moduleDir, hardBans, topics, indexTitle = `${titleCasePersona(personaId)} playbooks`, indexDescription = `Index of ${personaId} workflow playbooks (core + topics)`, coreTitle = `${titleCasePersona(personaId)} core playbook`, coreDescription = 'Hard bans, tools, and operating rules', } = options;
|
|
104
|
+
const indexUri = `lightdash://playbooks/${personaId}`;
|
|
105
|
+
const coreUri = `lightdash://playbooks/${personaId}/core`;
|
|
106
|
+
const namePrefix = personaId.split('-').join('_');
|
|
107
|
+
const load = (relativePath) => loadPlaybookMarkdown(moduleDir, relativePath);
|
|
108
|
+
const getIndexPlaybookMarkdown = () => load('playbooks/index.md');
|
|
109
|
+
const getCorePlaybookMarkdown = () => load('playbooks/core.md');
|
|
110
|
+
const topicUris = {};
|
|
111
|
+
const topicPlaybooks = {};
|
|
112
|
+
const topicMarkdownGetters = [];
|
|
113
|
+
for (const topic of topics) {
|
|
114
|
+
const uri = `lightdash://playbooks/${personaId}/${topic.id}`;
|
|
115
|
+
topicUris[topic.id] = uri;
|
|
116
|
+
const getMarkdown = () => load(`playbooks/${topic.file}`);
|
|
117
|
+
topicMarkdownGetters.push(getMarkdown);
|
|
118
|
+
topicPlaybooks[topic.id] = {
|
|
119
|
+
uri,
|
|
120
|
+
getMarkdown,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const CORE_PLAYBOOK = {
|
|
124
|
+
uri: coreUri,
|
|
125
|
+
getMarkdown: getCorePlaybookMarkdown,
|
|
126
|
+
};
|
|
127
|
+
const getAllPlaybookMarkdown = () => [
|
|
128
|
+
getIndexPlaybookMarkdown(),
|
|
129
|
+
getCorePlaybookMarkdown(),
|
|
130
|
+
...topicMarkdownGetters.map((g) => g()),
|
|
131
|
+
].join('\n');
|
|
132
|
+
const registerPlaybooks = (server) => {
|
|
133
|
+
registerMarkdownPlaybooks(server, [
|
|
134
|
+
{
|
|
135
|
+
name: `${namePrefix}_playbook_index`,
|
|
136
|
+
uri: indexUri,
|
|
137
|
+
title: indexTitle,
|
|
138
|
+
description: indexDescription,
|
|
139
|
+
getMarkdown: getIndexPlaybookMarkdown,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: `${namePrefix}_playbook_core`,
|
|
143
|
+
uri: coreUri,
|
|
144
|
+
title: coreTitle,
|
|
145
|
+
description: coreDescription,
|
|
146
|
+
getMarkdown: getCorePlaybookMarkdown,
|
|
147
|
+
},
|
|
148
|
+
...topics.map((topic) => ({
|
|
149
|
+
name: `${namePrefix}_playbook_${String(topic.id).split('-').join('_')}`,
|
|
150
|
+
uri: topicUris[topic.id],
|
|
151
|
+
title: topic.title,
|
|
152
|
+
description: topic.description,
|
|
153
|
+
getMarkdown: topicPlaybooks[topic.id].getMarkdown,
|
|
154
|
+
})),
|
|
155
|
+
]);
|
|
156
|
+
};
|
|
157
|
+
return {
|
|
158
|
+
URIs: { index: indexUri, core: coreUri, topics: topicUris },
|
|
159
|
+
HARD_BANS: hardBans,
|
|
160
|
+
getAllPlaybookMarkdown,
|
|
161
|
+
CORE_PLAYBOOK,
|
|
162
|
+
TOPIC_PLAYBOOKS: topicPlaybooks,
|
|
163
|
+
registerPlaybooks,
|
|
164
|
+
};
|
|
165
|
+
}
|