@lightdash-tools/mcp 0.23.0 → 0.25.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 +2 -2
- package/dist/auth/oauth-broker/as-metadata.d.ts +1 -0
- package/dist/auth/oauth-broker/as-metadata.js +5 -1
- package/dist/auth/oauth-broker/client-crypto.d.ts +12 -0
- package/dist/auth/oauth-broker/client-crypto.js +80 -0
- package/dist/auth/oauth-broker/client-directory.d.ts +39 -0
- package/dist/auth/oauth-broker/client-directory.js +104 -0
- package/dist/auth/oauth-broker/client-directory.test.d.ts +1 -0
- package/dist/auth/oauth-broker/client-directory.test.js +134 -0
- package/dist/auth/oauth-broker/lightdash-token.d.ts +8 -0
- package/dist/auth/oauth-broker/lightdash-token.js +72 -8
- package/dist/auth/oauth-broker/mcp-access-token.d.ts +3 -0
- package/dist/auth/oauth-broker/mcp-access-token.js +9 -1
- package/dist/auth/oauth-broker/pending-store.d.ts +16 -4
- package/dist/auth/oauth-broker/pending-store.js +40 -18
- package/dist/auth/oauth-broker/refresh-crypto.d.ts +19 -0
- package/dist/auth/oauth-broker/refresh-crypto.js +70 -0
- package/dist/auth/oauth-broker/refresh-crypto.test.d.ts +1 -0
- package/dist/auth/oauth-broker/refresh-crypto.test.js +40 -0
- package/dist/auth/oauth-broker/refresh-flow.test.d.ts +1 -0
- package/dist/auth/oauth-broker/refresh-flow.test.js +350 -0
- package/dist/auth/oauth-broker/refresh-grant.d.ts +46 -0
- package/dist/auth/oauth-broker/refresh-grant.js +288 -0
- package/dist/auth/oauth-broker/refresh-store.conformance.test.d.ts +1 -0
- package/dist/auth/oauth-broker/refresh-store.conformance.test.js +254 -0
- package/dist/auth/oauth-broker/refresh-store.d.ts +61 -0
- package/dist/auth/oauth-broker/refresh-store.js +124 -0
- package/dist/auth/oauth-broker/routes.d.ts +6 -4
- package/dist/auth/oauth-broker/routes.js +114 -51
- package/dist/auth/oauth-broker/routes.test.js +48 -0
- package/dist/auth/oauth-broker/stores/client-kv.d.ts +46 -0
- package/dist/auth/oauth-broker/stores/client-kv.js +182 -0
- package/dist/auth/oauth-broker/stores/firestore.d.ts +29 -0
- package/dist/auth/oauth-broker/stores/firestore.js +201 -0
- package/dist/auth/oauth-broker/stores/open-client-directory.d.ts +4 -0
- package/dist/auth/oauth-broker/stores/open-client-directory.js +30 -0
- package/dist/auth/oauth-broker/stores/open-refresh-store.d.ts +4 -0
- package/dist/auth/oauth-broker/stores/open-refresh-store.js +24 -0
- package/dist/auth/oauth-broker/stores/postgres.d.ts +13 -0
- package/dist/auth/oauth-broker/stores/postgres.js +193 -0
- package/dist/auth/oauth-broker/stores/redis.d.ts +25 -0
- package/dist/auth/oauth-broker/stores/redis.js +337 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +1 -1
- package/dist/config/env.d.ts +13 -0
- package/dist/config/env.js +14 -1
- package/dist/config/load-mcp-config.d.ts +20 -0
- package/dist/config/load-mcp-config.js +53 -1
- package/dist/config/load-mcp-config.test.js +53 -0
- package/dist/config/oauth-store-key.d.ts +2 -0
- package/dist/config/oauth-store-key.js +17 -0
- package/dist/policy/content-developer.d.ts +4 -1
- package/dist/policy/content-developer.js +7 -3
- package/dist/policy/preview-ledger.d.ts +11 -1
- package/dist/policy/preview-ledger.js +29 -3
- package/dist/policy/rename-rejected.d.ts +9 -0
- package/dist/policy/rename-rejected.js +15 -0
- package/dist/profiles/content-developer/v1/index.js +6 -0
- package/dist/profiles/content-developer/v1/prompt-specs.d.ts +1 -1
- package/dist/profiles/content-developer/v1/resources/playbooks/core.md +15 -0
- package/dist/profiles/content-developer/v1/resources/playbooks/recovery/preview-stale.md +1 -0
- package/dist/profiles/content-reader/v1/prompt-specs.d.ts +1 -1
- package/dist/profiles/semantic-layer/v1/prompts.js +3 -3
- package/dist/profiles/semantic-layer/v1/resources/playbooks/compose-compile.md +6 -3
- package/dist/profiles/semantic-layer/v1/resources/playbooks/core.md +1 -1
- package/dist/server/capabilities.d.ts +1 -1
- package/dist/stdio.process.test.js +3 -1
- package/dist/tools/project/content.js +8 -1
- package/dist/tools/project/developer-content.js +1 -1
- package/dist/tools/project/developer-helpers.d.ts +1 -0
- package/dist/tools/project/developer-helpers.test.js +1 -0
- package/dist/tools/project/developer-rename.d.ts +13 -0
- package/dist/tools/project/developer-rename.js +319 -0
- package/dist/tools/project/developer-rename.test.d.ts +5 -0
- package/dist/tools/project/developer-rename.test.js +296 -0
- package/dist/tools/project/reader-content.js +10 -3
- package/dist/tools/project/rename-instruction.d.ts +58 -0
- package/dist/tools/project/rename-instruction.js +104 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +1 -1
- package/dist/tools/query/reader-tool-helpers.js +4 -0
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/semantic/explore-helpers.d.ts +6 -0
- package/dist/tools/semantic/explore-helpers.js +43 -0
- package/dist/tools/semantic/explore-helpers.test.js +17 -0
- package/dist/tools/semantic/query.js +9 -19
- package/dist/tools/semantic/query.test.js +71 -0
- package/dist/transports/streamable-http.js +33 -7
- package/package.json +13 -9
|
@@ -6,14 +6,22 @@
|
|
|
6
6
|
* ledger). confirm_preview mints a validated token; apply verifies + re-sends proposed.
|
|
7
7
|
*/
|
|
8
8
|
import type { ServerContext } from '@modelcontextprotocol/server';
|
|
9
|
-
export declare const PREVIEW_RESOURCE_KINDS: readonly ["chart", "content-move", "dashboard"];
|
|
9
|
+
export declare const PREVIEW_RESOURCE_KINDS: readonly ["chart", "content-move", "dashboard", "rename"];
|
|
10
10
|
export type PreviewResourceKind = (typeof PREVIEW_RESOURCE_KINDS)[number];
|
|
11
11
|
export type PreviewStatus = 'draft' | 'validated';
|
|
12
|
+
/** Sorted uuid lists from a project rename preview. Apply compares a fresh preview to them. */
|
|
13
|
+
export type RenameImpactBaseline = {
|
|
14
|
+
alerts: readonly string[];
|
|
15
|
+
charts: readonly string[];
|
|
16
|
+
dashboardSchedulers: readonly string[];
|
|
17
|
+
dashboards: readonly string[];
|
|
18
|
+
};
|
|
12
19
|
/** Snapshot identity captured when the preview was issued (for update stale detection). */
|
|
13
20
|
export type PreviewBaseline = {
|
|
14
21
|
updatedAt?: string;
|
|
15
22
|
uuid?: string;
|
|
16
23
|
slug?: string;
|
|
24
|
+
renameImpact?: RenameImpactBaseline;
|
|
17
25
|
};
|
|
18
26
|
/** Compact claims embedded in the HMAC-signed previewToken (no proposed body). */
|
|
19
27
|
export type PreviewTokenClaims = {
|
|
@@ -42,6 +50,8 @@ export declare function resetPreviewLedgerForTests(): void;
|
|
|
42
50
|
/** sha256 hex digest of the stable JSON form of `value` (preview binding hash). */
|
|
43
51
|
export declare function hashPreviewContent(value: unknown): string;
|
|
44
52
|
export declare function uniqueResourceKeys(...keys: Array<string | null | undefined>): string[];
|
|
53
|
+
/** True when both impact snapshots list the same uuids. A missing snapshot is stale. */
|
|
54
|
+
export declare function sameRenameImpact(stored: RenameImpactBaseline | undefined, fresh: RenameImpactBaseline | undefined): boolean;
|
|
45
55
|
/** Mint a draft previewToken (opaque HMAC blob). Does not store proposed on the server. */
|
|
46
56
|
export declare function mintDraftPreviewToken(input: {
|
|
47
57
|
subject: string;
|
|
@@ -11,6 +11,7 @@ exports.EMPTY_SERVER_CONTEXT = exports.DEFAULT_PREVIEW_TTL_MS = exports.PreviewL
|
|
|
11
11
|
exports.resetPreviewLedgerForTests = resetPreviewLedgerForTests;
|
|
12
12
|
exports.hashPreviewContent = hashPreviewContent;
|
|
13
13
|
exports.uniqueResourceKeys = uniqueResourceKeys;
|
|
14
|
+
exports.sameRenameImpact = sameRenameImpact;
|
|
14
15
|
exports.mintDraftPreviewToken = mintDraftPreviewToken;
|
|
15
16
|
exports.confirmPreviewToken = confirmPreviewToken;
|
|
16
17
|
exports.withValidatedPreviewApply = withValidatedPreviewApply;
|
|
@@ -18,7 +19,7 @@ const node_crypto_1 = require("node:crypto");
|
|
|
18
19
|
const server_1 = require("@modelcontextprotocol/server");
|
|
19
20
|
const request_state_key_js_1 = require("../auth/request-state-key.js");
|
|
20
21
|
const stable_stringify_js_1 = require("../tools/lib/stable-stringify.js");
|
|
21
|
-
exports.PREVIEW_RESOURCE_KINDS = ['chart', 'content-move', 'dashboard'];
|
|
22
|
+
exports.PREVIEW_RESOURCE_KINDS = ['chart', 'content-move', 'dashboard', 'rename'];
|
|
22
23
|
class PreviewLedgerError extends Error {
|
|
23
24
|
constructor(code, message) {
|
|
24
25
|
super(message);
|
|
@@ -65,9 +66,28 @@ function hashPreviewBinding(proposed, baseline) {
|
|
|
65
66
|
function resourceKeyMatches(claims, resourceKey) {
|
|
66
67
|
return claims.resourceKey === resourceKey || claims.resourceAliases.includes(resourceKey);
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
function sameIds(left, right) {
|
|
70
|
+
if (left.length !== right.length) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return left.every((id, index) => {
|
|
74
|
+
const [counterpart] = right.slice(index, index + 1);
|
|
75
|
+
return id === counterpart;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/** True when both impact snapshots list the same uuids. A missing snapshot is stale. */
|
|
79
|
+
function sameRenameImpact(stored, fresh) {
|
|
80
|
+
if (stored == null || fresh == null) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return (sameIds(stored.alerts, fresh.alerts) &&
|
|
84
|
+
sameIds(stored.charts, fresh.charts) &&
|
|
85
|
+
sameIds(stored.dashboardSchedulers, fresh.dashboardSchedulers) &&
|
|
86
|
+
sameIds(stored.dashboards, fresh.dashboards));
|
|
87
|
+
}
|
|
88
|
+
/** Update drift, create-target appearance, or a changed project rename impact → PREVIEW_STALE. */
|
|
69
89
|
function assertBaselineStillValid(previewId, claims, currentBaseline) {
|
|
70
|
-
var _a;
|
|
90
|
+
var _a, _b;
|
|
71
91
|
const previewedUpdatedAt = (_a = claims.baseline) === null || _a === void 0 ? void 0 : _a.updatedAt;
|
|
72
92
|
if (previewedUpdatedAt != null &&
|
|
73
93
|
previewedUpdatedAt !== '' &&
|
|
@@ -79,6 +99,12 @@ function assertBaselineStillValid(previewId, claims, currentBaseline) {
|
|
|
79
99
|
((currentBaseline === null || currentBaseline === void 0 ? void 0 : currentBaseline.updatedAt) != null && currentBaseline.updatedAt !== ''))) {
|
|
80
100
|
throw new PreviewLedgerError('PREVIEW_STALE', `Preview '${previewId}' targeted a non-existent resource that now exists; re-run preview -> confirm`);
|
|
81
101
|
}
|
|
102
|
+
const storedImpact = (_b = claims.baseline) === null || _b === void 0 ? void 0 : _b.renameImpact;
|
|
103
|
+
const freshImpact = currentBaseline === null || currentBaseline === void 0 ? void 0 : currentBaseline.renameImpact;
|
|
104
|
+
if ((storedImpact != null || freshImpact != null) &&
|
|
105
|
+
!sameRenameImpact(storedImpact, freshImpact)) {
|
|
106
|
+
throw new PreviewLedgerError('PREVIEW_STALE', `Preview '${previewId}' rename impact changed; re-run preview_rename -> confirm`);
|
|
107
|
+
}
|
|
82
108
|
}
|
|
83
109
|
function resolveServerContext(serverContext) {
|
|
84
110
|
return serverContext !== null && serverContext !== void 0 ? serverContext : exports.EMPTY_SERVER_CONTEXT;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coded rejection for a rename instruction that must not be previewed or posted.
|
|
3
|
+
* Lives next to the content-developer error mapper so policy does not import tools.
|
|
4
|
+
*/
|
|
5
|
+
export type RenameRejectCode = 'RENAME_DRY_RUN' | 'RENAME_FIELD_UNLISTED' | 'RENAME_TARGET' | 'RENAME_UNCHANGED';
|
|
6
|
+
export declare class RenameRejectedError extends Error {
|
|
7
|
+
readonly code: RenameRejectCode;
|
|
8
|
+
constructor(code: RenameRejectCode, message: string);
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Coded rejection for a rename instruction that must not be previewed or posted.
|
|
4
|
+
* Lives next to the content-developer error mapper so policy does not import tools.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RenameRejectedError = void 0;
|
|
8
|
+
class RenameRejectedError extends Error {
|
|
9
|
+
constructor(code, message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'RenameRejectedError';
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.RenameRejectedError = RenameRejectedError;
|
|
@@ -9,6 +9,7 @@ exports.contentDeveloperProfile = exports.CONTENT_DEVELOPER_PROFILE_PATH = void
|
|
|
9
9
|
const developer_content_preview_js_1 = require("../../../tools/project/developer-content-preview.js");
|
|
10
10
|
const developer_content_js_1 = require("../../../tools/project/developer-content.js");
|
|
11
11
|
const developer_get_chart_as_code_js_1 = require("../../../tools/project/developer-get-chart-as-code.js");
|
|
12
|
+
const developer_rename_js_1 = require("../../../tools/project/developer-rename.js");
|
|
12
13
|
const projects_js_1 = require("../../../tools/project/projects.js");
|
|
13
14
|
const reader_content_js_1 = require("../../../tools/project/reader-content.js");
|
|
14
15
|
const spaces_js_1 = require("../../../tools/project/spaces.js");
|
|
@@ -46,6 +47,11 @@ exports.contentDeveloperProfile = {
|
|
|
46
47
|
developer_content_js_1.removeDashboardTileTool,
|
|
47
48
|
developer_content_js_1.resizeDashboardTileTool,
|
|
48
49
|
developer_content_js_1.moveContentTool,
|
|
50
|
+
developer_rename_js_1.listRenameFieldsTool,
|
|
51
|
+
developer_rename_js_1.previewRenameTool,
|
|
52
|
+
developer_rename_js_1.renameChartTool,
|
|
53
|
+
developer_rename_js_1.renameDashboardFilterTool,
|
|
54
|
+
developer_rename_js_1.renameProjectTool,
|
|
49
55
|
],
|
|
50
56
|
registerPrompts: prompts_js_1.registerContentDeveloperPrompts,
|
|
51
57
|
registerResources: playbooks_js_1.registerContentDeveloperPlaybook,
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Pure PromptContextSpec builders for content-developer prompts.
|
|
3
3
|
* Shared by registerContentDeveloperPrompts and budget gates.
|
|
4
4
|
*/
|
|
5
|
-
import type { ContentDeveloperPlaybookTopic } from './resources/playbooks.js';
|
|
6
5
|
import type { PromptContextSpec } from '../../lib/prompt-context.js';
|
|
6
|
+
import type { ContentDeveloperPlaybookTopic } from './resources/playbooks.js';
|
|
7
7
|
/** Topics for create/improve dashboard prompts (shell + design + viz). */
|
|
8
8
|
export declare const DASHBOARD_CHART_TOPIC_IDS: readonly ["dashboards", "dashboard-design", "chart-types"];
|
|
9
9
|
/** Topics for refactor (shell + design). */
|
|
@@ -61,6 +61,9 @@ Record when a budget stopped you. User-requested “one of every chart type” o
|
|
|
61
61
|
| `create_dashboard` / `update_dashboard` / `duplicate_dashboard` | Dashboard shell then tile updates |
|
|
62
62
|
| `add_dashboard_tile` / `move_dashboard_tile` / `remove_dashboard_tile` / `resize_dashboard_tile` | Tile ops; each needs preview of the **full next tiles array** |
|
|
63
63
|
| `move_content` | Relocate into existing spaces |
|
|
64
|
+
| `list_rename_fields` | Field ids that can replace a missing chart field or dashboard filter target |
|
|
65
|
+
| `preview_rename` | Mint draft `previewToken` for a rename instruction |
|
|
66
|
+
| `rename_chart` / `rename_dashboard_filter` / `rename_project` | Rename writes after confirm. See **Rename a missing field** |
|
|
64
67
|
| `validate_chart` / `validate_dashboard` | Optional post-apply health (`chartUuid` / dashboard UUID) |
|
|
65
68
|
| `compare_chart_versions` / `compare_dashboard_versions` | Drift / refactor |
|
|
66
69
|
|
|
@@ -96,6 +99,7 @@ Record when a budget stopped you. User-requested “one of every chart type” o
|
|
|
96
99
|
| Update / tile ops | `dashboard` | dashboard UUID (slug is alias) |
|
|
97
100
|
| Duplicate dashboard | `dashboard` | **source** UUID |
|
|
98
101
|
| Content move | `content-move` | preview's `resourceKey` |
|
|
102
|
+
| Rename | `rename` | chart UUID, dashboard UUID, or the project preview's `resourceKey` |
|
|
99
103
|
|
|
100
104
|
**Create-chart gotcha:** omit top-level `slug` on `preview_chart_changes` → preview returns `resourceKey: "new"`, but `create_chart` applies with `resourceKey = args.slug` → binding mismatch. Always pass top-level `slug` (same as `changes.slug`) on create previews.
|
|
101
105
|
|
|
@@ -110,3 +114,14 @@ Record when a budget stopped you. User-requested “one of every chart type” o
|
|
|
110
114
|
- `create_chart` response: extract UUID from `charts[0].data.uuid` (not a bare chart object).
|
|
111
115
|
- Viz shapes: `lightdash://playbooks/content-developer/chart-types`.
|
|
112
116
|
- PoP: prefer cloned `generationType: periodOverPeriod` metrics; else % of total / rank / windows via `lightdash://playbooks/content-developer/table-calculations`.
|
|
117
|
+
|
|
118
|
+
## Rename a missing field
|
|
119
|
+
|
|
120
|
+
Use rename when a chart or a dashboard filter references a field or model that no longer exists. One field rename rewrites both a missing dimension and a missing sort when they share the field id.
|
|
121
|
+
|
|
122
|
+
1. Call `list_rename_fields` with `target` set to `chart` or `dashboard`. For a field rename, `to` must be an id from that list. The list includes joined tables.
|
|
123
|
+
2. Call `preview_rename` with scope `chart`, `dashboard-filter`, or `project`. A model rename does not load the field list. A project field rename needs `model` set to the explore name and full field ids that start with that name, such as `orders_status` with `model` `orders`. Project scope returns the affected uuid lists as `impact`. `from` and `to` may contain only lowercase letters, digits, and underscores.
|
|
124
|
+
3. Call `confirm_preview` with the draft `previewToken`, `resourceKind: rename`, and the preview `resourceKey`. Apply with the returned validated `previewToken`.
|
|
125
|
+
4. Apply with `rename_chart`, `rename_dashboard_filter`, or `rename_project`. Pass the same target, `type`, `from`, and `to` as the preview, plus `model` for a project rename. Any other value returns `PREVIEW_STALE`.
|
|
126
|
+
5. `rename_project` previews again before it posts. A changed uuid list returns `PREVIEW_STALE`. A matching field list posts the short names (`status`, not `orders_status`) and returns `jobId`. The tool does not poll the job. Pass the same full ids you previewed. The tool strips the explore prefix for the job.
|
|
127
|
+
6. If charts or dashboards as code live in git, run `lightdash download` and commit. A later `lightdash upload` from stale YAML overwrites the rename. Then validate again with `validate_chart` or `validate_dashboard`.
|
|
@@ -19,3 +19,4 @@ Tool error `PREVIEW_STALE` — content hash mismatch, baseline `updatedAt` drift
|
|
|
19
19
|
- Edited proposed fields after preview (hash mismatch).
|
|
20
20
|
- Resource changed under you (`updatedAt` / create appeared).
|
|
21
21
|
- Create-chart preview omitted top-level `slug` → `resourceKey` mismatch at apply.
|
|
22
|
+
- A project rename now affects different charts, dashboards, alerts, or schedulers than `preview_rename` recorded.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Pure PromptContextSpec builders for content-reader prompts.
|
|
3
3
|
* Shared by registerContentReaderPrompts and budget gates.
|
|
4
4
|
*/
|
|
5
|
-
import type { ContentReaderPlaybookTopic } from './resources/playbooks.js';
|
|
6
5
|
import type { PromptContextSpec } from '../../lib/prompt-context.js';
|
|
6
|
+
import type { ContentReaderPlaybookTopic } from './resources/playbooks.js';
|
|
7
7
|
export declare const TOPIC_DISCOVER: "discover";
|
|
8
8
|
export type FindContentPromptArgs = {
|
|
9
9
|
question: string;
|
|
@@ -71,7 +71,7 @@ Procedure:
|
|
|
71
71
|
1. If exploreId is missing, resolve it per explore playbook (search + disambiguation). Stay on this projectUuid.
|
|
72
72
|
2. Copy fieldIds from list_dimensions and {exploreId}_{metricName} from get_explore → tables[baseTable].metrics. Never invent grains.
|
|
73
73
|
3. If the user asked for N insights, reuse one explore and compile N diverse cuts.
|
|
74
|
-
4. Build metricQuery from the compose-compile skeleton (fieldIds only; tool sets exploreName from exploreId and defaults missing tableCalculations to []). After each compile, verify every requested fieldId appears as a SELECT alias (missing alias = failure even without isError). Prefer SELECT aliases over metric name/label. ≤2 fix retries.
|
|
74
|
+
4. Build metricQuery from the compose-compile skeleton (fieldIds only; tool sets exploreName from exploreId and defaults missing tableCalculations and sorts to []). After each compile, verify every requested fieldId appears as a SELECT alias (missing alias = failure even without isError). Prefer SELECT aliases over metric name/label. ≤2 fix retries.
|
|
75
75
|
5. Deliverable: insight title(s) + fieldIds + compiled SQL (or errors). Never paste full explore/dimension/metric/lineage payloads.`,
|
|
76
76
|
invariantIds,
|
|
77
77
|
requiredTopics: [TOPIC_COMPOSE_COMPILE],
|
|
@@ -95,8 +95,8 @@ Explore: ${exploreId}
|
|
|
95
95
|
${err}
|
|
96
96
|
|
|
97
97
|
Checklist:
|
|
98
|
-
- unknown field id / empty SELECT / missing SELECT alias → use fieldIds from list_dimensions (base table) + explore-local metrics; re-compile (≤2 retries). Prefer SELECT aliases / compiledSql over metric name/label.
|
|
99
|
-
- Other OpenAPI-required keys still failing (filters,
|
|
98
|
+
- unknown field id / empty SELECT / missing SELECT alias / SQL ERROR comment → use fieldIds from list_dimensions (base table; STRUCT dots → __; ARRAY via baseTableOnly=false) + explore-local metrics; re-compile (≤2 retries). Prefer SELECT aliases / compiledSql over metric name/label.
|
|
99
|
+
- Other OpenAPI-required keys still failing (filters, limit, …) → copy the compose-compile skeleton; MCP fills exploreName and missing tableCalculations / sorts.
|
|
100
100
|
- Wrong explore → re-disambiguate (schemaName; label or name __{table}; skip empty schema / eda unless asked).
|
|
101
101
|
- Metric not found / catalog empty → get_explore tables[baseTable].metrics; tableName must be the full explore id; compile as {exploreId}_{metricName}.
|
|
102
102
|
- Verify SELECT aliases after every compile. Stop after a good compile or a clear blocker.`,
|
|
@@ -25,7 +25,7 @@ URI: `lightdash://playbooks/semantic-layer/compose-compile`
|
|
|
25
25
|
|
|
26
26
|
`metrics` may be `[]`. Every string in `dimensions` / `metrics` / `sorts[].fieldId` must appear in prior tool output.
|
|
27
27
|
|
|
28
|
-
MCP `compile_query` always sets `exploreName` from the tool `exploreId` (path is authoritative), defaults missing `tableCalculations` to `[]`, and **fills missing FilterGroup/FilterRule `id`s** (does not invent wrappers for unknown shapes). Keep the full skeleton for other OpenAPI-required keys (`filters`, `
|
|
28
|
+
MCP `compile_query` always sets `exploreName` from the tool `exploreId` (path is authoritative), defaults missing `tableCalculations` and `sorts` to `[]`, and **fills missing FilterGroup/FilterRule `id`s** (does not invent wrappers for unknown shapes). Keep the full skeleton for other OpenAPI-required keys (`filters`, `limit`, …) and for CLI/JSON callers. Prefer SELECT aliases / metric `compiledSql` over metric **name/label** when they disagree.
|
|
29
29
|
|
|
30
30
|
When filters are non-empty, prefer an explicit FilterGroup:
|
|
31
31
|
|
|
@@ -56,10 +56,13 @@ MCP may inject missing `id`s; still copy this shape so non-MCP clients and hosts
|
|
|
56
56
|
| `unknown field id` / hard error | Short names or typos | Use full `fieldId` from `list_dimensions` / `{exploreId}_{metricName}` |
|
|
57
57
|
| Server `isError` + empty SELECT | Upstream accepted bad ids with **zero** columns | Replace with real fieldIds; re-compile once |
|
|
58
58
|
| Server `isError` + missing SELECT aliases | Invented id, dotted STRUCT id (`…_customer.first_name` vs `…_customer__first_name`), or ARRAY join id without `baseTableOnly=false` | Copy `fieldId` from `list_dimensions` (STRUCT dots → `__`; ARRAY via join tables); re-compile |
|
|
59
|
+
| Server `isError` + compiled SQL `/* ERROR:` comment | Unknown filter (or other) fieldId; Lightdash embeds an ERROR comment while still returning SQL | Copy filter `fieldId`s from `list_dimensions`; re-compile |
|
|
59
60
|
| SQL “succeeds” but a requested dim/metric is **missing** from SELECT | Invented or wrong fieldId while another field still projected (pre-guard / non-MCP clients) | Re-check against `list_dimensions` / metrics map; re-compile |
|
|
60
61
|
| `UPSTREAM_VALIDATION` / `'tableCalculations' is required` | Body omitted `tableCalculations` (pre-harden / non-MCP clients) | MCP defaults to `[]`; pass `tableCalculations: []` explicitly if needed |
|
|
62
|
+
| `UPSTREAM_VALIDATION` / `'sorts' is required` | Body omitted `sorts` (pre-harden / non-MCP clients) | MCP defaults to `[]`; pass `sorts: []` explicitly if needed |
|
|
61
63
|
| `UPSTREAM_VALIDATION` / `'exploreName' is required` | Body omitted `exploreName` (pre-harden / non-MCP clients) or wrong exploreId | Pass locked `exploreId`; MCP fills `exploreName` — re-compile once |
|
|
62
64
|
| `UPSTREAM_VALIDATION` on `filters.dimensions` (`'id'/'or' required`) | FilterGroup missing top-level `id` (rules alone are not enough; pre-harden / non-MCP) | Prefer `{ "id": "…", "and": [ { "id": "…", "target": { "fieldId": "…" }, "operator": "…", "values": […] } ] }`; MCP fills missing ids |
|
|
65
|
+
| `UPSTREAM_VALIDATION` / operator `should be one of …` | Invented operator (e.g. `isNotNull`) | Use `notNull` / `isNull` (not `isNotNull`) |
|
|
63
66
|
| `Metric not found` on `get_metric` | `tableName` was warehouse label | Use full explore id |
|
|
64
67
|
| Lineage works with short name but compile fails | `get_field_lineage` accepts short names; `compile_query` does not | Always copy full `fieldId` into `metricQuery` |
|
|
65
68
|
|
|
@@ -67,7 +70,7 @@ Compiled SQL may include **extra related metrics** the semantic layer pulls in
|
|
|
67
70
|
|
|
68
71
|
## Verify after every compile (mandatory)
|
|
69
72
|
|
|
70
|
-
MCP `compile_query` sets `isError` when the SELECT is empty or when requested `dimensions` / `metrics` are missing from SELECT aliases. Still verify locally (belt-and-suspenders for hosts that ignore `isError`):
|
|
73
|
+
MCP `compile_query` sets `isError` when the SELECT is empty, when compiled SQL embeds a `/* ERROR:` comment (e.g. unknown filter fieldId), or when requested `dimensions` / `metrics` are missing from SELECT aliases. Still verify locally (belt-and-suspenders for hosts that ignore `isError`):
|
|
71
74
|
|
|
72
75
|
1. Parse the compiled `query` SELECT list (aliases / AS names).
|
|
73
76
|
2. Confirm **each** requested dimension and metric `fieldId` is present.
|
|
@@ -86,7 +89,7 @@ When the user asks for N insights on one table/explore:
|
|
|
86
89
|
## Debug checklist
|
|
87
90
|
|
|
88
91
|
- Unknown field id / short names / empty SELECT / missing SELECT alias → fix fieldIds from `list_dimensions` + explore-local metrics; re-compile (≤2 retries). Prefer SELECT aliases / `compiledSql` over metric name/label.
|
|
89
|
-
- Other OpenAPI-required keys still failing (`filters`, `
|
|
92
|
+
- Other OpenAPI-required keys still failing (`filters`, `limit`, …) → copy the skeleton; MCP already fills `exploreName`, missing `tableCalculations` / `sorts`, and missing filter `id`s.
|
|
90
93
|
- Wrong explore → re-disambiguate (`schemaName`; exact `label` or `name` `__{table}`; skip empty schema / eda unless asked).
|
|
91
94
|
- Catalog empty / metric not found → `get_explore` `tables[baseTable].metrics`; compile as `{exploreId}_{metricName}`.
|
|
92
95
|
- Stop after a good verified compile or a clear blocker.
|
|
@@ -38,7 +38,7 @@ Record when a budget stopped you.
|
|
|
38
38
|
| `list_dimensions` | Compact `{ name, label, table, type, fieldId }`. Default = base table only. Use `baseTableOnly=false` for ordinary joins **and** ARRAY UNNEST tables (`{base}__{column}`). |
|
|
39
39
|
| `get_explore` | **Preferred** metric menu: `tables[baseTable].metrics` names/labels only. Ignore join **metrics**; joined/ARRAY dims via `list_dimensions` (`baseTableOnly=false`) when needed. |
|
|
40
40
|
| `list_metrics` / `get_metric` | Optional catalog / definition dig. Filter `tableName === exploreId`. |
|
|
41
|
-
| `compile_query` | Compile only — never “run”. Sets `exploreName` from `exploreId`; defaults missing `tableCalculations` to `[]`. Prefer compiled SQL aliases over metric labels.
|
|
41
|
+
| `compile_query` | Compile only — never “run”. Sets `exploreName` from `exploreId`; defaults missing `tableCalculations` and `sorts` to `[]`. Prefer compiled SQL aliases over metric labels. |
|
|
42
42
|
| `get_field_lineage` | Optional provenance; summarize, don’t dump. |
|
|
43
43
|
|
|
44
44
|
## Project scope (critical)
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Registers MCP capabilities for a profile.
|
|
3
3
|
*/
|
|
4
4
|
import { type PromptContextPolicy } from '../config/prompt-context-policy.js';
|
|
5
|
-
import type { McpContextProvider } from './request-context.js';
|
|
6
5
|
import type { ProfileDefinition } from '../profiles/types.js';
|
|
6
|
+
import type { McpContextProvider } from './request-context.js';
|
|
7
7
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
8
8
|
export type RegisterCapabilitiesOptions = {
|
|
9
9
|
/** Profile to register (defaults to {@link getDefaultProfile}). */
|
|
@@ -18,6 +18,7 @@ const repoRoot = process.cwd();
|
|
|
18
18
|
const binPath = node_path_1.default.join(repoRoot, 'packages/mcp/dist/bin.js');
|
|
19
19
|
const INIT_TIMEOUT_MS = 5000;
|
|
20
20
|
const SEMANTIC_LAYER_TOOL_COUNT = (0, index_js_1.getProfile)('semantic-layer').tools.length;
|
|
21
|
+
const CONTENT_DEVELOPER_TOOL_COUNT = (0, index_js_1.getProfile)('content-developer').tools.length;
|
|
21
22
|
function writeLine(child, message) {
|
|
22
23
|
child.stdin.write(`${JSON.stringify(message)}\n`);
|
|
23
24
|
}
|
|
@@ -225,7 +226,8 @@ async function initializeThenListTools(child, getStderr, clientName) {
|
|
|
225
226
|
child = spawned.child;
|
|
226
227
|
const { serverName, tools } = await initializeThenListTools(child, spawned.getStderr, 'stdio-process-smoke');
|
|
227
228
|
(0, vitest_1.expect)(serverName).toBe('lightdash-mcp-cdev');
|
|
228
|
-
(0, vitest_1.expect)(tools).toHaveLength(
|
|
229
|
+
(0, vitest_1.expect)(tools).toHaveLength(CONTENT_DEVELOPER_TOOL_COUNT);
|
|
230
|
+
(0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_preview_rename')).toBe(true);
|
|
229
231
|
(0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_get_chart_as_code')).toBe(true);
|
|
230
232
|
(0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_preview_dashboard_changes')).toBe(true);
|
|
231
233
|
(0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_move_content')).toBe(true);
|
|
@@ -45,7 +45,13 @@ function registerListContent(server, contextProvider) {
|
|
|
45
45
|
projectUuids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
46
46
|
spaceUuids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
47
47
|
parentSpaceUuid: zod_1.z.string().optional(),
|
|
48
|
-
contentTypes: zod_1.z
|
|
48
|
+
contentTypes: zod_1.z
|
|
49
|
+
.array(zod_1.z.enum(['chart', 'dashboard', 'space', 'data_app', 'document']))
|
|
50
|
+
.optional(),
|
|
51
|
+
includePersonalDocuments: zod_1.z
|
|
52
|
+
.boolean()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("Include the caller's personal documents. Omitted leaves the server default"),
|
|
49
55
|
search: zod_1.z.string().optional(),
|
|
50
56
|
sortBy: zod_1.z.enum(common_1.CONTENT_SORT_BY_COLUMNS).optional(),
|
|
51
57
|
sortDirection: zod_1.z.enum(['asc', 'desc']).optional(),
|
|
@@ -65,6 +71,7 @@ function registerListContent(server, contextProvider) {
|
|
|
65
71
|
spaceUuids: args.spaceUuids,
|
|
66
72
|
parentSpaceUuid: args.parentSpaceUuid,
|
|
67
73
|
contentTypes: args.contentTypes,
|
|
74
|
+
includePersonalDocuments: args.includePersonalDocuments,
|
|
68
75
|
search: args.search,
|
|
69
76
|
sortBy: args.sortBy,
|
|
70
77
|
sortDirection: args.sortDirection,
|
|
@@ -93,7 +93,7 @@ function registerValidateDashboard(server, contextProvider) {
|
|
|
93
93
|
function registerConfirmPreview(server, contextProvider) {
|
|
94
94
|
(0, content_developer_js_1.registerContentDeveloperTool)(server, 'confirm_preview', {
|
|
95
95
|
title: 'Confirm preview',
|
|
96
|
-
description: 'Confirm a previewed create/update/duplicate/tile/content-move payload; resourceKind/resourceKey must match the preview exactly. Required unlock before every write tool.',
|
|
96
|
+
description: 'Confirm a previewed create/update/duplicate/tile/content-move/rename payload; resourceKind/resourceKey must match the preview exactly. Required unlock before every write tool.',
|
|
97
97
|
safety: content_developer_js_1.VALIDATE_SAFETY,
|
|
98
98
|
inputSchema: {
|
|
99
99
|
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
@@ -36,6 +36,7 @@ export type VersionSummary = {
|
|
|
36
36
|
* Providing only one of versionUuidA/versionUuidB is rejected.
|
|
37
37
|
*/
|
|
38
38
|
export declare function resolveCompareVersionIds(history: readonly VersionSummary[], versionUuidA?: string, versionUuidB?: string): [string, string];
|
|
39
|
+
/** Preview/apply move types. `space` and `document` are valid ItemPayload values and stay off this surface. */
|
|
39
40
|
export type MoveContentType = 'chart' | 'dashboard' | 'data_app';
|
|
40
41
|
export type MoveChartSource = 'dbt_explore' | 'sql';
|
|
41
42
|
/** Throws when `contentTypes` (required) or `chartSources` (when provided) don't line up 1:1 with `itemUuids`. */
|
|
@@ -382,6 +382,7 @@ const developer_helpers_js_1 = require("./developer-helpers.js");
|
|
|
382
382
|
});
|
|
383
383
|
(0, vitest_1.it)('rejects unsupported content types', () => {
|
|
384
384
|
(0, vitest_1.expect)((0, developer_helpers_js_1.moveContentItemFromSummary)({ uuid: 's1', contentType: 'space' })).toBeNull();
|
|
385
|
+
(0, vitest_1.expect)((0, developer_helpers_js_1.moveContentItemFromSummary)({ uuid: 'd1', contentType: 'document' })).toBeNull();
|
|
385
386
|
});
|
|
386
387
|
(0, vitest_1.it)('normalizes null target space and named spaces', () => {
|
|
387
388
|
(0, vitest_1.expect)((0, developer_helpers_js_1.moveContentTargetSpaceFromRecord)(null, null)).toEqual({ uuid: null, name: null });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-developer rename tools (ADR-0036).
|
|
3
|
+
*
|
|
4
|
+
* preview_rename mints a previewToken (ADR-0019) over a RenameInstruction. Chart and
|
|
5
|
+
* dashboard scopes bind the saved resource baseline and do not call POST /rename/preview.
|
|
6
|
+
* Project scope calls it and binds the impacted uuid lists. Apply tools rebuild the
|
|
7
|
+
* instruction from their own arguments, so a token unlocks only the rename it previewed.
|
|
8
|
+
*/
|
|
9
|
+
export declare const listRenameFieldsTool: import("../types.js").ToolModule;
|
|
10
|
+
export declare const previewRenameTool: import("../types.js").ToolModule;
|
|
11
|
+
export declare const renameChartTool: import("../types.js").ToolModule;
|
|
12
|
+
export declare const renameDashboardFilterTool: import("../types.js").ToolModule;
|
|
13
|
+
export declare const renameProjectTool: import("../types.js").ToolModule;
|