@lightdash-tools/mcp 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -14
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +31 -57
- package/dist/cli-help.d.ts +5 -0
- package/dist/cli-help.js +23 -0
- package/dist/cli-help.test.js +24 -0
- package/dist/config/env.d.ts +2 -2
- package/dist/config/env.js +3 -3
- package/dist/config/load-mcp-config.js +10 -2
- package/dist/config/load-mcp-config.test.js +34 -6
- package/dist/config/obsolete-env.js +0 -4
- package/dist/config/obsolete-env.test.js +0 -5
- package/dist/config/runtime.js +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +22 -32
- package/dist/profiles/ai-agent-ops/v1/index.js +25 -6
- package/dist/profiles/ai-agent-ops/v1/prompts.test.js +2 -5
- package/dist/profiles/content-developer/v1/index.js +36 -6
- package/dist/profiles/content-developer/v1/prompts.test.js +7 -8
- package/dist/profiles/content-governance/v1/index.js +7 -6
- package/dist/profiles/content-governance/v1/prompts.test.js +2 -5
- package/dist/profiles/content-reader/v1/index.js +26 -6
- package/dist/profiles/content-reader/v1/prompts.test.js +2 -5
- package/dist/profiles/data-analyst/v1/index.js +19 -6
- package/dist/profiles/data-analyst/v1/prompts.test.js +2 -4
- package/dist/profiles/index.d.ts +3 -1
- package/dist/profiles/index.js +6 -1
- package/dist/profiles/index.test.js +29 -14
- package/dist/profiles/organization-audit/v1/index.js +27 -6
- package/dist/profiles/organization-audit/v1/prompts.test.js +2 -5
- package/dist/profiles/semantic-layer/v1/index.js +17 -6
- package/dist/profiles/semantic-layer/v1/prompts.js +3 -2
- package/dist/profiles/semantic-layer/v1/prompts.test.js +2 -5
- package/dist/profiles/semantic-layer/v1/resources/playbooks/compose-compile.md +14 -8
- package/dist/profiles/semantic-layer/v1/resources/playbooks/core.md +9 -9
- package/dist/profiles/semantic-layer/v1/resources/playbooks/explore.md +4 -3
- package/dist/profiles/test-support/playbook-invariants.d.ts +5 -0
- package/dist/profiles/test-support/playbook-invariants.js +14 -0
- package/dist/profiles/types.d.ts +6 -1
- package/dist/profiles/types.js +1 -1
- package/dist/protocol-contract.test.js +2 -2
- package/dist/server/capabilities.d.ts +2 -2
- package/dist/server/capabilities.js +3 -4
- package/dist/server/capabilities.test.js +4 -5
- package/dist/stdio.process.test.js +114 -193
- package/dist/tools/ai-agents/agents.d.ts +2 -0
- package/dist/tools/ai-agents/agents.js +5 -0
- package/dist/tools/ai-agents/discovery.d.ts +4 -0
- package/dist/tools/ai-agents/discovery.js +7 -0
- package/dist/tools/ai-agents/evaluations.d.ts +9 -0
- package/dist/tools/ai-agents/evaluations.js +12 -0
- package/dist/tools/ai-agents/threads.d.ts +2 -0
- package/dist/tools/ai-agents/threads.js +5 -0
- package/dist/tools/composition/explain-content.d.ts +1 -0
- package/dist/tools/composition/explain-content.js +4 -0
- package/dist/tools/organization/invariants.test.js +7 -3
- package/dist/tools/organization/inventory.d.ts +5 -0
- package/dist/tools/organization/inventory.js +8 -0
- package/dist/tools/organization/roles.d.ts +5 -0
- package/dist/tools/organization/roles.js +8 -0
- package/dist/tools/project/content.d.ts +4 -0
- package/dist/tools/project/content.js +7 -0
- package/dist/tools/project/delete-chart.d.ts +3 -1
- package/dist/tools/project/delete-chart.js +4 -2
- package/dist/tools/project/delete-dashboard.d.ts +3 -1
- package/dist/tools/project/delete-dashboard.js +4 -2
- package/dist/tools/project/developer-content-preview.d.ts +3 -0
- package/dist/tools/project/developer-content-preview.js +6 -0
- package/dist/tools/project/developer-content.d.ts +16 -1
- package/dist/tools/project/developer-content.js +18 -5
- package/dist/tools/project/developer-get-chart-as-code.d.ts +1 -0
- package/dist/tools/project/developer-get-chart-as-code.js +4 -0
- package/dist/tools/project/get-dashboard-promote-diff.d.ts +1 -0
- package/dist/tools/project/get-dashboard-promote-diff.js +4 -0
- package/dist/tools/project/invariants.test.js +6 -18
- package/dist/tools/project/parameters.d.ts +2 -0
- package/dist/tools/project/parameters.js +5 -0
- package/dist/tools/project/projects.d.ts +8 -2
- package/dist/tools/project/projects.js +34 -38
- package/dist/tools/project/projects.test.js +6 -6
- package/dist/tools/project/promote-dashboard.d.ts +3 -1
- package/dist/tools/project/promote-dashboard.js +4 -2
- package/dist/tools/project/reader-content.d.ts +3 -0
- package/dist/tools/project/reader-content.js +6 -0
- package/dist/tools/project/reader-execution.d.ts +2 -0
- package/dist/tools/project/reader-execution.js +5 -0
- package/dist/tools/project/reader-export-chart-image.d.ts +1 -0
- package/dist/tools/project/reader-export-chart-image.js +4 -0
- package/dist/tools/project/schedulers.d.ts +2 -0
- package/dist/tools/project/schedulers.js +5 -0
- package/dist/tools/project/spaces.d.ts +2 -0
- package/dist/tools/project/spaces.js +5 -0
- package/dist/tools/query/lifecycle.d.ts +2 -0
- package/dist/tools/query/lifecycle.js +5 -0
- package/dist/tools/query/run-metric-query.d.ts +1 -0
- package/dist/tools/query/run-metric-query.js +4 -0
- package/dist/tools/registry.d.ts +5 -284
- package/dist/tools/registry.js +9 -137
- package/dist/tools/registry.test.js +36 -0
- package/dist/tools/semantic/explores.d.ts +5 -1
- package/dist/tools/semantic/explores.js +8 -1
- package/dist/tools/semantic/metrics.d.ts +3 -1
- package/dist/tools/semantic/metrics.js +6 -1
- package/dist/tools/semantic/query.d.ts +2 -1
- package/dist/tools/semantic/query.js +11 -3
- package/dist/tools/semantic/query.test.d.ts +4 -0
- package/dist/tools/semantic/query.test.js +134 -0
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +2 -2
- package/dist/tools/space/access.d.ts +2 -0
- package/dist/tools/space/access.js +5 -0
- package/dist/tools/types.d.ts +18 -0
- package/dist/tools/types.js +29 -0
- package/dist/tools/types.test.js +50 -0
- package/package.json +5 -5
- package/dist/index.test.js +0 -9
- package/dist/profiles/profile.membership.test.js +0 -36
- package/dist/tools/index.d.ts +0 -4
- package/dist/tools/index.js +0 -8
- package/dist/tools/index.test.js +0 -78
- /package/dist/{index.test.d.ts → cli-help.test.d.ts} +0 -0
- /package/dist/{profiles/profile.membership.test.d.ts → tools/registry.test.d.ts} +0 -0
- /package/dist/tools/{index.test.d.ts → types.test.d.ts} +0 -0
package/dist/tools/registry.d.ts
CHANGED
|
@@ -1,288 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Wire names are always `lightdash_` + id via registerToolSafe.
|
|
4
|
-
* Profile allowlists must resolve through the operation catalog (ADR-0013).
|
|
2
|
+
* Register profile-mounted ToolModules (orchestration only).
|
|
5
3
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { registerEvaluateAgentReadiness, registerGetAgentModels, registerGetAgentSuggestions, registerGetExploreAccessSummary } from './ai-agents/discovery.js';
|
|
8
|
-
import { registerAppendAgentEvaluationPrompts, registerCreateAgentEvaluation, registerDeleteAgentEvaluation, registerGetAgentEvalRunResults, registerGetAgentEvaluation, registerListAgentEvaluationRuns, registerListAgentEvaluations, registerRunAgentEvaluation, registerUpdateAgentEvaluation } from './ai-agents/evaluations.js';
|
|
9
|
-
import { registerGetAgentThread, registerListAgentThreads } from './ai-agents/threads.js';
|
|
10
|
-
import { registerExplainContent } from './composition/explain-content.js';
|
|
11
|
-
import { registerGetOrgMember, registerGetOrgProfile, registerListOrgGroups, registerListOrgMembers, registerListOrgProjects } from './organization/inventory.js';
|
|
12
|
-
import { registerGetCustomRole, registerListCustomRoles, registerListOrgRoleAssignments, registerListProjectDirectAccess, registerListProjectRoles } from './organization/roles.js';
|
|
13
|
-
import { registerGetDashboardMeta, registerGetProjectUserActivity, registerListContent, registerListValidationResults } from './project/content.js';
|
|
14
|
-
import { registerDeleteChart } from './project/delete-chart.js';
|
|
15
|
-
import { registerDeleteDashboard } from './project/delete-dashboard.js';
|
|
16
|
-
import { registerAddDashboardTile, registerCompareChartVersions, registerCompareDashboardVersions, registerConfirmPreview, registerCreateChart, registerCreateDashboard, registerDuplicateChart, registerDuplicateDashboard, registerMoveContent, registerMoveDashboardTile, registerPreviewChartChanges, registerPreviewContentMove, registerPreviewDashboardChanges, registerRemoveDashboardTile, registerResizeDashboardTile, registerUpdateChart, registerUpdateDashboard, registerValidateChart, registerValidateDashboard } from './project/developer-content.js';
|
|
17
|
-
import { registerGetChartAsCode } from './project/developer-get-chart-as-code.js';
|
|
18
|
-
import { registerGetDashboardPromoteDiff } from './project/get-dashboard-promote-diff.js';
|
|
19
|
-
import { registerGetProjectParameters, registerListProjectParameters } from './project/parameters.js';
|
|
20
|
-
import { registerGetProject, registerListProjects } from './project/projects.js';
|
|
21
|
-
import { registerPromoteDashboard } from './project/promote-dashboard.js';
|
|
22
|
-
import { registerGetChart, registerGetDashboard, registerSearchContent } from './project/reader-content.js';
|
|
23
|
-
import { registerRunChart, registerRunDashboardTile } from './project/reader-execution.js';
|
|
24
|
-
import { registerExportChartImage } from './project/reader-export-chart-image.js';
|
|
25
|
-
import { registerGetScheduler, registerListProjectSchedulers } from './project/schedulers.js';
|
|
26
|
-
import { registerGetSpace, registerListSpaces } from './project/spaces.js';
|
|
27
|
-
import { registerCancelQuery, registerGetQueryResult } from './query/lifecycle.js';
|
|
28
|
-
import { registerRunMetricQuery } from './query/run-metric-query.js';
|
|
29
|
-
import { registerGetExplore, registerGetFieldLineage, registerListDimensions, registerListExplores } from './semantic/explores.js';
|
|
30
|
-
import { registerGetMetric, registerListMetrics } from './semantic/metrics.js';
|
|
31
|
-
import { registerCompileQuery } from './semantic/query.js';
|
|
32
|
-
import { registerListSpaceAccess, registerResolveEffectiveAccess } from './space/access.js';
|
|
4
|
+
import type { ToolModule } from './types.js';
|
|
33
5
|
import type { McpContextProvider } from '../server/request-context.js';
|
|
34
6
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
35
|
-
export type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export declare const toolRegistry: {
|
|
39
|
-
readonly compile_query: {
|
|
40
|
-
readonly register: typeof registerCompileQuery;
|
|
41
|
-
};
|
|
42
|
-
readonly get_explore: {
|
|
43
|
-
readonly register: typeof registerGetExplore;
|
|
44
|
-
};
|
|
45
|
-
readonly get_field_lineage: {
|
|
46
|
-
readonly register: typeof registerGetFieldLineage;
|
|
47
|
-
};
|
|
48
|
-
readonly get_metric: {
|
|
49
|
-
readonly register: typeof registerGetMetric;
|
|
50
|
-
};
|
|
51
|
-
readonly get_project: {
|
|
52
|
-
readonly register: typeof registerGetProject;
|
|
53
|
-
};
|
|
54
|
-
readonly list_dimensions: {
|
|
55
|
-
readonly register: typeof registerListDimensions;
|
|
56
|
-
};
|
|
57
|
-
readonly list_explores: {
|
|
58
|
-
readonly register: typeof registerListExplores;
|
|
59
|
-
};
|
|
60
|
-
readonly list_metrics: {
|
|
61
|
-
readonly register: typeof registerListMetrics;
|
|
62
|
-
};
|
|
63
|
-
readonly list_projects: {
|
|
64
|
-
readonly register: typeof registerListProjects;
|
|
65
|
-
};
|
|
66
|
-
readonly get_org_profile: {
|
|
67
|
-
readonly register: typeof registerGetOrgProfile;
|
|
68
|
-
};
|
|
69
|
-
readonly list_org_members: {
|
|
70
|
-
readonly register: typeof registerListOrgMembers;
|
|
71
|
-
};
|
|
72
|
-
readonly get_org_member: {
|
|
73
|
-
readonly register: typeof registerGetOrgMember;
|
|
74
|
-
};
|
|
75
|
-
readonly list_org_groups: {
|
|
76
|
-
readonly register: typeof registerListOrgGroups;
|
|
77
|
-
};
|
|
78
|
-
readonly list_org_projects: {
|
|
79
|
-
readonly register: typeof registerListOrgProjects;
|
|
80
|
-
};
|
|
81
|
-
readonly list_org_role_assignments: {
|
|
82
|
-
readonly register: typeof registerListOrgRoleAssignments;
|
|
83
|
-
};
|
|
84
|
-
readonly list_custom_roles: {
|
|
85
|
-
readonly register: typeof registerListCustomRoles;
|
|
86
|
-
};
|
|
87
|
-
readonly get_custom_role: {
|
|
88
|
-
readonly register: typeof registerGetCustomRole;
|
|
89
|
-
};
|
|
90
|
-
readonly list_project_roles: {
|
|
91
|
-
readonly register: typeof registerListProjectRoles;
|
|
92
|
-
};
|
|
93
|
-
readonly list_project_direct_access: {
|
|
94
|
-
readonly register: typeof registerListProjectDirectAccess;
|
|
95
|
-
};
|
|
96
|
-
readonly list_space_access: {
|
|
97
|
-
readonly register: typeof registerListSpaceAccess;
|
|
98
|
-
};
|
|
99
|
-
readonly resolve_effective_access: {
|
|
100
|
-
readonly register: typeof registerResolveEffectiveAccess;
|
|
101
|
-
};
|
|
102
|
-
readonly list_content: {
|
|
103
|
-
readonly register: typeof registerListContent;
|
|
104
|
-
};
|
|
105
|
-
readonly get_dashboard_meta: {
|
|
106
|
-
readonly register: typeof registerGetDashboardMeta;
|
|
107
|
-
};
|
|
108
|
-
readonly list_validation_results: {
|
|
109
|
-
readonly register: typeof registerListValidationResults;
|
|
110
|
-
};
|
|
111
|
-
readonly get_project_user_activity: {
|
|
112
|
-
readonly register: typeof registerGetProjectUserActivity;
|
|
113
|
-
};
|
|
114
|
-
readonly list_project_schedulers: {
|
|
115
|
-
readonly register: typeof registerListProjectSchedulers;
|
|
116
|
-
};
|
|
117
|
-
readonly get_scheduler: {
|
|
118
|
-
readonly register: typeof registerGetScheduler;
|
|
119
|
-
};
|
|
120
|
-
readonly search_content: {
|
|
121
|
-
readonly register: typeof registerSearchContent;
|
|
122
|
-
};
|
|
123
|
-
readonly list_spaces: {
|
|
124
|
-
readonly register: typeof registerListSpaces;
|
|
125
|
-
};
|
|
126
|
-
readonly get_space: {
|
|
127
|
-
readonly register: typeof registerGetSpace;
|
|
128
|
-
};
|
|
129
|
-
readonly get_dashboard: {
|
|
130
|
-
readonly register: typeof registerGetDashboard;
|
|
131
|
-
};
|
|
132
|
-
readonly get_chart: {
|
|
133
|
-
readonly register: typeof registerGetChart;
|
|
134
|
-
};
|
|
135
|
-
readonly list_project_parameters: {
|
|
136
|
-
readonly register: typeof registerListProjectParameters;
|
|
137
|
-
};
|
|
138
|
-
readonly get_project_parameters: {
|
|
139
|
-
readonly register: typeof registerGetProjectParameters;
|
|
140
|
-
};
|
|
141
|
-
readonly explain_content: {
|
|
142
|
-
readonly register: typeof registerExplainContent;
|
|
143
|
-
};
|
|
144
|
-
readonly run_chart: {
|
|
145
|
-
readonly register: typeof registerRunChart;
|
|
146
|
-
};
|
|
147
|
-
readonly export_chart_image: {
|
|
148
|
-
readonly register: typeof registerExportChartImage;
|
|
149
|
-
};
|
|
150
|
-
readonly run_dashboard_tile: {
|
|
151
|
-
readonly register: typeof registerRunDashboardTile;
|
|
152
|
-
};
|
|
153
|
-
readonly get_query_result: {
|
|
154
|
-
readonly register: typeof registerGetQueryResult;
|
|
155
|
-
};
|
|
156
|
-
readonly cancel_query: {
|
|
157
|
-
readonly register: typeof registerCancelQuery;
|
|
158
|
-
};
|
|
159
|
-
readonly run_metric_query: {
|
|
160
|
-
readonly register: typeof registerRunMetricQuery;
|
|
161
|
-
};
|
|
162
|
-
readonly get_chart_as_code: {
|
|
163
|
-
readonly register: typeof registerGetChartAsCode;
|
|
164
|
-
};
|
|
165
|
-
readonly preview_chart_changes: {
|
|
166
|
-
readonly register: typeof registerPreviewChartChanges;
|
|
167
|
-
};
|
|
168
|
-
readonly preview_dashboard_changes: {
|
|
169
|
-
readonly register: typeof registerPreviewDashboardChanges;
|
|
170
|
-
};
|
|
171
|
-
readonly preview_content_move: {
|
|
172
|
-
readonly register: typeof registerPreviewContentMove;
|
|
173
|
-
};
|
|
174
|
-
readonly validate_chart: {
|
|
175
|
-
readonly register: typeof registerValidateChart;
|
|
176
|
-
};
|
|
177
|
-
readonly validate_dashboard: {
|
|
178
|
-
readonly register: typeof registerValidateDashboard;
|
|
179
|
-
};
|
|
180
|
-
readonly confirm_preview: {
|
|
181
|
-
readonly register: typeof registerConfirmPreview;
|
|
182
|
-
};
|
|
183
|
-
readonly compare_chart_versions: {
|
|
184
|
-
readonly register: typeof registerCompareChartVersions;
|
|
185
|
-
};
|
|
186
|
-
readonly compare_dashboard_versions: {
|
|
187
|
-
readonly register: typeof registerCompareDashboardVersions;
|
|
188
|
-
};
|
|
189
|
-
readonly create_chart: {
|
|
190
|
-
readonly register: typeof registerCreateChart;
|
|
191
|
-
};
|
|
192
|
-
readonly update_chart: {
|
|
193
|
-
readonly register: typeof registerUpdateChart;
|
|
194
|
-
};
|
|
195
|
-
readonly duplicate_chart: {
|
|
196
|
-
readonly register: typeof registerDuplicateChart;
|
|
197
|
-
};
|
|
198
|
-
readonly create_dashboard: {
|
|
199
|
-
readonly register: typeof registerCreateDashboard;
|
|
200
|
-
};
|
|
201
|
-
readonly update_dashboard: {
|
|
202
|
-
readonly register: typeof registerUpdateDashboard;
|
|
203
|
-
};
|
|
204
|
-
readonly duplicate_dashboard: {
|
|
205
|
-
readonly register: typeof registerDuplicateDashboard;
|
|
206
|
-
};
|
|
207
|
-
readonly add_dashboard_tile: {
|
|
208
|
-
readonly register: typeof registerAddDashboardTile;
|
|
209
|
-
};
|
|
210
|
-
readonly move_dashboard_tile: {
|
|
211
|
-
readonly register: typeof registerMoveDashboardTile;
|
|
212
|
-
};
|
|
213
|
-
readonly remove_dashboard_tile: {
|
|
214
|
-
readonly register: typeof registerRemoveDashboardTile;
|
|
215
|
-
};
|
|
216
|
-
readonly resize_dashboard_tile: {
|
|
217
|
-
readonly register: typeof registerResizeDashboardTile;
|
|
218
|
-
};
|
|
219
|
-
readonly move_content: {
|
|
220
|
-
readonly register: typeof registerMoveContent;
|
|
221
|
-
};
|
|
222
|
-
readonly delete_chart: {
|
|
223
|
-
readonly register: typeof registerDeleteChart;
|
|
224
|
-
};
|
|
225
|
-
readonly delete_dashboard: {
|
|
226
|
-
readonly register: typeof registerDeleteDashboard;
|
|
227
|
-
};
|
|
228
|
-
readonly get_dashboard_promote_diff: {
|
|
229
|
-
readonly register: typeof registerGetDashboardPromoteDiff;
|
|
230
|
-
};
|
|
231
|
-
readonly promote_dashboard: {
|
|
232
|
-
readonly register: typeof registerPromoteDashboard;
|
|
233
|
-
};
|
|
234
|
-
readonly list_project_agents: {
|
|
235
|
-
readonly register: typeof registerListProjectAgents;
|
|
236
|
-
};
|
|
237
|
-
readonly get_project_agent: {
|
|
238
|
-
readonly register: typeof registerGetProjectAgent;
|
|
239
|
-
};
|
|
240
|
-
readonly evaluate_agent_readiness: {
|
|
241
|
-
readonly register: typeof registerEvaluateAgentReadiness;
|
|
242
|
-
};
|
|
243
|
-
readonly get_agent_suggestions: {
|
|
244
|
-
readonly register: typeof registerGetAgentSuggestions;
|
|
245
|
-
};
|
|
246
|
-
readonly get_agent_models: {
|
|
247
|
-
readonly register: typeof registerGetAgentModels;
|
|
248
|
-
};
|
|
249
|
-
readonly get_explore_access_summary: {
|
|
250
|
-
readonly register: typeof registerGetExploreAccessSummary;
|
|
251
|
-
};
|
|
252
|
-
readonly list_agent_threads: {
|
|
253
|
-
readonly register: typeof registerListAgentThreads;
|
|
254
|
-
};
|
|
255
|
-
readonly get_agent_thread: {
|
|
256
|
-
readonly register: typeof registerGetAgentThread;
|
|
257
|
-
};
|
|
258
|
-
readonly list_agent_evaluations: {
|
|
259
|
-
readonly register: typeof registerListAgentEvaluations;
|
|
260
|
-
};
|
|
261
|
-
readonly get_agent_evaluation: {
|
|
262
|
-
readonly register: typeof registerGetAgentEvaluation;
|
|
263
|
-
};
|
|
264
|
-
readonly create_agent_evaluation: {
|
|
265
|
-
readonly register: typeof registerCreateAgentEvaluation;
|
|
266
|
-
};
|
|
267
|
-
readonly update_agent_evaluation: {
|
|
268
|
-
readonly register: typeof registerUpdateAgentEvaluation;
|
|
269
|
-
};
|
|
270
|
-
readonly append_agent_evaluation_prompts: {
|
|
271
|
-
readonly register: typeof registerAppendAgentEvaluationPrompts;
|
|
272
|
-
};
|
|
273
|
-
readonly delete_agent_evaluation: {
|
|
274
|
-
readonly register: typeof registerDeleteAgentEvaluation;
|
|
275
|
-
};
|
|
276
|
-
readonly run_agent_evaluation: {
|
|
277
|
-
readonly register: typeof registerRunAgentEvaluation;
|
|
278
|
-
};
|
|
279
|
-
readonly list_agent_evaluation_runs: {
|
|
280
|
-
readonly register: typeof registerListAgentEvaluationRuns;
|
|
281
|
-
};
|
|
282
|
-
readonly get_agent_eval_run_results: {
|
|
283
|
-
readonly register: typeof registerGetAgentEvalRunResults;
|
|
284
|
-
};
|
|
285
|
-
};
|
|
286
|
-
export type ToolId = keyof typeof toolRegistry;
|
|
287
|
-
/** Register a subset of tools by id (catalog membership, ADR-0006). */
|
|
288
|
-
export declare function registerToolsByIds(server: McpServer, contextProvider: McpContextProvider, ids: readonly string[]): void;
|
|
7
|
+
export type { ToolModule } from './types.js';
|
|
8
|
+
/** Register profile-mounted tool modules (deterministic order = array order). */
|
|
9
|
+
export declare function registerTools(server: McpServer, contextProvider: McpContextProvider, tools: readonly ToolModule[]): void;
|
package/dist/tools/registry.js
CHANGED
|
@@ -1,145 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* Wire names are always `lightdash_` + id via registerToolSafe.
|
|
5
|
-
* Profile allowlists must resolve through the operation catalog (ADR-0013).
|
|
3
|
+
* Register profile-mounted ToolModules (orchestration only).
|
|
6
4
|
*/
|
|
7
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
9
|
-
exports.registerToolsByIds = registerToolsByIds;
|
|
6
|
+
exports.registerTools = registerTools;
|
|
10
7
|
const common_1 = require("@lightdash-tools/common");
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const roles_js_1 = require("./organization/roles.js");
|
|
18
|
-
const content_js_1 = require("./project/content.js");
|
|
19
|
-
const delete_chart_js_1 = require("./project/delete-chart.js");
|
|
20
|
-
const delete_dashboard_js_1 = require("./project/delete-dashboard.js");
|
|
21
|
-
const developer_content_js_1 = require("./project/developer-content.js");
|
|
22
|
-
const developer_get_chart_as_code_js_1 = require("./project/developer-get-chart-as-code.js");
|
|
23
|
-
const get_dashboard_promote_diff_js_1 = require("./project/get-dashboard-promote-diff.js");
|
|
24
|
-
const parameters_js_1 = require("./project/parameters.js");
|
|
25
|
-
const projects_js_1 = require("./project/projects.js");
|
|
26
|
-
const promote_dashboard_js_1 = require("./project/promote-dashboard.js");
|
|
27
|
-
const reader_content_js_1 = require("./project/reader-content.js");
|
|
28
|
-
const reader_execution_js_1 = require("./project/reader-execution.js");
|
|
29
|
-
const reader_export_chart_image_js_1 = require("./project/reader-export-chart-image.js");
|
|
30
|
-
const schedulers_js_1 = require("./project/schedulers.js");
|
|
31
|
-
const spaces_js_1 = require("./project/spaces.js");
|
|
32
|
-
const lifecycle_js_1 = require("./query/lifecycle.js");
|
|
33
|
-
const run_metric_query_js_1 = require("./query/run-metric-query.js");
|
|
34
|
-
const explores_js_1 = require("./semantic/explores.js");
|
|
35
|
-
const metrics_js_1 = require("./semantic/metrics.js");
|
|
36
|
-
const query_js_1 = require("./semantic/query.js");
|
|
37
|
-
const access_js_1 = require("./space/access.js");
|
|
38
|
-
exports.toolRegistry = {
|
|
39
|
-
// semantic-layer
|
|
40
|
-
compile_query: { register: query_js_1.registerCompileQuery },
|
|
41
|
-
get_explore: { register: explores_js_1.registerGetExplore },
|
|
42
|
-
get_field_lineage: { register: explores_js_1.registerGetFieldLineage },
|
|
43
|
-
get_metric: { register: metrics_js_1.registerGetMetric },
|
|
44
|
-
get_project: { register: projects_js_1.registerGetProject },
|
|
45
|
-
list_dimensions: { register: explores_js_1.registerListDimensions },
|
|
46
|
-
list_explores: { register: explores_js_1.registerListExplores },
|
|
47
|
-
list_metrics: { register: metrics_js_1.registerListMetrics },
|
|
48
|
-
list_projects: { register: projects_js_1.registerListProjects },
|
|
49
|
-
// organization inventory / access / content / delivery (shared; profile membership selects)
|
|
50
|
-
get_org_profile: { register: inventory_js_1.registerGetOrgProfile },
|
|
51
|
-
list_org_members: { register: inventory_js_1.registerListOrgMembers },
|
|
52
|
-
get_org_member: { register: inventory_js_1.registerGetOrgMember },
|
|
53
|
-
list_org_groups: { register: inventory_js_1.registerListOrgGroups },
|
|
54
|
-
list_org_projects: { register: inventory_js_1.registerListOrgProjects },
|
|
55
|
-
list_org_role_assignments: { register: roles_js_1.registerListOrgRoleAssignments },
|
|
56
|
-
list_custom_roles: { register: roles_js_1.registerListCustomRoles },
|
|
57
|
-
get_custom_role: { register: roles_js_1.registerGetCustomRole },
|
|
58
|
-
list_project_roles: { register: roles_js_1.registerListProjectRoles },
|
|
59
|
-
list_project_direct_access: { register: roles_js_1.registerListProjectDirectAccess },
|
|
60
|
-
list_space_access: { register: access_js_1.registerListSpaceAccess },
|
|
61
|
-
resolve_effective_access: { register: access_js_1.registerResolveEffectiveAccess },
|
|
62
|
-
list_content: { register: content_js_1.registerListContent },
|
|
63
|
-
get_dashboard_meta: { register: content_js_1.registerGetDashboardMeta },
|
|
64
|
-
list_validation_results: { register: content_js_1.registerListValidationResults },
|
|
65
|
-
get_project_user_activity: { register: content_js_1.registerGetProjectUserActivity },
|
|
66
|
-
list_project_schedulers: { register: schedulers_js_1.registerListProjectSchedulers },
|
|
67
|
-
get_scheduler: { register: schedulers_js_1.registerGetScheduler },
|
|
68
|
-
// content-reader
|
|
69
|
-
search_content: { register: reader_content_js_1.registerSearchContent },
|
|
70
|
-
list_spaces: { register: spaces_js_1.registerListSpaces },
|
|
71
|
-
get_space: { register: spaces_js_1.registerGetSpace },
|
|
72
|
-
get_dashboard: { register: reader_content_js_1.registerGetDashboard },
|
|
73
|
-
get_chart: { register: reader_content_js_1.registerGetChart },
|
|
74
|
-
list_project_parameters: { register: parameters_js_1.registerListProjectParameters },
|
|
75
|
-
get_project_parameters: { register: parameters_js_1.registerGetProjectParameters },
|
|
76
|
-
explain_content: { register: explain_content_js_1.registerExplainContent },
|
|
77
|
-
run_chart: { register: reader_execution_js_1.registerRunChart },
|
|
78
|
-
export_chart_image: { register: reader_export_chart_image_js_1.registerExportChartImage },
|
|
79
|
-
run_dashboard_tile: { register: reader_execution_js_1.registerRunDashboardTile },
|
|
80
|
-
get_query_result: { register: lifecycle_js_1.registerGetQueryResult },
|
|
81
|
-
cancel_query: { register: lifecycle_js_1.registerCancelQuery },
|
|
82
|
-
run_metric_query: { register: run_metric_query_js_1.registerRunMetricQuery },
|
|
83
|
-
// content-developer (ADR-0014)
|
|
84
|
-
get_chart_as_code: { register: developer_get_chart_as_code_js_1.registerGetChartAsCode },
|
|
85
|
-
preview_chart_changes: { register: developer_content_js_1.registerPreviewChartChanges },
|
|
86
|
-
preview_dashboard_changes: { register: developer_content_js_1.registerPreviewDashboardChanges },
|
|
87
|
-
preview_content_move: { register: developer_content_js_1.registerPreviewContentMove },
|
|
88
|
-
validate_chart: { register: developer_content_js_1.registerValidateChart },
|
|
89
|
-
validate_dashboard: { register: developer_content_js_1.registerValidateDashboard },
|
|
90
|
-
confirm_preview: { register: developer_content_js_1.registerConfirmPreview },
|
|
91
|
-
compare_chart_versions: { register: developer_content_js_1.registerCompareChartVersions },
|
|
92
|
-
compare_dashboard_versions: { register: developer_content_js_1.registerCompareDashboardVersions },
|
|
93
|
-
create_chart: { register: developer_content_js_1.registerCreateChart },
|
|
94
|
-
update_chart: { register: developer_content_js_1.registerUpdateChart },
|
|
95
|
-
duplicate_chart: { register: developer_content_js_1.registerDuplicateChart },
|
|
96
|
-
create_dashboard: { register: developer_content_js_1.registerCreateDashboard },
|
|
97
|
-
update_dashboard: { register: developer_content_js_1.registerUpdateDashboard },
|
|
98
|
-
duplicate_dashboard: { register: developer_content_js_1.registerDuplicateDashboard },
|
|
99
|
-
add_dashboard_tile: { register: developer_content_js_1.registerAddDashboardTile },
|
|
100
|
-
move_dashboard_tile: { register: developer_content_js_1.registerMoveDashboardTile },
|
|
101
|
-
remove_dashboard_tile: { register: developer_content_js_1.registerRemoveDashboardTile },
|
|
102
|
-
resize_dashboard_tile: { register: developer_content_js_1.registerResizeDashboardTile },
|
|
103
|
-
move_content: { register: developer_content_js_1.registerMoveContent },
|
|
104
|
-
// content-governance (ADR-0015 / ADR-0017)
|
|
105
|
-
delete_chart: { register: delete_chart_js_1.registerDeleteChart },
|
|
106
|
-
delete_dashboard: { register: delete_dashboard_js_1.registerDeleteDashboard },
|
|
107
|
-
get_dashboard_promote_diff: { register: get_dashboard_promote_diff_js_1.registerGetDashboardPromoteDiff },
|
|
108
|
-
promote_dashboard: { register: promote_dashboard_js_1.registerPromoteDashboard },
|
|
109
|
-
// ai-agent-ops (ADR-0018)
|
|
110
|
-
list_project_agents: { register: agents_js_1.registerListProjectAgents },
|
|
111
|
-
get_project_agent: { register: agents_js_1.registerGetProjectAgent },
|
|
112
|
-
evaluate_agent_readiness: { register: discovery_js_1.registerEvaluateAgentReadiness },
|
|
113
|
-
get_agent_suggestions: { register: discovery_js_1.registerGetAgentSuggestions },
|
|
114
|
-
get_agent_models: { register: discovery_js_1.registerGetAgentModels },
|
|
115
|
-
get_explore_access_summary: { register: discovery_js_1.registerGetExploreAccessSummary },
|
|
116
|
-
list_agent_threads: { register: threads_js_1.registerListAgentThreads },
|
|
117
|
-
get_agent_thread: { register: threads_js_1.registerGetAgentThread },
|
|
118
|
-
list_agent_evaluations: { register: evaluations_js_1.registerListAgentEvaluations },
|
|
119
|
-
get_agent_evaluation: { register: evaluations_js_1.registerGetAgentEvaluation },
|
|
120
|
-
create_agent_evaluation: { register: evaluations_js_1.registerCreateAgentEvaluation },
|
|
121
|
-
update_agent_evaluation: { register: evaluations_js_1.registerUpdateAgentEvaluation },
|
|
122
|
-
append_agent_evaluation_prompts: { register: evaluations_js_1.registerAppendAgentEvaluationPrompts },
|
|
123
|
-
delete_agent_evaluation: { register: evaluations_js_1.registerDeleteAgentEvaluation },
|
|
124
|
-
run_agent_evaluation: { register: evaluations_js_1.registerRunAgentEvaluation },
|
|
125
|
-
list_agent_evaluation_runs: { register: evaluations_js_1.registerListAgentEvaluationRuns },
|
|
126
|
-
get_agent_eval_run_results: { register: evaluations_js_1.registerGetAgentEvalRunResults },
|
|
127
|
-
};
|
|
128
|
-
const BANNED_MCP_TOOL_IDS = new Set((0, common_1.listBannedMcpToolNames)());
|
|
129
|
-
/** Register a subset of tools by id (catalog membership, ADR-0006). */
|
|
130
|
-
function registerToolsByIds(server, contextProvider, ids) {
|
|
131
|
-
var _a;
|
|
132
|
-
for (const id of ids) {
|
|
133
|
-
if (BANNED_MCP_TOOL_IDS.has(id)) {
|
|
134
|
-
throw new Error(`MCP tool id '${id}' is banned (client-only / irrecoverable)`);
|
|
8
|
+
const BANNED_MCP_TOOL_IDS = new Set(common_1.IRRECOVERABLE_TOOL_DENYLIST);
|
|
9
|
+
/** Register profile-mounted tool modules (deterministic order = array order). */
|
|
10
|
+
function registerTools(server, contextProvider, tools) {
|
|
11
|
+
for (const tool of tools) {
|
|
12
|
+
if (BANNED_MCP_TOOL_IDS.has(tool.id)) {
|
|
13
|
+
throw new Error(`MCP tool id '${tool.id}' is banned (client-only / irrecoverable)`);
|
|
135
14
|
}
|
|
136
|
-
|
|
137
|
-
if (((_a = catalogOp === null || catalogOp === void 0 ? void 0 : catalogOp.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed) !== true) {
|
|
138
|
-
throw new Error(`MCP tool id '${id}' is not an exposed operation in the catalog (ADR-0013)`);
|
|
139
|
-
}
|
|
140
|
-
if (!(id in exports.toolRegistry)) {
|
|
141
|
-
throw new Error(`MCP tool id '${id}' is not registered in the tool registry`);
|
|
142
|
-
}
|
|
143
|
-
exports.toolRegistry[id].register(server, contextProvider);
|
|
15
|
+
tool.register(server, contextProvider);
|
|
144
16
|
}
|
|
145
17
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const server_profile_js_1 = require("../audit/server-profile.js");
|
|
5
|
+
const index_js_1 = require("../profiles/index.js");
|
|
6
|
+
const registry_js_1 = require("./registry.js");
|
|
7
|
+
const shared_js_1 = require("./shared.js");
|
|
8
|
+
vitest_1.vi.mock('@lightdash-tools/common', async (importOriginal) => {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
const actual = await importOriginal();
|
|
11
|
+
return Object.assign(Object.assign({}, actual), { getSessionId: () => 'test-session', logAuditEntry: vitest_1.vi.fn(), initAuditLog: vitest_1.vi.fn() });
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.describe)('registerTools', () => {
|
|
14
|
+
const registeredTools = [];
|
|
15
|
+
const mockServer = {
|
|
16
|
+
registerTool: vitest_1.vi.fn((name, options) => {
|
|
17
|
+
registeredTools.push({ name, description: options.description });
|
|
18
|
+
}),
|
|
19
|
+
registerResource: vitest_1.vi.fn(),
|
|
20
|
+
};
|
|
21
|
+
(0, vitest_1.beforeEach)(() => {
|
|
22
|
+
registeredTools.length = 0;
|
|
23
|
+
mockServer.registerTool.mockClear();
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.it)('registers only the profile tools with lightdash_ prefix', () => {
|
|
26
|
+
const mockContextProvider = { getContext: async () => ({ lightdashClient: {} }) };
|
|
27
|
+
const profile = (0, index_js_1.getDefaultProfile)();
|
|
28
|
+
const toolIds = (0, index_js_1.listToolIds)(profile);
|
|
29
|
+
(0, server_profile_js_1.bindServerProfile)(mockServer, profile.id);
|
|
30
|
+
(0, registry_js_1.registerTools)(mockServer, mockContextProvider, profile.tools);
|
|
31
|
+
(0, vitest_1.expect)(registeredTools).toHaveLength(toolIds.length);
|
|
32
|
+
(0, vitest_1.expect)(registeredTools.every((t) => t.name.startsWith(shared_js_1.TOOL_PREFIX))).toBe(true);
|
|
33
|
+
const names = registeredTools.map((t) => t.name);
|
|
34
|
+
(0, vitest_1.expect)(names).toEqual(toolIds.map((id) => `${shared_js_1.TOOL_PREFIX}${id}`));
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP tools: explores (list, get, dimensions, lineage)
|
|
2
|
+
* MCP tools: explores (list, get, dimensions, lineage).
|
|
3
3
|
*/
|
|
4
4
|
import type { McpContextProvider } from '../../server/request-context.js';
|
|
5
5
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
@@ -7,3 +7,7 @@ export declare function registerListExplores(server: McpServer, contextProvider:
|
|
|
7
7
|
export declare function registerGetExplore(server: McpServer, contextProvider: McpContextProvider): void;
|
|
8
8
|
export declare function registerListDimensions(server: McpServer, contextProvider: McpContextProvider): void;
|
|
9
9
|
export declare function registerGetFieldLineage(server: McpServer, contextProvider: McpContextProvider): void;
|
|
10
|
+
export declare const listExploresTool: import("../types.js").ToolModule;
|
|
11
|
+
export declare const getExploreTool: import("../types.js").ToolModule;
|
|
12
|
+
export declare const listDimensionsTool: import("../types.js").ToolModule;
|
|
13
|
+
export declare const getFieldLineageTool: import("../types.js").ToolModule;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* MCP tools: explores (list, get, dimensions, lineage)
|
|
3
|
+
* MCP tools: explores (list, get, dimensions, lineage).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getFieldLineageTool = exports.listDimensionsTool = exports.getExploreTool = exports.listExploresTool = void 0;
|
|
6
7
|
exports.registerListExplores = registerListExplores;
|
|
7
8
|
exports.registerGetExplore = registerGetExplore;
|
|
8
9
|
exports.registerListDimensions = registerListDimensions;
|
|
@@ -12,6 +13,7 @@ const project_scope_js_1 = require("../../governance/project-scope.js");
|
|
|
12
13
|
const schema_fields_js_1 = require("../lib/schema-fields.js");
|
|
13
14
|
const reader_tool_helpers_js_1 = require("../query/reader-tool-helpers.js");
|
|
14
15
|
const shared_js_1 = require("../shared.js");
|
|
16
|
+
const types_js_1 = require("../types.js");
|
|
15
17
|
const explore_helpers_js_1 = require("./explore-helpers.js");
|
|
16
18
|
const schema_fields_js_2 = require("./schema-fields.js");
|
|
17
19
|
function registerListExplores(server, contextProvider) {
|
|
@@ -104,3 +106,8 @@ function registerGetFieldLineage(server, contextProvider) {
|
|
|
104
106
|
}
|
|
105
107
|
}));
|
|
106
108
|
}
|
|
109
|
+
// ToolModule exports (profile mounts)
|
|
110
|
+
exports.listExploresTool = (0, types_js_1.defineTool)('list_explores', registerListExplores);
|
|
111
|
+
exports.getExploreTool = (0, types_js_1.defineTool)('get_explore', registerGetExplore);
|
|
112
|
+
exports.listDimensionsTool = (0, types_js_1.defineTool)('list_dimensions', registerListDimensions);
|
|
113
|
+
exports.getFieldLineageTool = (0, types_js_1.defineTool)('get_field_lineage', registerGetFieldLineage);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP tools: metrics (list, get)
|
|
2
|
+
* MCP tools: metrics (list, get).
|
|
3
3
|
*/
|
|
4
4
|
import type { McpContextProvider } from '../../server/request-context.js';
|
|
5
5
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
export declare function registerListMetrics(server: McpServer, contextProvider: McpContextProvider): void;
|
|
7
7
|
export declare function registerGetMetric(server: McpServer, contextProvider: McpContextProvider): void;
|
|
8
|
+
export declare const listMetricsTool: import("../types.js").ToolModule;
|
|
9
|
+
export declare const getMetricTool: import("../types.js").ToolModule;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* MCP tools: metrics (list, get)
|
|
3
|
+
* MCP tools: metrics (list, get).
|
|
4
4
|
*/
|
|
5
5
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
6
6
|
var t = {};
|
|
@@ -14,6 +14,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
14
14
|
return t;
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.getMetricTool = exports.listMetricsTool = void 0;
|
|
17
18
|
exports.registerListMetrics = registerListMetrics;
|
|
18
19
|
exports.registerGetMetric = registerGetMetric;
|
|
19
20
|
const zod_1 = require("zod");
|
|
@@ -21,6 +22,7 @@ const project_scope_js_1 = require("../../governance/project-scope.js");
|
|
|
21
22
|
const schema_fields_js_1 = require("../lib/schema-fields.js");
|
|
22
23
|
const reader_tool_helpers_js_1 = require("../query/reader-tool-helpers.js");
|
|
23
24
|
const shared_js_1 = require("../shared.js");
|
|
25
|
+
const types_js_1 = require("../types.js");
|
|
24
26
|
function registerListMetrics(server, contextProvider) {
|
|
25
27
|
(0, shared_js_1.registerToolSafe)(server, 'list_metrics', {
|
|
26
28
|
title: 'List metrics',
|
|
@@ -65,3 +67,6 @@ function registerGetMetric(server, contextProvider) {
|
|
|
65
67
|
}
|
|
66
68
|
}));
|
|
67
69
|
}
|
|
70
|
+
// ToolModule exports (profile mounts)
|
|
71
|
+
exports.listMetricsTool = (0, types_js_1.defineTool)('list_metrics', registerListMetrics);
|
|
72
|
+
exports.getMetricTool = (0, types_js_1.defineTool)('get_metric', registerGetMetric);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP tools: query (compile only)
|
|
2
|
+
* MCP tools: query (compile only).
|
|
3
3
|
*/
|
|
4
4
|
import type { McpContextProvider } from '../../server/request-context.js';
|
|
5
5
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
6
|
export declare function registerCompileQuery(server: McpServer, contextProvider: McpContextProvider): void;
|
|
7
|
+
export declare const compileQueryTool: import("../types.js").ToolModule;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* MCP tools: query (compile only)
|
|
3
|
+
* MCP tools: query (compile only).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.compileQueryTool = void 0;
|
|
6
7
|
exports.registerCompileQuery = registerCompileQuery;
|
|
7
8
|
const zod_1 = require("zod");
|
|
8
9
|
const project_scope_js_1 = require("../../governance/project-scope.js");
|
|
9
10
|
const schema_fields_js_1 = require("../lib/schema-fields.js");
|
|
10
11
|
const reader_tool_helpers_js_1 = require("../query/reader-tool-helpers.js");
|
|
11
12
|
const shared_js_1 = require("../shared.js");
|
|
13
|
+
const types_js_1 = require("../types.js");
|
|
12
14
|
const explore_helpers_js_1 = require("./explore-helpers.js");
|
|
13
15
|
const schema_fields_js_2 = require("./schema-fields.js");
|
|
14
16
|
function registerCompileQuery(server, contextProvider) {
|
|
15
17
|
(0, shared_js_1.registerToolSafe)(server, 'compile_query', {
|
|
16
18
|
title: 'Compile query',
|
|
17
|
-
description: 'Compile a metric query for an explore without executing it. Empty SELECT (no columns) is returned as an error — use fieldId `{table}_{name}`, not short names. projectUuid optional when X-Lightdash-Project is set.',
|
|
19
|
+
description: 'Compile a metric query for an explore without executing it. Sets metricQuery.exploreName from exploreId (authoritative) and defaults missing tableCalculations to []. Empty SELECT (no columns) is returned as an error — use fieldId `{table}_{name}`, not short names. projectUuid optional when X-Lightdash-Project is set.',
|
|
18
20
|
inputSchema: {
|
|
19
21
|
projectUuid: (0, schema_fields_js_1.optionalProjectUuidField)(),
|
|
20
22
|
exploreId: (0, schema_fields_js_2.exploreIdField)(),
|
|
@@ -26,7 +28,11 @@ function registerCompileQuery(server, contextProvider) {
|
|
|
26
28
|
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async ({ projectUuid, exploreId, metricQuery, }) => {
|
|
27
29
|
try {
|
|
28
30
|
const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid });
|
|
29
|
-
|
|
31
|
+
// Path exploreId is authoritative; OpenAPI MetricQuery requires exploreName + tableCalculations.
|
|
32
|
+
const body = Object.assign(Object.assign({}, metricQuery), { tableCalculations: Array.isArray(metricQuery.tableCalculations)
|
|
33
|
+
? metricQuery.tableCalculations
|
|
34
|
+
: [], exploreName: exploreId });
|
|
35
|
+
const result = await c.v1.query.compileQuery(scope.projectUuid, exploreId, body);
|
|
30
36
|
const sql = (0, explore_helpers_js_1.extractCompiledSql)(result);
|
|
31
37
|
if (sql && (0, explore_helpers_js_1.isEmptySelectSql)(sql)) {
|
|
32
38
|
return {
|
|
@@ -48,3 +54,5 @@ function registerCompileQuery(server, contextProvider) {
|
|
|
48
54
|
}
|
|
49
55
|
}));
|
|
50
56
|
}
|
|
57
|
+
// ToolModule exports (profile mounts)
|
|
58
|
+
exports.compileQueryTool = (0, types_js_1.defineTool)('compile_query', registerCompileQuery);
|