@lightdash-tools/mcp 0.6.0 → 0.7.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.
Files changed (271) hide show
  1. package/README.md +133 -58
  2. package/dist/audit/audit.d.ts +5 -0
  3. package/dist/{audit.js → audit/audit.js} +1 -2
  4. package/dist/audit/tool-audit-context.d.ts +6 -0
  5. package/dist/audit/tool-audit-context.js +12 -0
  6. package/dist/audit/tool-audit-context.test.d.ts +1 -0
  7. package/dist/audit/tool-audit-context.test.js +19 -0
  8. package/dist/auth/auth-mode.d.ts +4 -0
  9. package/dist/auth/auth-mode.js +6 -0
  10. package/dist/auth/bearer.d.ts +3 -0
  11. package/dist/auth/bearer.js +13 -0
  12. package/dist/auth/lightdash-oauth-upstream-contract.d.ts +22 -0
  13. package/dist/auth/lightdash-oauth-upstream-contract.js +36 -0
  14. package/dist/auth/lightdash-oauth-upstream-contract.test.d.ts +1 -0
  15. package/dist/auth/lightdash-oauth-upstream-contract.test.js +56 -0
  16. package/dist/auth/oauth-broker/as-metadata.d.ts +14 -0
  17. package/dist/auth/oauth-broker/as-metadata.js +20 -0
  18. package/dist/auth/oauth-broker/lightdash-token.d.ts +20 -0
  19. package/dist/auth/oauth-broker/lightdash-token.js +76 -0
  20. package/dist/auth/oauth-broker/pending-store.d.ts +76 -0
  21. package/dist/auth/oauth-broker/pending-store.js +124 -0
  22. package/dist/auth/oauth-broker/pkce.d.ts +2 -0
  23. package/dist/auth/oauth-broker/pkce.js +17 -0
  24. package/dist/auth/oauth-broker/routes.d.ts +9 -0
  25. package/dist/auth/oauth-broker/routes.js +447 -0
  26. package/dist/auth/oauth-broker/routes.test.d.ts +1 -0
  27. package/dist/auth/oauth-broker/routes.test.js +237 -0
  28. package/dist/auth/providers/bearer-context-provider.d.ts +24 -0
  29. package/dist/auth/providers/bearer-context-provider.js +52 -0
  30. package/dist/auth/providers/env-context-provider.d.ts +13 -0
  31. package/dist/auth/providers/env-context-provider.js +19 -0
  32. package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +23 -0
  33. package/dist/auth/resource-server/lightdash-oauth-middleware.js +115 -0
  34. package/dist/auth/resource-server/lightdash-oauth-middleware.test.d.ts +1 -0
  35. package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +202 -0
  36. package/dist/auth/resource-server/lightdash-token-validation.d.ts +14 -0
  37. package/dist/auth/resource-server/lightdash-token-validation.js +82 -0
  38. package/dist/auth/resource-server/lightdash-token-validation.test.d.ts +1 -0
  39. package/dist/auth/resource-server/lightdash-token-validation.test.js +177 -0
  40. package/dist/auth/resource-server/oauth-protected-resource.d.ts +25 -0
  41. package/dist/auth/resource-server/oauth-protected-resource.js +67 -0
  42. package/dist/auth/resource-server/shared-key-middleware.d.ts +13 -0
  43. package/dist/auth/resource-server/shared-key-middleware.js +24 -0
  44. package/dist/auth/resource-server/token-scopes.d.ts +15 -0
  45. package/dist/auth/resource-server/token-scopes.js +76 -0
  46. package/dist/auth/resource-server/token-scopes.test.d.ts +1 -0
  47. package/dist/auth/resource-server/token-scopes.test.js +51 -0
  48. package/dist/auth/resource-server/token-validation-cache.d.ts +15 -0
  49. package/dist/auth/resource-server/token-validation-cache.js +44 -0
  50. package/dist/auth/resource-server/token-validation-cache.test.d.ts +1 -0
  51. package/dist/auth/resource-server/token-validation-cache.test.js +41 -0
  52. package/dist/auth/resource-server/token-validation-error.d.ts +6 -0
  53. package/dist/auth/resource-server/token-validation-error.js +13 -0
  54. package/dist/auth/resource-server/www-authenticate.d.ts +8 -0
  55. package/dist/auth/resource-server/www-authenticate.js +24 -0
  56. package/dist/auth/resource-server/www-authenticate.test.d.ts +1 -0
  57. package/dist/auth/resource-server/www-authenticate.test.js +64 -0
  58. package/dist/auth/token-hash.d.ts +2 -0
  59. package/dist/auth/token-hash.js +8 -0
  60. package/dist/bin.d.ts +0 -4
  61. package/dist/bin.js +41 -33
  62. package/dist/config/env.d.ts +50 -0
  63. package/dist/config/env.js +53 -0
  64. package/dist/config/load-mcp-config.d.ts +30 -0
  65. package/dist/config/load-mcp-config.js +282 -0
  66. package/dist/config/load-mcp-config.test.d.ts +1 -0
  67. package/dist/config/load-mcp-config.test.js +195 -0
  68. package/dist/config/normalize-url.d.ts +13 -0
  69. package/dist/config/normalize-url.js +52 -0
  70. package/dist/config/normalize-url.test.d.ts +1 -0
  71. package/dist/config/normalize-url.test.js +41 -0
  72. package/dist/config/public-url.d.ts +3 -0
  73. package/dist/config/public-url.js +10 -0
  74. package/dist/config/runtime.d.ts +15 -0
  75. package/dist/config/runtime.js +48 -0
  76. package/dist/config/runtime.test.d.ts +1 -0
  77. package/dist/config/runtime.test.js +69 -0
  78. package/dist/config/test-mcp-http-config.d.ts +3 -0
  79. package/dist/config/test-mcp-http-config.js +7 -0
  80. package/dist/governance/project-pin.d.ts +14 -0
  81. package/dist/governance/project-pin.js +44 -0
  82. package/dist/governance/project-pin.test.d.ts +1 -0
  83. package/dist/governance/project-pin.test.js +35 -0
  84. package/dist/http.d.ts +1 -2
  85. package/dist/http.integration.test.d.ts +1 -0
  86. package/dist/http.integration.test.js +688 -0
  87. package/dist/http.js +3 -170
  88. package/dist/http.test.d.ts +4 -0
  89. package/dist/http.test.js +131 -0
  90. package/dist/index.d.ts +2 -0
  91. package/dist/index.integration.test.js +73 -30
  92. package/dist/index.js +28 -27
  93. package/dist/index.test.js +3 -3
  94. package/dist/logging/structured.d.ts +27 -0
  95. package/dist/logging/structured.js +32 -0
  96. package/dist/logging/structured.test.d.ts +1 -0
  97. package/dist/logging/structured.test.js +33 -0
  98. package/dist/personas/index.d.ts +19 -0
  99. package/dist/personas/index.js +57 -0
  100. package/dist/personas/index.test.d.ts +1 -0
  101. package/dist/personas/index.test.js +58 -0
  102. package/dist/personas/organization-audit/v1/index.d.ts +8 -0
  103. package/dist/personas/organization-audit/v1/index.js +42 -0
  104. package/dist/personas/organization-audit/v1/prompts.d.ts +5 -0
  105. package/dist/personas/organization-audit/v1/prompts.js +111 -0
  106. package/dist/personas/organization-audit/v1/prompts.test.d.ts +4 -0
  107. package/dist/personas/organization-audit/v1/prompts.test.js +25 -0
  108. package/dist/personas/organization-audit/v1/resources/playbook.d.ts +11 -0
  109. package/dist/personas/organization-audit/v1/resources/playbook.js +40 -0
  110. package/dist/personas/organization-audit/v1/resources/playbook.md +52 -0
  111. package/dist/personas/semantic-layer/v1/index.d.ts +8 -0
  112. package/dist/personas/semantic-layer/v1/index.js +32 -0
  113. package/dist/personas/semantic-layer/v1/prompts.d.ts +5 -0
  114. package/dist/personas/semantic-layer/v1/prompts.js +107 -0
  115. package/dist/personas/semantic-layer/v1/resources/playbook.d.ts +12 -0
  116. package/dist/personas/semantic-layer/v1/resources/playbook.js +42 -0
  117. package/dist/personas/semantic-layer/v1/resources/playbook.md +153 -0
  118. package/dist/personas/types.d.ts +19 -0
  119. package/dist/personas/types.js +5 -0
  120. package/dist/protocol-contract.test.d.ts +1 -0
  121. package/dist/protocol-contract.test.js +42 -0
  122. package/dist/server/capabilities.d.ts +15 -0
  123. package/dist/server/capabilities.js +19 -0
  124. package/dist/server/capabilities.test.d.ts +1 -0
  125. package/dist/server/capabilities.test.js +39 -0
  126. package/dist/server/errors.test.d.ts +1 -0
  127. package/dist/server/errors.test.js +53 -0
  128. package/dist/server/request-context.d.ts +13 -0
  129. package/dist/server/request-context.js +2 -0
  130. package/dist/server/server.d.ts +4 -0
  131. package/dist/server/server.js +17 -0
  132. package/dist/server/server.test.d.ts +1 -0
  133. package/dist/server/server.test.js +15 -0
  134. package/dist/server/version.d.ts +1 -0
  135. package/dist/server/version.js +7 -0
  136. package/dist/server/version.test.d.ts +1 -0
  137. package/dist/server/version.test.js +9 -0
  138. package/dist/stdio.process.test.d.ts +1 -0
  139. package/dist/stdio.process.test.js +126 -0
  140. package/dist/tools/index.d.ts +2 -4
  141. package/dist/tools/index.js +4 -30
  142. package/dist/tools/index.test.d.ts +1 -0
  143. package/dist/tools/index.test.js +72 -0
  144. package/dist/tools/lib/api-errors.d.ts +9 -0
  145. package/dist/tools/lib/api-errors.js +22 -0
  146. package/dist/tools/lib/api-shape.d.ts +16 -0
  147. package/dist/tools/lib/api-shape.js +47 -0
  148. package/dist/tools/lib/assert-safe.d.ts +13 -0
  149. package/dist/tools/lib/assert-safe.js +21 -0
  150. package/dist/tools/lib/assert-safe.test.d.ts +4 -0
  151. package/dist/tools/lib/assert-safe.test.js +32 -0
  152. package/dist/tools/lib/concurrency.d.ts +4 -0
  153. package/dist/tools/lib/concurrency.js +24 -0
  154. package/dist/tools/lib/contracts.d.ts +34 -0
  155. package/dist/tools/lib/contracts.js +30 -0
  156. package/dist/tools/lib/redaction.d.ts +107 -0
  157. package/dist/tools/lib/redaction.js +299 -0
  158. package/dist/tools/lib/redaction.test.d.ts +4 -0
  159. package/dist/tools/lib/redaction.test.js +216 -0
  160. package/dist/tools/lib/register-org-audit.d.ts +9 -0
  161. package/dist/tools/lib/register-org-audit.js +20 -0
  162. package/dist/tools/lib/schema-fields.d.ts +9 -0
  163. package/dist/tools/lib/schema-fields.js +19 -0
  164. package/dist/tools/organization/binding.d.ts +14 -0
  165. package/dist/tools/organization/binding.js +31 -0
  166. package/dist/tools/organization/invariants.test.d.ts +4 -0
  167. package/dist/tools/organization/invariants.test.js +28 -0
  168. package/dist/tools/organization/inventory.d.ts +10 -0
  169. package/dist/tools/organization/inventory.js +189 -0
  170. package/dist/tools/organization/roles.d.ts +10 -0
  171. package/dist/tools/organization/roles.js +213 -0
  172. package/dist/tools/project/content.d.ts +9 -0
  173. package/dist/tools/project/content.js +192 -0
  174. package/dist/tools/project/projects.d.ts +7 -0
  175. package/dist/tools/project/projects.js +42 -0
  176. package/dist/tools/project/projects.test.d.ts +1 -0
  177. package/dist/tools/project/projects.test.js +117 -0
  178. package/dist/tools/project/schedulers.d.ts +7 -0
  179. package/dist/tools/project/schedulers.js +115 -0
  180. package/dist/tools/registry.d.ts +104 -0
  181. package/dist/tools/registry.js +59 -0
  182. package/dist/tools/semantic/explore-helpers.d.ts +56 -0
  183. package/dist/tools/semantic/explore-helpers.js +115 -0
  184. package/dist/tools/semantic/explore-helpers.test.d.ts +1 -0
  185. package/dist/tools/semantic/explore-helpers.test.js +170 -0
  186. package/dist/tools/semantic/explores.d.ts +9 -0
  187. package/dist/tools/semantic/explores.js +80 -0
  188. package/dist/tools/semantic/metrics.d.ts +7 -0
  189. package/dist/tools/semantic/metrics.js +53 -0
  190. package/dist/tools/semantic/query.d.ts +6 -0
  191. package/dist/tools/semantic/query.js +42 -0
  192. package/dist/tools/semantic/schema-fields.d.ts +3 -0
  193. package/dist/tools/semantic/schema-fields.js +7 -0
  194. package/dist/tools/shared.d.ts +26 -13
  195. package/dist/tools/shared.js +112 -157
  196. package/dist/tools/shared.test.js +132 -183
  197. package/dist/tools/space/access.d.ts +66 -0
  198. package/dist/tools/space/access.js +322 -0
  199. package/dist/tools/space/access.test.d.ts +4 -0
  200. package/dist/tools/space/access.test.js +90 -0
  201. package/dist/transports/http-body.d.ts +5 -0
  202. package/dist/transports/http-body.js +50 -0
  203. package/dist/transports/http-request-utils.d.ts +2 -0
  204. package/dist/transports/http-request-utils.js +13 -0
  205. package/dist/transports/http-response.d.ts +6 -0
  206. package/dist/transports/http-response.js +56 -0
  207. package/dist/transports/session-store.d.ts +40 -0
  208. package/dist/transports/session-store.js +88 -0
  209. package/dist/transports/session-store.test.d.ts +1 -0
  210. package/dist/transports/session-store.test.js +111 -0
  211. package/dist/transports/streamable-http.d.ts +9 -0
  212. package/dist/transports/streamable-http.js +454 -0
  213. package/dist/transports/streamable-http.test.d.ts +1 -0
  214. package/dist/transports/streamable-http.test.js +95 -0
  215. package/package.json +25 -10
  216. package/dist/audit.d.ts +0 -6
  217. package/dist/config.d.ts +0 -47
  218. package/dist/config.js +0 -82
  219. package/dist/tools/ai-agents.d.ts +0 -6
  220. package/dist/tools/ai-agents.js +0 -388
  221. package/dist/tools/charts.d.ts +0 -6
  222. package/dist/tools/charts.js +0 -55
  223. package/dist/tools/content.d.ts +0 -6
  224. package/dist/tools/content.js +0 -37
  225. package/dist/tools/dashboards.d.ts +0 -6
  226. package/dist/tools/dashboards.js +0 -28
  227. package/dist/tools/explores.d.ts +0 -6
  228. package/dist/tools/explores.js +0 -65
  229. package/dist/tools/groups.d.ts +0 -6
  230. package/dist/tools/groups.js +0 -121
  231. package/dist/tools/metrics.d.ts +0 -6
  232. package/dist/tools/metrics.js +0 -45
  233. package/dist/tools/projects.d.ts +0 -6
  234. package/dist/tools/projects.js +0 -58
  235. package/dist/tools/query.d.ts +0 -6
  236. package/dist/tools/query.js +0 -34
  237. package/dist/tools/schedulers.d.ts +0 -6
  238. package/dist/tools/schedulers.js +0 -45
  239. package/dist/tools/spaces.d.ts +0 -6
  240. package/dist/tools/spaces.js +0 -128
  241. package/dist/tools/tags.d.ts +0 -6
  242. package/dist/tools/tags.js +0 -28
  243. package/dist/tools/users.d.ts +0 -6
  244. package/dist/tools/users.js +0 -50
  245. package/src/audit.ts +0 -6
  246. package/src/bin.ts +0 -58
  247. package/src/config.ts +0 -83
  248. package/src/errors.ts +0 -27
  249. package/src/http.ts +0 -187
  250. package/src/index.integration.test.ts +0 -57
  251. package/src/index.test.ts +0 -8
  252. package/src/index.ts +0 -31
  253. package/src/tools/ai-agents.ts +0 -759
  254. package/src/tools/charts.ts +0 -85
  255. package/src/tools/content.ts +0 -44
  256. package/src/tools/dashboards.ts +0 -25
  257. package/src/tools/explores.ts +0 -98
  258. package/src/tools/groups.ts +0 -180
  259. package/src/tools/index.ts +0 -35
  260. package/src/tools/metrics.ts +0 -42
  261. package/src/tools/projects.ts +0 -74
  262. package/src/tools/query.ts +0 -47
  263. package/src/tools/schedulers.ts +0 -42
  264. package/src/tools/shared.test.ts +0 -365
  265. package/src/tools/shared.ts +0 -274
  266. package/src/tools/spaces.ts +0 -217
  267. package/src/tools/tags.ts +0 -25
  268. package/src/tools/users.ts +0 -64
  269. package/tsconfig.json +0 -13
  270. /package/dist/{errors.d.ts → server/errors.d.ts} +0 -0
  271. /package/dist/{errors.js → server/errors.js} +0 -0
@@ -1,85 +0,0 @@
1
- /**
2
- * MCP tools: charts (list, charts-as-code list and upsert).
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { z } from 'zod';
8
- import { wrapTool, registerToolSafe, READ_ONLY_DEFAULT, WRITE_IDEMPOTENT } from './shared.js';
9
-
10
- export function registerChartTools(server: McpServer, client: LightdashClient): void {
11
- registerToolSafe(
12
- server,
13
- 'list_charts',
14
- {
15
- title: 'List charts',
16
- description: 'List charts in a project',
17
- inputSchema: { projectUuid: z.string().describe('Project UUID') },
18
- annotations: READ_ONLY_DEFAULT,
19
- },
20
- wrapTool(client, (c) => async ({ projectUuid }: { projectUuid: string }) => {
21
- const charts = await c.v1.charts.listCharts(projectUuid);
22
- return { content: [{ type: 'text', text: JSON.stringify(charts, null, 2) }] };
23
- }),
24
- );
25
- registerToolSafe(
26
- server,
27
- 'list_charts_as_code',
28
- {
29
- title: 'List charts as code',
30
- description: 'Get charts in code representation for a project (for charts-as-code workflows)',
31
- inputSchema: {
32
- projectUuid: z.string().describe('Project UUID'),
33
- ids: z.array(z.string()).optional().describe('Optional chart IDs (slugs) to filter'),
34
- },
35
- annotations: READ_ONLY_DEFAULT,
36
- },
37
- wrapTool(
38
- client,
39
- (c) =>
40
- async ({ projectUuid, ids }: { projectUuid: string; ids?: string[] }) => {
41
- const result = await c.v1.charts.getChartsAsCode(projectUuid, { ids });
42
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
43
- },
44
- ),
45
- );
46
- registerToolSafe(
47
- server,
48
- 'upsert_chart_as_code',
49
- {
50
- title: 'Upsert chart as code',
51
- description: 'Create or update a chart from its code representation (by slug)',
52
- inputSchema: {
53
- projectUuid: z.string().describe('Project UUID'),
54
- slug: z.string().describe('Chart slug'),
55
- chart: z
56
- .record(z.string(), z.unknown())
57
- .describe('Chart-as-code payload (name, metricQuery, chartConfig, etc.)'),
58
- },
59
- annotations: WRITE_IDEMPOTENT,
60
- },
61
- wrapTool(
62
- client,
63
- (c) =>
64
- async ({
65
- projectUuid,
66
- slug,
67
- chart,
68
- }: {
69
- projectUuid: string;
70
- slug: string;
71
- chart: Record<string, unknown>;
72
- }) => {
73
- type UpsertChartBody = Parameters<
74
- LightdashClient['v1']['charts']['upsertChartAsCode']
75
- >[2];
76
- const result = await c.v1.charts.upsertChartAsCode(
77
- projectUuid,
78
- slug,
79
- chart as UpsertChartBody,
80
- );
81
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
82
- },
83
- ),
84
- );
85
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * MCP tools: content (search).
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { z } from 'zod';
8
- import { wrapTool, registerToolSafe, READ_ONLY_DEFAULT } from './shared.js';
9
-
10
- export function registerContentTools(server: McpServer, client: LightdashClient): void {
11
- registerToolSafe(
12
- server,
13
- 'search_content',
14
- {
15
- title: 'Search content',
16
- description: 'Search for charts, dashboards, and spaces across projects',
17
- inputSchema: {
18
- search: z.string().describe('Search query'),
19
- projectUuids: z.array(z.string()).optional().describe('Optional project UUIDs to filter'),
20
- contentTypes: z
21
- .array(z.enum(['chart', 'dashboard', 'space']))
22
- .optional()
23
- .describe('Optional content types to filter'),
24
- page: z.number().optional().describe('Page number'),
25
- pageSize: z.number().optional().describe('Page size'),
26
- },
27
- annotations: READ_ONLY_DEFAULT,
28
- },
29
- wrapTool(
30
- client,
31
- (c) =>
32
- async (params: {
33
- search: string;
34
- projectUuids?: string[];
35
- contentTypes?: ('chart' | 'dashboard' | 'space')[];
36
- page?: number;
37
- pageSize?: number;
38
- }) => {
39
- const result = await c.v2.content.searchContent(params);
40
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
41
- },
42
- ),
43
- );
44
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * MCP tools: dashboards (list).
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { z } from 'zod';
8
- import { wrapTool, registerToolSafe, READ_ONLY_DEFAULT } from './shared.js';
9
-
10
- export function registerDashboardTools(server: McpServer, client: LightdashClient): void {
11
- registerToolSafe(
12
- server,
13
- 'list_dashboards',
14
- {
15
- title: 'List dashboards',
16
- description: 'List dashboards in a project',
17
- inputSchema: { projectUuid: z.string().describe('Project UUID') },
18
- annotations: READ_ONLY_DEFAULT,
19
- },
20
- wrapTool(client, (c) => async ({ projectUuid }: { projectUuid: string }) => {
21
- const dashboards = await c.v1.dashboards.listDashboards(projectUuid);
22
- return { content: [{ type: 'text', text: JSON.stringify(dashboards, null, 2) }] };
23
- }),
24
- );
25
- }
@@ -1,98 +0,0 @@
1
- /**
2
- * MCP tools: explores (list, get).
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { z } from 'zod';
8
- import { wrapTool, registerToolSafe, READ_ONLY_DEFAULT } from './shared.js';
9
-
10
- export function registerExploresTools(server: McpServer, client: LightdashClient): void {
11
- registerToolSafe(
12
- server,
13
- 'list_explores',
14
- {
15
- title: 'List explores',
16
- description: 'List all explores in a project',
17
- inputSchema: { projectUuid: z.string().describe('Project UUID') },
18
- annotations: READ_ONLY_DEFAULT,
19
- },
20
- wrapTool(client, (c) => async ({ projectUuid }: { projectUuid: string }) => {
21
- const explores = await c.v1.explores.listExplores(projectUuid);
22
- return { content: [{ type: 'text', text: JSON.stringify(explores, null, 2) }] };
23
- }),
24
- );
25
- registerToolSafe(
26
- server,
27
- 'get_explore',
28
- {
29
- title: 'Get explore',
30
- description:
31
- 'Get an explore by project UUID and explore ID (includes tables, dimensions, and metrics)',
32
- inputSchema: {
33
- projectUuid: z.string().describe('Project UUID'),
34
- exploreId: z.string().describe('Explore ID'),
35
- },
36
- annotations: READ_ONLY_DEFAULT,
37
- },
38
- wrapTool(
39
- client,
40
- (c) =>
41
- async ({ projectUuid, exploreId }: { projectUuid: string; exploreId: string }) => {
42
- const explore = await c.v1.explores.getExplore(projectUuid, exploreId);
43
- return { content: [{ type: 'text', text: JSON.stringify(explore, null, 2) }] };
44
- },
45
- ),
46
- );
47
- registerToolSafe(
48
- server,
49
- 'list_dimensions',
50
- {
51
- title: 'List dimensions',
52
- description: 'List all dimensions for a specific explore',
53
- inputSchema: {
54
- projectUuid: z.string().describe('Project UUID'),
55
- exploreId: z.string().describe('Explore ID'),
56
- },
57
- annotations: READ_ONLY_DEFAULT,
58
- },
59
- wrapTool(
60
- client,
61
- (c) =>
62
- async ({ projectUuid, exploreId }: { projectUuid: string; exploreId: string }) => {
63
- const result = await c.v1.explores.listDimensions(projectUuid, exploreId);
64
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
65
- },
66
- ),
67
- );
68
- registerToolSafe(
69
- server,
70
- 'get_field_lineage',
71
- {
72
- title: 'Get field lineage',
73
- description: 'Get upstream lineage for a specific field in an explore',
74
- inputSchema: {
75
- projectUuid: z.string().describe('Project UUID'),
76
- exploreId: z.string().describe('Explore ID'),
77
- fieldId: z.string().describe('Field ID'),
78
- },
79
- annotations: READ_ONLY_DEFAULT,
80
- },
81
- wrapTool(
82
- client,
83
- (c) =>
84
- async ({
85
- projectUuid,
86
- exploreId,
87
- fieldId,
88
- }: {
89
- projectUuid: string;
90
- exploreId: string;
91
- fieldId: string;
92
- }) => {
93
- const result = await c.v1.explores.getFieldLineage(projectUuid, exploreId, fieldId);
94
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
95
- },
96
- ),
97
- );
98
- }
@@ -1,180 +0,0 @@
1
- /**
2
- * MCP tools: groups (list, get).
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { z } from 'zod';
8
- import {
9
- wrapTool,
10
- registerToolSafe,
11
- READ_ONLY_DEFAULT,
12
- WRITE_IDEMPOTENT,
13
- WRITE_DESTRUCTIVE,
14
- } from './shared.js';
15
-
16
- type ListGroupsParams = {
17
- page?: number;
18
- pageSize?: number;
19
- searchQuery?: string;
20
- };
21
-
22
- export function registerGroupTools(server: McpServer, client: LightdashClient): void {
23
- registerToolSafe(
24
- server,
25
- 'list_groups',
26
- {
27
- title: 'List groups',
28
- description: 'List organization groups (one page)',
29
- inputSchema: {
30
- page: z.number().optional().describe('Page number'),
31
- pageSize: z.number().optional().describe('Page size'),
32
- searchQuery: z.string().optional().describe('Search query'),
33
- },
34
- annotations: READ_ONLY_DEFAULT,
35
- },
36
- wrapTool(client, (c) => async (params: ListGroupsParams) => {
37
- const result = await c.v1.groups.listGroups(params ?? {});
38
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
39
- }),
40
- );
41
-
42
- registerToolSafe(
43
- server,
44
- 'get_group',
45
- {
46
- title: 'Get group',
47
- description: 'Get a group by UUID',
48
- inputSchema: { groupUuid: z.string().describe('Group UUID') },
49
- annotations: READ_ONLY_DEFAULT,
50
- },
51
- wrapTool(client, (c) => async ({ groupUuid }: { groupUuid: string }) => {
52
- const group = await c.v1.groups.getGroup(groupUuid);
53
- return { content: [{ type: 'text', text: JSON.stringify(group, null, 2) }] };
54
- }),
55
- );
56
-
57
- registerToolSafe(
58
- server,
59
- 'create_group',
60
- {
61
- title: 'Create group',
62
- description: 'Create a new group in the organization',
63
- inputSchema: {
64
- name: z.string().describe('Group name'),
65
- },
66
- annotations: WRITE_IDEMPOTENT,
67
- },
68
- wrapTool(client, (c) => async ({ name }: { name: string }) => {
69
- const group = await c.v1.groups.createGroup({ name });
70
- return { content: [{ type: 'text', text: JSON.stringify(group, null, 2) }] };
71
- }),
72
- );
73
-
74
- registerToolSafe(
75
- server,
76
- 'update_group',
77
- {
78
- title: 'Update group',
79
- description: 'Update a group name',
80
- inputSchema: {
81
- groupUuid: z.string().describe('Group UUID'),
82
- name: z.string().describe('New group name'),
83
- },
84
- annotations: WRITE_IDEMPOTENT,
85
- },
86
- wrapTool(client, (c) => async ({ groupUuid, name }: { groupUuid: string; name: string }) => {
87
- const group = await c.v1.groups.updateGroup(groupUuid, { name });
88
- return { content: [{ type: 'text', text: JSON.stringify(group, null, 2) }] };
89
- }),
90
- );
91
-
92
- registerToolSafe(
93
- server,
94
- 'delete_group',
95
- {
96
- title: 'Delete group',
97
- description: 'Delete a group by UUID',
98
- inputSchema: {
99
- groupUuid: z.string().describe('Group UUID'),
100
- },
101
- annotations: WRITE_DESTRUCTIVE,
102
- },
103
- wrapTool(client, (c) => async ({ groupUuid }: { groupUuid: string }) => {
104
- await c.v1.groups.deleteGroup(groupUuid);
105
- return { content: [{ type: 'text', text: `Group ${groupUuid} deleted successfully` }] };
106
- }),
107
- );
108
-
109
- registerToolSafe(
110
- server,
111
- 'list_group_members',
112
- {
113
- title: 'List group members',
114
- description: 'List members of a group',
115
- inputSchema: {
116
- groupUuid: z.string().describe('Group UUID'),
117
- },
118
- annotations: READ_ONLY_DEFAULT,
119
- },
120
- wrapTool(client, (c) => async ({ groupUuid }: { groupUuid: string }) => {
121
- const members = await c.v1.groups.getGroupMembers(groupUuid);
122
- return { content: [{ type: 'text', text: JSON.stringify(members, null, 2) }] };
123
- }),
124
- );
125
-
126
- registerToolSafe(
127
- server,
128
- 'add_user_to_group',
129
- {
130
- title: 'Add user to group',
131
- description: 'Add a user to a group',
132
- inputSchema: {
133
- groupUuid: z.string().describe('Group UUID'),
134
- userUuid: z.string().describe('User UUID'),
135
- },
136
- annotations: WRITE_IDEMPOTENT,
137
- },
138
- wrapTool(
139
- client,
140
- (c) =>
141
- async ({ groupUuid, userUuid }: { groupUuid: string; userUuid: string }) => {
142
- await c.v1.groups.addUserToGroup(groupUuid, userUuid);
143
- return {
144
- content: [
145
- { type: 'text', text: `User ${userUuid} added to group ${groupUuid} successfully` },
146
- ],
147
- };
148
- },
149
- ),
150
- );
151
-
152
- registerToolSafe(
153
- server,
154
- 'remove_user_from_group',
155
- {
156
- title: 'Remove user from group',
157
- description: 'Remove a user from a group',
158
- inputSchema: {
159
- groupUuid: z.string().describe('Group UUID'),
160
- userUuid: z.string().describe('User UUID'),
161
- },
162
- annotations: WRITE_DESTRUCTIVE,
163
- },
164
- wrapTool(
165
- client,
166
- (c) =>
167
- async ({ groupUuid, userUuid }: { groupUuid: string; userUuid: string }) => {
168
- await c.v1.groups.removeUserFromGroup(groupUuid, userUuid);
169
- return {
170
- content: [
171
- {
172
- type: 'text',
173
- text: `User ${userUuid} removed from group ${groupUuid} successfully`,
174
- },
175
- ],
176
- };
177
- },
178
- ),
179
- );
180
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * MCP tool registration: barrel that delegates to domain modules.
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { registerProjectTools } from './projects.js';
8
- import { registerChartTools } from './charts.js';
9
- import { registerDashboardTools } from './dashboards.js';
10
- import { registerSpaceTools } from './spaces.js';
11
- import { registerUserTools } from './users.js';
12
- import { registerGroupTools } from './groups.js';
13
- import { registerQueryTools } from './query.js';
14
- import { registerExploresTools } from './explores.js';
15
- import { registerMetricsTools } from './metrics.js';
16
- import { registerSchedulersTools } from './schedulers.js';
17
- import { registerTagsTools } from './tags.js';
18
- import { registerContentTools } from './content.js';
19
- import { registerAiAgentTools } from './ai-agents.js';
20
-
21
- export function registerTools(server: McpServer, client: LightdashClient): void {
22
- registerProjectTools(server, client);
23
- registerChartTools(server, client);
24
- registerDashboardTools(server, client);
25
- registerSpaceTools(server, client);
26
- registerUserTools(server, client);
27
- registerGroupTools(server, client);
28
- registerQueryTools(server, client);
29
- registerExploresTools(server, client);
30
- registerMetricsTools(server, client);
31
- registerSchedulersTools(server, client);
32
- registerTagsTools(server, client);
33
- registerContentTools(server, client);
34
- registerAiAgentTools(server, client);
35
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * MCP tools: metrics (list, get).
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { z } from 'zod';
8
- import { wrapTool, registerToolSafe, READ_ONLY_DEFAULT } from './shared.js';
9
-
10
- export function registerMetricsTools(server: McpServer, client: LightdashClient): void {
11
- registerToolSafe(
12
- server,
13
- 'list_metrics',
14
- {
15
- title: 'List metrics',
16
- description: 'List metrics in a project data catalog',
17
- inputSchema: {
18
- projectUuid: z.string().describe('Project UUID'),
19
- search: z.string().optional().describe('Search query'),
20
- page: z.number().optional().describe('Page number'),
21
- pageSize: z.number().optional().describe('Page size'),
22
- },
23
- annotations: READ_ONLY_DEFAULT,
24
- },
25
- wrapTool(
26
- client,
27
- (c) =>
28
- async ({
29
- projectUuid,
30
- ...params
31
- }: {
32
- projectUuid: string;
33
- search?: string;
34
- page?: number;
35
- pageSize?: number;
36
- }) => {
37
- const result = await c.v1.metrics.listMetrics(projectUuid, params);
38
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
39
- },
40
- ),
41
- );
42
- }
@@ -1,74 +0,0 @@
1
- /**
2
- * MCP tools: projects (list, get).
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { z } from 'zod';
8
- import { wrapTool, registerToolSafe, READ_ONLY_DEFAULT, WRITE_IDEMPOTENT } from './shared.js';
9
-
10
- export function registerProjectTools(server: McpServer, client: LightdashClient): void {
11
- registerToolSafe(
12
- server,
13
- 'list_projects',
14
- {
15
- title: 'List projects',
16
- description: 'List all projects in the current organization',
17
- inputSchema: {},
18
- annotations: READ_ONLY_DEFAULT,
19
- },
20
- wrapTool(client, () => async () => {
21
- const projects = await client.v1.projects.listProjects();
22
- return { content: [{ type: 'text', text: JSON.stringify(projects, null, 2) }] };
23
- }),
24
- );
25
- registerToolSafe(
26
- server,
27
- 'get_project',
28
- {
29
- title: 'Get project',
30
- description: 'Get a project by UUID',
31
- inputSchema: { projectUuid: z.string().describe('Project UUID') },
32
- annotations: READ_ONLY_DEFAULT,
33
- },
34
- wrapTool(client, (c) => async ({ projectUuid }: { projectUuid: string }) => {
35
- const project = await c.v1.projects.getProject(projectUuid);
36
- return { content: [{ type: 'text', text: JSON.stringify(project, null, 2) }] };
37
- }),
38
- );
39
- registerToolSafe(
40
- server,
41
- 'validate_project',
42
- {
43
- title: 'Validate project',
44
- description: 'Trigger a validation job for a project and return the job ID',
45
- inputSchema: { projectUuid: z.string().describe('Project UUID') },
46
- annotations: WRITE_IDEMPOTENT,
47
- },
48
- wrapTool(client, (c) => async ({ projectUuid }: { projectUuid: string }) => {
49
- const result = await c.v1.validation.validateProject(projectUuid);
50
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
51
- }),
52
- );
53
- registerToolSafe(
54
- server,
55
- 'get_validation_results',
56
- {
57
- title: 'Get validation results',
58
- description: 'Get the latest validation results for a project',
59
- inputSchema: {
60
- projectUuid: z.string().describe('Project UUID'),
61
- jobId: z.string().optional().describe('Optional job ID to get results for'),
62
- },
63
- annotations: READ_ONLY_DEFAULT,
64
- },
65
- wrapTool(
66
- client,
67
- (c) =>
68
- async ({ projectUuid, jobId }: { projectUuid: string; jobId?: string }) => {
69
- const result = await c.v1.validation.getValidationResults(projectUuid, { jobId });
70
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
71
- },
72
- ),
73
- );
74
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * MCP tools: query (compile).
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { z } from 'zod';
8
- import { wrapTool, registerToolSafe, READ_ONLY_DEFAULT } from './shared.js';
9
-
10
- export function registerQueryTools(server: McpServer, client: LightdashClient): void {
11
- registerToolSafe(
12
- server,
13
- 'compile_query',
14
- {
15
- title: 'Compile query',
16
- description: 'Compile a metric query for an explore without executing it',
17
- inputSchema: {
18
- projectUuid: z.string().describe('Project UUID'),
19
- exploreId: z.string().describe('Explore ID'),
20
- metricQuery: z
21
- .record(z.string(), z.unknown())
22
- .describe('Metric query object (dimensions, metrics, filters, etc.)'),
23
- },
24
- annotations: READ_ONLY_DEFAULT,
25
- },
26
- wrapTool(
27
- client,
28
- (c) =>
29
- async ({
30
- projectUuid,
31
- exploreId,
32
- metricQuery,
33
- }: {
34
- projectUuid: string;
35
- exploreId: string;
36
- metricQuery: Record<string, unknown>;
37
- }) => {
38
- const result = await c.v1.query.compileQuery(
39
- projectUuid,
40
- exploreId,
41
- metricQuery as never,
42
- );
43
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
44
- },
45
- ),
46
- );
47
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * MCP tools: schedulers (list, get).
3
- */
4
-
5
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import type { LightdashClient } from '@lightdash-tools/client';
7
- import { z } from 'zod';
8
- import { wrapTool, registerToolSafe, READ_ONLY_DEFAULT } from './shared.js';
9
-
10
- export function registerSchedulersTools(server: McpServer, client: LightdashClient): void {
11
- registerToolSafe(
12
- server,
13
- 'list_schedulers',
14
- {
15
- title: 'List schedulers',
16
- description: 'List scheduled deliveries in a project',
17
- inputSchema: {
18
- projectUuid: z.string().describe('Project UUID'),
19
- searchQuery: z.string().optional().describe('Search query'),
20
- page: z.number().optional().describe('Page number'),
21
- pageSize: z.number().optional().describe('Page size'),
22
- },
23
- annotations: READ_ONLY_DEFAULT,
24
- },
25
- wrapTool(
26
- client,
27
- (c) =>
28
- async ({
29
- projectUuid,
30
- ...params
31
- }: {
32
- projectUuid: string;
33
- searchQuery?: string;
34
- page?: number;
35
- pageSize?: number;
36
- }) => {
37
- const result = await c.v1.schedulers.listSchedulers(projectUuid, params);
38
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
39
- },
40
- ),
41
- );
42
- }