@lightdash-tools/mcp 0.8.0 → 0.11.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 (339) hide show
  1. package/README.md +112 -236
  2. package/dist/audit/server-profile.d.ts +13 -0
  3. package/dist/audit/server-profile.js +28 -0
  4. package/dist/audit/server-profile.test.js +21 -0
  5. package/dist/auth/oauth-broker/pending-store.d.ts +6 -7
  6. package/dist/auth/oauth-broker/pending-store.js +3 -4
  7. package/dist/auth/oauth-broker/pending-store.test.d.ts +2 -3
  8. package/dist/auth/oauth-broker/pending-store.test.js +2 -39
  9. package/dist/auth/oauth-broker/routes.d.ts +1 -1
  10. package/dist/auth/oauth-broker/routes.js +3 -3
  11. package/dist/auth/oauth-broker/routes.test.js +1 -1
  12. package/dist/auth/request-state-key.d.ts +19 -0
  13. package/dist/auth/request-state-key.js +49 -0
  14. package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +1 -3
  15. package/dist/auth/resource-server/lightdash-oauth-middleware.js +1 -20
  16. package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +14 -14
  17. package/dist/auth/resource-server/oauth-protected-resource.d.ts +6 -6
  18. package/dist/auth/resource-server/oauth-protected-resource.js +8 -8
  19. package/dist/auth/resource-server/token-scopes.d.ts +1 -1
  20. package/dist/auth/resource-server/token-scopes.js +1 -1
  21. package/dist/auth/resource-server/www-authenticate.test.js +11 -13
  22. package/dist/bin.js +54 -51
  23. package/dist/config/env.d.ts +8 -16
  24. package/dist/config/env.js +9 -17
  25. package/dist/config/load-mcp-config.d.ts +0 -4
  26. package/dist/config/load-mcp-config.js +9 -38
  27. package/dist/config/load-mcp-config.test.js +8 -2
  28. package/dist/config/normalize-url.d.ts +1 -1
  29. package/dist/config/normalize-url.js +1 -1
  30. package/dist/config/normalize-url.test.js +16 -13
  31. package/dist/config/obsolete-env.d.ts +5 -0
  32. package/dist/config/obsolete-env.js +48 -0
  33. package/dist/config/obsolete-env.test.js +22 -0
  34. package/dist/config/runtime.d.ts +3 -3
  35. package/dist/config/runtime.js +19 -23
  36. package/dist/config/runtime.test.js +23 -9
  37. package/dist/config/test-mcp-http-config.js +1 -1
  38. package/dist/destructive/content-promote.js +7 -1
  39. package/dist/destructive/promote-contract.test.js +106 -47
  40. package/dist/destructive/register-destructive-tool.js +6 -24
  41. package/dist/destructive/request-state.d.ts +2 -6
  42. package/dist/destructive/request-state.js +3 -38
  43. package/dist/destructive/types.d.ts +2 -1
  44. package/dist/governance/available-projects.d.ts +37 -0
  45. package/dist/governance/available-projects.js +132 -0
  46. package/dist/governance/available-projects.test.d.ts +4 -0
  47. package/dist/governance/available-projects.test.js +107 -0
  48. package/dist/governance/mcp-client-session.d.ts +3 -2
  49. package/dist/governance/mcp-client-session.js +3 -2
  50. package/dist/governance/mcp-post-factory-context.d.ts +15 -0
  51. package/dist/governance/mcp-post-factory-context.js +22 -0
  52. package/dist/governance/mcp-post-factory-context.test.js +34 -0
  53. package/dist/governance/project-scope.d.ts +8 -22
  54. package/dist/governance/project-scope.js +36 -44
  55. package/dist/governance/project-scope.test.d.ts +1 -1
  56. package/dist/governance/project-scope.test.js +21 -44
  57. package/dist/governance/promote-allowlist.d.ts +18 -0
  58. package/dist/governance/promote-allowlist.js +66 -0
  59. package/dist/governance/promote-allowlist.test.d.ts +4 -0
  60. package/dist/governance/promote-allowlist.test.js +87 -0
  61. package/dist/http.integration.test.js +116 -265
  62. package/dist/http.test.js +0 -12
  63. package/dist/index.d.ts +5 -1
  64. package/dist/index.integration.test.js +0 -4
  65. package/dist/index.js +31 -16
  66. package/dist/policy/content-developer.d.ts +3 -3
  67. package/dist/policy/content-developer.js +3 -3
  68. package/dist/policy/content-developer.test.js +10 -4
  69. package/dist/policy/content-reader.d.ts +15 -6
  70. package/dist/policy/content-reader.js +39 -10
  71. package/dist/policy/content-reader.test.js +5 -3
  72. package/dist/policy/envelope.d.ts +4 -2
  73. package/dist/policy/envelope.js +2 -2
  74. package/dist/policy/envelope.test.js +28 -0
  75. package/dist/policy/preview-ledger-fault.test.js +101 -426
  76. package/dist/policy/preview-ledger.d.ts +38 -74
  77. package/dist/policy/preview-ledger.js +108 -186
  78. package/dist/policy/preview-ledger.test.js +237 -111
  79. package/dist/policy/result-limits.d.ts +6 -1
  80. package/dist/policy/result-limits.js +28 -29
  81. package/dist/policy/result-limits.test.js +10 -1
  82. package/dist/profiles/ai-agent-ops/v1/index.d.ts +6 -0
  83. package/dist/profiles/ai-agent-ops/v1/index.js +20 -0
  84. package/dist/profiles/ai-agent-ops/v1/prompts.d.ts +5 -0
  85. package/dist/profiles/ai-agent-ops/v1/prompts.js +141 -0
  86. package/dist/profiles/ai-agent-ops/v1/prompts.test.d.ts +4 -0
  87. package/dist/profiles/ai-agent-ops/v1/prompts.test.js +26 -0
  88. package/dist/profiles/ai-agent-ops/v1/resources/playbooks/core.md +39 -0
  89. package/dist/profiles/ai-agent-ops/v1/resources/playbooks/evaluation.md +25 -0
  90. package/dist/profiles/ai-agent-ops/v1/resources/playbooks/index.md +14 -0
  91. package/dist/profiles/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +28 -0
  92. package/dist/profiles/ai-agent-ops/v1/resources/playbooks/release-gate.md +22 -0
  93. package/dist/profiles/ai-agent-ops/v1/resources/playbooks.d.ts +10 -0
  94. package/dist/profiles/ai-agent-ops/v1/resources/playbooks.js +41 -0
  95. package/dist/profiles/content-developer/v1/index.d.ts +8 -0
  96. package/dist/profiles/content-developer/v1/index.js +22 -0
  97. package/dist/{personas → profiles}/content-developer/v1/prompts.d.ts +3 -0
  98. package/dist/profiles/content-developer/v1/prompts.js +157 -0
  99. package/dist/profiles/content-developer/v1/prompts.test.js +286 -0
  100. package/dist/profiles/content-developer/v1/resources/playbooks/chart-types.md +138 -0
  101. package/dist/profiles/content-developer/v1/resources/playbooks/content-move.md +22 -0
  102. package/dist/profiles/content-developer/v1/resources/playbooks/core.md +109 -0
  103. package/dist/profiles/content-developer/v1/resources/playbooks/dashboard-design.md +153 -0
  104. package/dist/profiles/content-developer/v1/resources/playbooks/dashboards.md +108 -0
  105. package/dist/profiles/content-developer/v1/resources/playbooks/index.md +15 -0
  106. package/dist/{personas → profiles}/content-developer/v1/resources/playbooks.d.ts +1 -1
  107. package/dist/profiles/content-developer/v1/resources/playbooks.js +65 -0
  108. package/dist/profiles/content-governance/v1/index.d.ts +7 -0
  109. package/dist/profiles/content-governance/v1/index.js +21 -0
  110. package/dist/{personas → profiles}/content-governance/v1/prompts.test.js +2 -2
  111. package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/core.md +3 -3
  112. package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/dashboards.md +1 -1
  113. package/dist/{personas → profiles}/content-governance/v1/resources/playbooks.js +4 -4
  114. package/dist/profiles/content-reader/v1/index.d.ts +6 -0
  115. package/dist/profiles/content-reader/v1/index.js +20 -0
  116. package/dist/profiles/content-reader/v1/prompts.js +162 -0
  117. package/dist/{personas → profiles}/content-reader/v1/prompts.test.js +2 -2
  118. package/dist/profiles/content-reader/v1/resources/playbooks/compare.md +36 -0
  119. package/dist/profiles/content-reader/v1/resources/playbooks/core.md +67 -0
  120. package/dist/profiles/content-reader/v1/resources/playbooks/discover.md +35 -0
  121. package/dist/profiles/content-reader/v1/resources/playbooks/explain-run.md +49 -0
  122. package/dist/profiles/content-reader/v1/resources/playbooks/index.md +14 -0
  123. package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.js +4 -4
  124. package/dist/profiles/data-analyst/v1/index.d.ts +6 -0
  125. package/dist/profiles/data-analyst/v1/index.js +20 -0
  126. package/dist/profiles/data-analyst/v1/prompts.d.ts +5 -0
  127. package/dist/profiles/data-analyst/v1/prompts.js +41 -0
  128. package/dist/profiles/data-analyst/v1/prompts.test.d.ts +4 -0
  129. package/dist/profiles/data-analyst/v1/prompts.test.js +26 -0
  130. package/dist/profiles/data-analyst/v1/resources/playbooks/core.md +41 -0
  131. package/dist/profiles/data-analyst/v1/resources/playbooks/explore.md +26 -0
  132. package/dist/profiles/data-analyst/v1/resources/playbooks/index.md +8 -0
  133. package/dist/profiles/data-analyst/v1/resources/playbooks.d.ts +10 -0
  134. package/dist/profiles/data-analyst/v1/resources/playbooks.js +33 -0
  135. package/dist/profiles/index.d.ts +24 -0
  136. package/dist/profiles/index.js +73 -0
  137. package/dist/profiles/index.test.js +121 -0
  138. package/dist/{personas → profiles}/lib/playbook-resources.d.ts +12 -10
  139. package/dist/{personas → profiles}/lib/playbook-resources.js +28 -24
  140. package/dist/profiles/organization-audit/v1/index.d.ts +6 -0
  141. package/dist/profiles/organization-audit/v1/index.js +20 -0
  142. package/dist/profiles/organization-audit/v1/prompts.js +124 -0
  143. package/dist/{personas → profiles}/organization-audit/v1/prompts.test.js +2 -2
  144. package/dist/profiles/organization-audit/v1/resources/playbooks/access.md +21 -0
  145. package/dist/profiles/organization-audit/v1/resources/playbooks/content.md +19 -0
  146. package/dist/profiles/organization-audit/v1/resources/playbooks/core.md +69 -0
  147. package/dist/profiles/organization-audit/v1/resources/playbooks/deliveries.md +14 -0
  148. package/dist/profiles/organization-audit/v1/resources/playbooks/index.md +14 -0
  149. package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.js +3 -3
  150. package/dist/profiles/profile.membership.test.js +36 -0
  151. package/dist/profiles/semantic-layer/v1/index.d.ts +6 -0
  152. package/dist/profiles/semantic-layer/v1/index.js +19 -0
  153. package/dist/profiles/semantic-layer/v1/prompts.js +96 -0
  154. package/dist/{personas → profiles}/semantic-layer/v1/prompts.test.js +2 -2
  155. package/dist/profiles/semantic-layer/v1/resources/playbooks/compose-compile.md +60 -0
  156. package/dist/profiles/semantic-layer/v1/resources/playbooks/core.md +71 -0
  157. package/dist/profiles/semantic-layer/v1/resources/playbooks/explore.md +79 -0
  158. package/dist/profiles/semantic-layer/v1/resources/playbooks/index.md +13 -0
  159. package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.js +4 -4
  160. package/dist/{personas → profiles}/types.d.ts +6 -7
  161. package/dist/{personas → profiles}/types.js +1 -1
  162. package/dist/protocol-contract.test.js +48 -3
  163. package/dist/server/capabilities.d.ts +6 -6
  164. package/dist/server/capabilities.js +11 -8
  165. package/dist/server/capabilities.test.js +8 -7
  166. package/dist/server/server.js +17 -13
  167. package/dist/server/upstream-errors.d.ts +17 -0
  168. package/dist/server/upstream-errors.js +60 -0
  169. package/dist/server/upstream-errors.test.js +50 -0
  170. package/dist/stdio.process.test.js +65 -9
  171. package/dist/tools/ai-agents/agents.d.ts +7 -0
  172. package/dist/tools/ai-agents/agents.js +32 -0
  173. package/dist/tools/ai-agents/agents.test.d.ts +1 -0
  174. package/dist/tools/ai-agents/agents.test.js +176 -0
  175. package/dist/tools/ai-agents/discovery.d.ts +9 -0
  176. package/dist/tools/ai-agents/discovery.js +73 -0
  177. package/dist/tools/ai-agents/evaluations.d.ts +14 -0
  178. package/dist/tools/ai-agents/evaluations.js +177 -0
  179. package/dist/tools/ai-agents/helpers.d.ts +63 -0
  180. package/dist/tools/ai-agents/helpers.js +321 -0
  181. package/dist/tools/ai-agents/threads.d.ts +7 -0
  182. package/dist/tools/ai-agents/threads.js +40 -0
  183. package/dist/tools/composition/explain-content.js +3 -1
  184. package/dist/tools/index.d.ts +1 -1
  185. package/dist/tools/index.js +1 -1
  186. package/dist/tools/index.test.js +16 -10
  187. package/dist/tools/lib/schema-fields.d.ts +2 -0
  188. package/dist/tools/lib/schema-fields.js +4 -1
  189. package/dist/tools/lib/stable-stringify.d.ts +1 -1
  190. package/dist/tools/lib/stable-stringify.js +1 -1
  191. package/dist/tools/organization/invariants.test.d.ts +1 -1
  192. package/dist/tools/organization/invariants.test.js +5 -5
  193. package/dist/tools/organization/inventory.js +2 -1
  194. package/dist/tools/project/content.js +5 -1
  195. package/dist/tools/project/developer-content-preview.d.ts +3 -2
  196. package/dist/tools/project/developer-content-preview.js +41 -36
  197. package/dist/tools/project/developer-content-shared.d.ts +9 -3
  198. package/dist/tools/project/developer-content-shared.js +8 -4
  199. package/dist/tools/project/developer-content.d.ts +7 -8
  200. package/dist/tools/project/developer-content.js +72 -67
  201. package/dist/tools/project/developer-get-chart-as-code.d.ts +9 -0
  202. package/dist/tools/project/developer-get-chart-as-code.js +39 -0
  203. package/dist/tools/project/developer-get-chart-as-code.test.d.ts +4 -0
  204. package/dist/tools/project/developer-get-chart-as-code.test.js +70 -0
  205. package/dist/tools/project/developer-helpers.d.ts +1 -1
  206. package/dist/tools/project/developer-helpers.js +1 -1
  207. package/dist/tools/project/get-dashboard-promote-diff.js +12 -2
  208. package/dist/tools/project/invariants.test.d.ts +1 -1
  209. package/dist/tools/project/invariants.test.js +12 -10
  210. package/dist/tools/project/parameters.js +8 -3
  211. package/dist/tools/project/projects.d.ts +1 -4
  212. package/dist/tools/project/projects.js +37 -15
  213. package/dist/tools/project/projects.test.js +70 -8
  214. package/dist/tools/project/reader-content.js +6 -3
  215. package/dist/tools/project/reader-execution.js +4 -2
  216. package/dist/tools/project/reader-export-chart-image.d.ts +6 -0
  217. package/dist/tools/project/reader-export-chart-image.js +78 -0
  218. package/dist/tools/project/reader-export-chart-image.test.d.ts +4 -0
  219. package/dist/tools/project/reader-export-chart-image.test.js +149 -0
  220. package/dist/tools/project/spaces.js +12 -4
  221. package/dist/tools/project/spaces.test.d.ts +1 -0
  222. package/dist/tools/project/spaces.test.js +47 -0
  223. package/dist/tools/query/bounded-saved-query.d.ts +4 -3
  224. package/dist/tools/query/bounded-saved-query.js +4 -6
  225. package/dist/tools/query/lifecycle.d.ts +1 -1
  226. package/dist/tools/query/lifecycle.js +25 -31
  227. package/dist/tools/query/query-ledger.d.ts +17 -9
  228. package/dist/tools/query/query-ledger.js +21 -15
  229. package/dist/tools/query/query-ledger.test.js +13 -11
  230. package/dist/tools/query/reader-tool-helpers.d.ts +4 -2
  231. package/dist/tools/query/reader-tool-helpers.js +11 -8
  232. package/dist/tools/query/reader-tool-helpers.test.js +8 -4
  233. package/dist/tools/query/run-metric-query.d.ts +6 -0
  234. package/dist/tools/query/run-metric-query.js +94 -0
  235. package/dist/tools/query/run-metric-query.test.d.ts +4 -0
  236. package/dist/tools/query/run-metric-query.test.js +116 -0
  237. package/dist/tools/registry.d.ts +71 -8
  238. package/dist/tools/registry.js +36 -6
  239. package/dist/tools/semantic/explores.js +43 -17
  240. package/dist/tools/semantic/metrics.js +22 -8
  241. package/dist/tools/semantic/query.js +25 -17
  242. package/dist/tools/shared.d.ts +28 -9
  243. package/dist/tools/shared.js +62 -29
  244. package/dist/tools/shared.test.js +100 -4
  245. package/dist/transports/streamable-http.js +75 -223
  246. package/dist/transports/streamable-http.test.js +19 -12
  247. package/package.json +5 -6
  248. package/dist/destructive/confirmation-claim.d.ts +0 -21
  249. package/dist/destructive/confirmation-claim.js +0 -87
  250. package/dist/destructive/confirmation-claim.test.js +0 -50
  251. package/dist/personas/content-developer/v1/index.d.ts +0 -10
  252. package/dist/personas/content-developer/v1/index.js +0 -51
  253. package/dist/personas/content-developer/v1/prompts.js +0 -138
  254. package/dist/personas/content-developer/v1/prompts.test.js +0 -75
  255. package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +0 -15
  256. package/dist/personas/content-developer/v1/resources/playbooks/core.md +0 -63
  257. package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +0 -55
  258. package/dist/personas/content-developer/v1/resources/playbooks/index.md +0 -13
  259. package/dist/personas/content-developer/v1/resources/playbooks.js +0 -44
  260. package/dist/personas/content-governance/v1/index.d.ts +0 -9
  261. package/dist/personas/content-governance/v1/index.js +0 -29
  262. package/dist/personas/content-reader/v1/index.d.ts +0 -8
  263. package/dist/personas/content-reader/v1/index.js +0 -37
  264. package/dist/personas/content-reader/v1/prompts.js +0 -128
  265. package/dist/personas/content-reader/v1/resources/playbooks/compare.md +0 -21
  266. package/dist/personas/content-reader/v1/resources/playbooks/core.md +0 -40
  267. package/dist/personas/content-reader/v1/resources/playbooks/discover.md +0 -13
  268. package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +0 -19
  269. package/dist/personas/content-reader/v1/resources/playbooks/index.md +0 -14
  270. package/dist/personas/index.d.ts +0 -22
  271. package/dist/personas/index.js +0 -73
  272. package/dist/personas/index.test.js +0 -109
  273. package/dist/personas/organization-audit/v1/index.d.ts +0 -8
  274. package/dist/personas/organization-audit/v1/index.js +0 -42
  275. package/dist/personas/organization-audit/v1/prompts.js +0 -92
  276. package/dist/personas/organization-audit/v1/resources/playbooks/access.md +0 -13
  277. package/dist/personas/organization-audit/v1/resources/playbooks/content.md +0 -9
  278. package/dist/personas/organization-audit/v1/resources/playbooks/core.md +0 -36
  279. package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +0 -9
  280. package/dist/personas/organization-audit/v1/resources/playbooks/index.md +0 -14
  281. package/dist/personas/persona.parity.test.js +0 -26
  282. package/dist/personas/semantic-layer/v1/index.d.ts +0 -8
  283. package/dist/personas/semantic-layer/v1/index.js +0 -32
  284. package/dist/personas/semantic-layer/v1/prompts.js +0 -85
  285. package/dist/personas/semantic-layer/v1/resources/playbooks/compose-compile.md +0 -55
  286. package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +0 -39
  287. package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +0 -76
  288. package/dist/personas/semantic-layer/v1/resources/playbooks/index.md +0 -13
  289. package/dist/store/config.d.ts +0 -11
  290. package/dist/store/config.js +0 -50
  291. package/dist/store/config.test.js +0 -56
  292. package/dist/store/create-oauth-broker-store.d.ts +0 -6
  293. package/dist/store/create-oauth-broker-store.js +0 -16
  294. package/dist/store/create-preview-store.d.ts +0 -10
  295. package/dist/store/create-preview-store.js +0 -30
  296. package/dist/store/create-session-store.d.ts +0 -19
  297. package/dist/store/create-session-store.js +0 -24
  298. package/dist/store/in-memory-preview-store.d.ts +0 -17
  299. package/dist/store/in-memory-preview-store.js +0 -72
  300. package/dist/store/redis-client.d.ts +0 -11
  301. package/dist/store/redis-client.js +0 -48
  302. package/dist/store/redis-oauth-broker-store.d.ts +0 -42
  303. package/dist/store/redis-oauth-broker-store.js +0 -167
  304. package/dist/store/redis-oauth-broker-store.test.js +0 -80
  305. package/dist/store/redis-preview-store.d.ts +0 -23
  306. package/dist/store/redis-preview-store.js +0 -94
  307. package/dist/store/redis-preview-store.test.js +0 -39
  308. package/dist/store/redis-session-index.d.ts +0 -33
  309. package/dist/store/redis-session-index.js +0 -49
  310. package/dist/store/types.d.ts +0 -13
  311. package/dist/store/types.js +0 -8
  312. package/dist/transports/http-request-utils.d.ts +0 -2
  313. package/dist/transports/http-request-utils.js +0 -13
  314. package/dist/transports/session-store.d.ts +0 -72
  315. package/dist/transports/session-store.js +0 -143
  316. package/dist/transports/session-store.test.js +0 -111
  317. /package/dist/{destructive/confirmation-claim.test.d.ts → audit/server-profile.test.d.ts} +0 -0
  318. /package/dist/{personas/index.test.d.ts → config/obsolete-env.test.d.ts} +0 -0
  319. /package/dist/{personas/persona.parity.test.d.ts → governance/mcp-post-factory-context.test.d.ts} +0 -0
  320. /package/dist/{store/config.test.d.ts → policy/envelope.test.d.ts} +0 -0
  321. /package/dist/{personas → profiles}/content-developer/v1/prompts.test.d.ts +0 -0
  322. /package/dist/{personas → profiles}/content-governance/v1/prompts.d.ts +0 -0
  323. /package/dist/{personas → profiles}/content-governance/v1/prompts.js +0 -0
  324. /package/dist/{personas → profiles}/content-governance/v1/prompts.test.d.ts +0 -0
  325. /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/charts.md +0 -0
  326. /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/index.md +0 -0
  327. /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks.d.ts +0 -0
  328. /package/dist/{personas → profiles}/content-reader/v1/prompts.d.ts +0 -0
  329. /package/dist/{personas → profiles}/content-reader/v1/prompts.test.d.ts +0 -0
  330. /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.d.ts +0 -0
  331. /package/dist/{store/redis-oauth-broker-store.test.d.ts → profiles/index.test.d.ts} +0 -0
  332. /package/dist/{personas → profiles}/organization-audit/v1/prompts.d.ts +0 -0
  333. /package/dist/{personas → profiles}/organization-audit/v1/prompts.test.d.ts +0 -0
  334. /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.d.ts +0 -0
  335. /package/dist/{store/redis-preview-store.test.d.ts → profiles/profile.membership.test.d.ts} +0 -0
  336. /package/dist/{personas → profiles}/semantic-layer/v1/prompts.d.ts +0 -0
  337. /package/dist/{personas → profiles}/semantic-layer/v1/prompts.test.d.ts +0 -0
  338. /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.d.ts +0 -0
  339. /package/dist/{transports/session-store.test.d.ts → server/upstream-errors.test.d.ts} +0 -0
@@ -0,0 +1,69 @@
1
+ # Organization-audit core
2
+
3
+ URI: `lightdash://playbooks/organization-audit/core`
4
+
5
+ ## Hard bans
6
+
7
+ - Do not mutate users, groups, roles, spaces, content, or schedulers.
8
+ - Do not execute warehouse, SQL, chart, or underlying-data queries.
9
+ - Do not download user-activity CSV (`POST .../download`).
10
+ - Do not treat `list_project_direct_access` as complete effective access (it is **direct grants only**; empty is common when access is via org role or groups).
11
+ - Do not recommend deletion solely because content has low or zero views.
12
+ - Do not claim SOC 2 / GDPR / ISO / HIPAA (or any) certification from these tools.
13
+ - Do not crawl the whole org in one pass — honor budgets below.
14
+ - Do not request warehouse/dbt secrets via MCP — credentials are never returned (ADR-0011).
15
+
16
+ ## Default budgets (override only if the user expands scope)
17
+
18
+ | Resource | Default |
19
+ | -------------------------- | ---------------------------------------------------------------------------------------------- |
20
+ | Member list pages | `pageSize=50`, stop after **3 pages** or when `pagination.complete` |
21
+ | Groups pages | `pageSize=50`, stop after **2 pages** |
22
+ | Projects in depth | **3** non-preview projects (or only those in `projectUuids` / HTTP pin) |
23
+ | Content pages per project | `pageSize=50`, **2** pages max per contentTypes pass |
24
+ | `resolve_effective_access` | `maxPrincipals=50`; prefer with a `projectUuid` (and `spaceUuid` when investigating one space) |
25
+ | Schedulers pages | `pageSize=50`, **2** pages |
26
+
27
+ Always record when you stopped early (`pagination.complete=false`, budget hit, or user-capped project list).
28
+
29
+ ## Coverage semantics (do not confuse)
30
+
31
+ - **`pagination.complete`**: this list response finished paging (or you stopped).
32
+ - **`coverage.complete`**: often **false** even when a single call succeeded — it means the _audit envelope_ is not a full org certification. **Do not** treat `coverage.complete=false` alone as “tool failed”.
33
+ - Prefer citing `pagination`, `warnings[]` codes (`REDACTED`, `INCOMPLETE_EFFECTIVE_ACCESS`, `TRUNCATED`, `V1_FALLBACK`), and `accessSemantics`.
34
+
35
+ ## Tool catalog (`lightdash_*`)
36
+
37
+ **Org inventory:** `get_org_profile`, `list_org_members`, `get_org_member`, `list_org_groups`, `list_org_projects`
38
+
39
+ **Access:** `list_org_role_assignments`, `list_custom_roles`, `get_custom_role`, `list_project_roles`, `list_project_direct_access`, `list_space_access`, `resolve_effective_access`
40
+
41
+ **Content / health:** `list_content`, `get_dashboard_meta`, `list_validation_results`, `get_project_user_activity`
42
+
43
+ **Delivery:** `list_project_schedulers`, `get_scheduler`
44
+
45
+ ## Phase 0 — Scope
46
+
47
+ 1. Call `lightdash_get_org_profile`. Record `organizationUuid`, caller role, `auditVisibility`, and `capabilities`.
48
+ 2. If `auditVisibility` is not `organization_admin`, downgrade org-wide claims and note inaccessible scopes.
49
+ 3. Call `lightdash_list_org_projects` (`includePreviewProjects=false` unless asked).
50
+ 4. **Project selection:**
51
+ - Prefer the HTTP pin (`X-Lightdash-Project`) or user-supplied `projectUuids`.
52
+ - Otherwise pick up to **3** `type=DEFAULT` projects.
53
+ - Flag (or skip unless asked) names that look soft-deleted / temporary (e.g. contain `Deleted`, `Preview`, or have `upstreamProjectUuid` set for throwaway clones).
54
+ 5. Convert prompt `allowedEmailDomains` comma-strings into **string arrays** for tools that accept `allowedEmailDomains`.
55
+
56
+ ## Phase 5 — Report template
57
+
58
+ For each finding use:
59
+
60
+ ```text
61
+ ### [severity: high|medium|low|info] Title
62
+ - Fact: …
63
+ - Evidence: tool=lightdash_… ; resource UUIDs=… ; warning codes=…
64
+ - Inference (optional): …
65
+ - Gaps: pagination/budget/redaction/incomplete effective access
66
+ - Suggested review action: … (never auto-delete / never mutate)
67
+ ```
68
+
69
+ End with: projects sampled, pages fetched, redaction state, and explicit non-certification statement.
@@ -0,0 +1,14 @@
1
+ # Organization-audit — scheduled deliveries
2
+
3
+ URI: `lightdash://playbooks/organization-audit/deliveries`
4
+
5
+ ## Phase 4 — Deliveries (per sampled project)
6
+
7
+ 1. **`lightdash_list_project_schedulers`** with required `projectUuid`. Destinations stay redacted unless the user asks for `revealDestinations=true`.
8
+ 2. Pass `allowedEmailDomains` (array) when classifying external email destinations after reveal.
9
+ 3. Note `enabled`, `format` (e.g. `gsheets`, email), `cron`, linked `savedChartUuid` / `dashboardUuid`, and creator UUIDs.
10
+ 4. **`enabled: false`** is still inventory — report as disabled schedule, not as “safe / ignore”.
11
+ 5. Use **`lightdash_get_scheduler`** (`projectUuid` + `schedulerUuid`) for one schedule when list rows are insufficient.
12
+ 6. Cross-link chart/dashboard UUIDs to `list_content` names when helpful.
13
+
14
+ Never create, edit, run, enable, disable, or delete schedules. External destinations (when revealed) are **review signals**, not automatic policy violations.
@@ -0,0 +1,14 @@
1
+ # Organization-audit playbooks
2
+
3
+ URI: `lightdash://playbooks/organization-audit`
4
+
5
+ Read-only evidence collection for Lightdash organization administrators. The host synthesizes findings from primitive `lightdash_*` tools — there are **no** composed `audit_*` tools and **no** compliance certification.
6
+
7
+ | Topic | URI | When to load |
8
+ | ---------------------------- | ----------------------------------------------------- | ------------------------------------------------- |
9
+ | Core (budgets, bans, report) | `lightdash://playbooks/organization-audit/core` | Always (embedded in every prompt) |
10
+ | Access governance | `lightdash://playbooks/organization-audit/access` | `review_access_governance` / access chapters |
11
+ | Content and health | `lightdash://playbooks/organization-audit/content` | `review_content_governance` / content chapters |
12
+ | Scheduled deliveries | `lightdash://playbooks/organization-audit/deliveries` | `review_scheduled_deliveries` / delivery chapters |
13
+
14
+ **Live-org reality check:** organizations often have hundreds of members and many projects. Default to **bounded samples** (see core budgets). Never crawl every member page or every project unless the user explicitly expands scope.
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ORGANIZATION_AUDIT_TOPIC_PLAYBOOKS = exports.ORGANIZATION_AUDIT_CORE_PLAYBOOK = exports.getAllPlaybookMarkdown = exports.ORGANIZATION_AUDIT_HARD_BANS = void 0;
7
7
  exports.registerOrganizationAuditPlaybook = registerOrganizationAuditPlaybook;
8
8
  const playbook_resources_js_1 = require("../../../lib/playbook-resources.js");
9
- const playbooks = (0, playbook_resources_js_1.definePersonaPlaybooks)({
10
- personaId: 'organization-audit',
9
+ const playbooks = (0, playbook_resources_js_1.defineProfilePlaybooks)({
10
+ profileId: 'organization-audit',
11
11
  moduleDir: __dirname,
12
- hardBans: 'Do not mutate users/groups/roles/content/schedulers, execute warehouse or chart queries, download user-activity CSV, reveal secrets, or claim compliance certification. Those capabilities are not available on this server.',
12
+ hardBans: 'Do not mutate users/groups/roles/content/schedulers, execute warehouse or chart queries, download user-activity CSV, reveal secrets, crawl unbounded org inventories, or claim compliance certification. Prefer core budgets (page/project caps). Those capabilities are not available on this server.',
13
13
  coreDescription: 'Hard bans, tool catalog, scope, and report rules',
14
14
  topics: [
15
15
  {
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const common_1 = require("@lightdash-tools/common");
4
+ const vitest_1 = require("vitest");
5
+ const index_js_1 = require("./index.js");
6
+ (0, vitest_1.describe)('profile catalog membership', () => {
7
+ (0, vitest_1.it)('ships exactly the catalog PROFILE_IDS', () => {
8
+ (0, vitest_1.expect)(Object.keys(index_js_1.PROFILES).sort()).toEqual([...common_1.PROFILE_IDS].sort());
9
+ });
10
+ (0, vitest_1.it)('every shipped profile exposes at least one MCP tool from the catalog', () => {
11
+ for (const id of common_1.PROFILE_IDS) {
12
+ (0, vitest_1.expect)((0, common_1.listMcpToolNamesByProfile)(id).length).toBeGreaterThan(0);
13
+ }
14
+ });
15
+ (0, vitest_1.it)('every exposed MCP tool is tagged with at least one serving profile', () => {
16
+ var _a;
17
+ const exposed = new Set((0, common_1.listExposedMcpToolNames)());
18
+ for (const operation of (0, common_1.listOperations)()) {
19
+ if (((_a = operation.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed) !== true) {
20
+ continue;
21
+ }
22
+ (0, vitest_1.expect)(operation.profiles.length).toBeGreaterThan(0);
23
+ (0, vitest_1.expect)(exposed.has(operation.mcp.toolName)).toBe(true);
24
+ }
25
+ });
26
+ (0, vitest_1.it)('listMcpToolNamesByProfile matches only exposed tools for each profile', () => {
27
+ var _a;
28
+ for (const id of common_1.PROFILE_IDS) {
29
+ for (const toolName of (0, common_1.listMcpToolNamesByProfile)(id)) {
30
+ const op = (0, common_1.listOperations)().find((o) => { var _a; return ((_a = o.mcp) === null || _a === void 0 ? void 0 : _a.toolName) === toolName; });
31
+ (0, vitest_1.expect)((_a = op === null || op === void 0 ? void 0 : op.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed).toBe(true);
32
+ (0, vitest_1.expect)(op === null || op === void 0 ? void 0 : op.profiles).toContain(id);
33
+ }
34
+ }
35
+ });
36
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Semantic-layer profile: compile/discovery tools + playbook/prompts.
3
+ */
4
+ import type { ProfileDefinition } from '../../types.js';
5
+ export declare const SEMANTIC_LAYER_PROFILE_PATH: "/semantic-layer/v1/mcp";
6
+ export declare const semanticLayerProfile: ProfileDefinition;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /**
3
+ * Semantic-layer profile: compile/discovery tools + playbook/prompts.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.semanticLayerProfile = exports.SEMANTIC_LAYER_PROFILE_PATH = void 0;
7
+ const prompts_js_1 = require("./prompts.js");
8
+ const playbooks_js_1 = require("./resources/playbooks.js");
9
+ exports.SEMANTIC_LAYER_PROFILE_PATH = '/semantic-layer/v1/mcp';
10
+ exports.semanticLayerProfile = {
11
+ id: 'semantic-layer',
12
+ path: exports.SEMANTIC_LAYER_PROFILE_PATH,
13
+ registerPrompts: (server) => {
14
+ (0, prompts_js_1.registerSemanticLayerPrompts)(server);
15
+ },
16
+ registerResources: (server) => {
17
+ (0, playbooks_js_1.registerSemanticLayerPlaybook)(server);
18
+ },
19
+ };
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /**
3
+ * MCP prompts for semantic-layer discovery and compile workflows.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.registerSemanticLayerPrompts = registerSemanticLayerPrompts;
7
+ const zod_1 = require("zod");
8
+ const schema_fields_js_1 = require("../../../tools/lib/schema-fields.js");
9
+ const schema_fields_js_2 = require("../../../tools/semantic/schema-fields.js");
10
+ const playbook_resources_js_1 = require("../../lib/playbook-resources.js");
11
+ const playbooks_js_1 = require("./resources/playbooks.js");
12
+ const userMessages = (0, playbook_resources_js_1.createPromptPlaybookEmbedder)({
13
+ core: playbooks_js_1.SEMANTIC_LAYER_CORE_PLAYBOOK,
14
+ topics: playbooks_js_1.SEMANTIC_LAYER_TOPIC_PLAYBOOKS,
15
+ });
16
+ function registerSemanticLayerPrompts(server) {
17
+ server.registerPrompt('lightdash_semantic_explore', {
18
+ title: 'Explore semantic layer',
19
+ description: 'Locate explores, metrics, and dimensions for a question without running warehouse queries',
20
+ argsSchema: zod_1.z.object({
21
+ projectUuid: (0, schema_fields_js_1.projectUuidField)(),
22
+ question: zod_1.z.string().optional().describe('Natural-language question or topic'),
23
+ }),
24
+ }, async ({ projectUuid, question }) => {
25
+ const topic = question ? `Question/topic: ${question}.` : '';
26
+ return userMessages(`Discover the Lightdash semantic layer for this project. Compile is out of scope unless asked.
27
+
28
+ Project UUID (required on every tool): ${projectUuid}.
29
+ ${topic}
30
+
31
+ ${playbooks_js_1.SEMANTIC_LAYER_HARD_BANS}
32
+
33
+ Procedure:
34
+ 1. get_project once to confirm name. Do not switch projects from org-wide list_projects.
35
+ 2. list_explores with search+limit (≤15). Disambiguate: skip empty schemaName / errors; prefer exact label or name __{table}; deprioritize eda_/reporting_ unless asked.
36
+ 3. list_dimensions (base table) → shortlist ≤12 fieldIds by role (time/channel/segment/entity). Copy fieldIds literally.
37
+ 4. get_explore → tables[baseTable].metrics only (≤8 names/labels). Skip list_metrics once explore is known. Skip get_metric / get_field_lineage unless needed.
38
+ 5. Deliverable: chosen explore (name/label/schemaName/databaseName + why) + field shortlist. Never dump full explore/dimension/metric/lineage payloads.
39
+
40
+ Follow embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_EXPLORE_URI}). Use only lightdash_* tools.`, 'explore');
41
+ });
42
+ server.registerPrompt('lightdash_semantic_compose_compile', {
43
+ title: 'Compose and compile query',
44
+ description: 'Build a metric query and compile it with lightdash_compile_query; never execute against the warehouse',
45
+ argsSchema: zod_1.z.object({
46
+ projectUuid: (0, schema_fields_js_1.projectUuidField)(),
47
+ question: zod_1.z.string().optional().describe('What the query should answer'),
48
+ exploreId: (0, schema_fields_js_2.exploreIdField)().optional(),
49
+ }),
50
+ }, async ({ projectUuid, question, exploreId }) => {
51
+ const topic = question ? `Goal: ${question}.` : '';
52
+ const explore = exploreId ? `Preferred explore: ${exploreId}.` : '';
53
+ return userMessages(`Compose a Lightdash metric query and compile it with lightdash_compile_query. Do not run the query.
54
+
55
+ Project UUID: ${projectUuid}.
56
+ ${topic}
57
+ ${explore}
58
+
59
+ ${playbooks_js_1.SEMANTIC_LAYER_HARD_BANS}
60
+
61
+ Procedure:
62
+ 1. If exploreId is missing, resolve it per explore playbook (search + disambiguation). Stay on this projectUuid.
63
+ 2. Copy fieldIds from list_dimensions and {exploreId}_{metricName} from get_explore → tables[baseTable].metrics. Never invent grains.
64
+ 3. If the user asked for N insights, reuse one explore and compile N diverse cuts.
65
+ 4. compile_query with fieldIds only. After each compile, verify every requested fieldId appears as a SELECT alias (missing alias = failure even without isError). ≤2 fix retries.
66
+ 5. Deliverable: insight title(s) + fieldIds + compiled SQL (or errors). Never paste full explore/dimension/metric/lineage payloads.
67
+
68
+ Follow embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_COMPOSE_COMPILE_URI}).`, 'compose-compile');
69
+ });
70
+ server.registerPrompt('lightdash_semantic_compile_debug', {
71
+ title: 'Debug compile errors',
72
+ description: 'Interpret lightdash_compile_query failures, adjust the metric query, and re-compile',
73
+ argsSchema: zod_1.z.object({
74
+ projectUuid: (0, schema_fields_js_1.projectUuidField)(),
75
+ exploreId: (0, schema_fields_js_2.exploreIdField)(),
76
+ errorText: zod_1.z.string().optional().describe('Compile error text if already known'),
77
+ }),
78
+ }, async ({ projectUuid, exploreId, errorText }) => {
79
+ const err = errorText ? `Known error: ${errorText}` : '';
80
+ return userMessages(`Debug a failing lightdash_compile_query call and re-compile until it succeeds or you explain blockers.
81
+
82
+ Project UUID: ${projectUuid}
83
+ Explore: ${exploreId}
84
+ ${err}
85
+
86
+ ${playbooks_js_1.SEMANTIC_LAYER_HARD_BANS}
87
+
88
+ Checklist:
89
+ - unknown field id / empty SELECT / missing SELECT alias → use fieldIds from list_dimensions (base table) + explore-local metrics; re-compile (≤2 retries).
90
+ - Wrong explore → re-disambiguate (schemaName; label or name __{table}; skip empty schema / eda unless asked).
91
+ - Metric not found / catalog empty → get_explore tables[baseTable].metrics; tableName must be the full explore id; compile as {exploreId}_{metricName}.
92
+ - Verify SELECT aliases after every compile. Stop after a good compile or a clear blocker.
93
+
94
+ Follow embedded playbooks (${playbooks_js_1.SEMANTIC_LAYER_CORE_URI}, ${playbooks_js_1.SEMANTIC_LAYER_COMPOSE_COMPILE_URI}).`, 'compose-compile');
95
+ });
96
+ }
@@ -3,13 +3,13 @@
3
3
  * Semantic-layer prompt/playbook invariants.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const common_1 = require("@lightdash-tools/common");
6
7
  const vitest_1 = require("vitest");
7
8
  const playbooks_js_1 = require("./resources/playbooks.js");
8
- const index_js_1 = require("./index.js");
9
9
  (0, vitest_1.describe)('semantic-layer prompts/playbook', () => {
10
10
  (0, vitest_1.it)('playbooks reference only registered tool short ids', () => {
11
11
  const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
12
- for (const id of index_js_1.SEMANTIC_LAYER_TOOL_IDS) {
12
+ for (const id of (0, common_1.listMcpToolNamesByProfile)('semantic-layer')) {
13
13
  (0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
14
14
  }
15
15
  (0, vitest_1.expect)(md).not.toMatch(/\bldt__/);
@@ -0,0 +1,60 @@
1
+ # Semantic-layer — compose & compile
2
+
3
+ URI: `lightdash://playbooks/semantic-layer/compose-compile`
4
+
5
+ ## Recommended sequence
6
+
7
+ 1. Scope: `get_project` with the user-given project UUID (do not switch from org-wide `list_projects`).
8
+ 2. Discover: search explores → disambiguate → `list_dimensions` shortlist + `get_explore` → `tables[baseTable].metrics`.
9
+ 3. Build `metricQuery` using **only** copied `fieldId`s.
10
+ 4. `compile_query` → **verify SELECT aliases** → stop (or ≤2 fix retries).
11
+
12
+ ## metricQuery skeleton
13
+
14
+ ```json
15
+ {
16
+ "exploreName": "{exploreId}",
17
+ "dimensions": ["{exploreId}_{dim}"],
18
+ "metrics": ["{exploreId}_{metric}"],
19
+ "filters": {},
20
+ "sorts": [{ "fieldId": "{exploreId}_{dim}", "descending": false }],
21
+ "limit": 50,
22
+ "tableCalculations": []
23
+ }
24
+ ```
25
+
26
+ `metrics` may be `[]`. Every string in `dimensions` / `metrics` / `sorts[].fieldId` must appear in prior tool output.
27
+
28
+ ## Field IDs — failure modes
29
+
30
+ | Symptom | Cause | Fix |
31
+ | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
32
+ | `unknown field id` / hard error | Short names or typos | Use full `fieldId` from `list_dimensions` / `{exploreId}_{metricName}` |
33
+ | Server `isError` + empty SELECT | Upstream accepted bad ids with **zero** columns | Replace with real fieldIds; re-compile once |
34
+ | SQL “succeeds” but a requested dim/metric is **missing** from SELECT | Invented or wrong fieldId (e.g. non-existent `*_session_day`) while another field still projected | Re-check against `list_dimensions` / metrics map; re-compile |
35
+ | `Metric not found` on `get_metric` | `tableName` was warehouse label | Use full explore id |
36
+
37
+ Compiled SQL may include **extra related metrics** the semantic layer pulls in — OK if every **requested** fieldId still appears as a SELECT alias.
38
+
39
+ ## Verify after every compile (mandatory)
40
+
41
+ 1. Parse the compiled `query` SELECT list (aliases / AS names).
42
+ 2. Confirm **each** requested dimension and metric `fieldId` is present.
43
+ 3. If any are missing → treat as failure even when the tool did not set `isError`.
44
+ 4. Confirm `ORDER BY` / sorts only reference fields that exist in the SELECT (or known group keys).
45
+
46
+ ## Multi-insight composition
47
+
48
+ When the user asks for N insights on one table/explore:
49
+
50
+ 1. Disambiguate explore **once**; reuse the same `exploreId` and metric shortlist.
51
+ 2. Pick **diverse** cuts from available fields (trend, categorical breakdown, rate/quality, outcome, acquisition) — only when those fields exist. Don’t repeat the same grain N times.
52
+ 3. Compile each; verify aliases; present **title + fieldIds + SQL** (or errors).
53
+ 4. Metrics that join other tables may produce large CTE SQL — still OK; mention the join briefly.
54
+
55
+ ## Debug checklist
56
+
57
+ - Empty SELECT / unknown field id / missing alias → fix fieldIds from `list_dimensions` + explore-local metrics; re-compile (≤2 retries).
58
+ - Wrong explore → re-disambiguate (`schemaName`; exact `label` or `name` `__{table}`; skip empty schema / eda unless asked).
59
+ - Catalog empty / metric not found → `get_explore` `tables[baseTable].metrics`; compile as `{exploreId}_{metricName}`.
60
+ - Stop after a good verified compile or a clear blocker.
@@ -0,0 +1,71 @@
1
+ # Semantic-layer core
2
+
3
+ URI: `lightdash://playbooks/semantic-layer/core`
4
+
5
+ ## Purpose
6
+
7
+ Discover the Lightdash semantic layer and **compose + compile** metric queries. Stop after a good compile (or a clear blocker). This server never runs warehouse queries or mutates content.
8
+
9
+ ## Hard bans
10
+
11
+ - Do **not** run / execute metric queries, SQL runner, charts, dashboards, or underlying data.
12
+ - Do **not** invent tools for validation jobs, spaces, users, groups, ACL, AI agents, or agentops — they are not on this server.
13
+ - Do **not** switch away from the user-given **Lightdash project UUID** after seeing `list_projects` (org-wide) or explore tags that mention other warehouses.
14
+ - Do **not** paste full `get_explore`, full dimension arrays, full `get_metric`, or full lineage JSON into the answer.
15
+ - Do **not** invent `fieldId`s or time-grain names — copy them from tool output only.
16
+
17
+ ## Default budgets (override only if the user expands scope)
18
+
19
+ | Resource | Default |
20
+ | ----------------------------------- | ------------------------------------------------------------------------ |
21
+ | Explore search candidates inspected | **≤10** rows from `list_explores` (`search` + `limit≤15`) |
22
+ | Explores opened with `get_explore` | **1** chosen explore (retry only if wrong explore) |
23
+ | Dimension shortlist in the answer | **≤12** fieldIds |
24
+ | Metrics shortlisted / used | **≤8** (from `tables[baseTable].metrics`) |
25
+ | `list_metrics` catalog pages | **0** once explore is known; else **≤1** page (`pageSize≤20`) and filter |
26
+ | `get_metric` | **0** by default; **≤2** only when SQL/definition is required |
27
+ | `get_field_lineage` | **0** by default; **≤1** and summarize as “N upstream models” |
28
+ | Compile retries | **≤2** after the first attempt (fix fieldIds / explore, then stop) |
29
+
30
+ Record when a budget stopped you.
31
+
32
+ ## Allowed tools (`lightdash_` prefix)
33
+
34
+ | Tool | Use for |
35
+ | ------------------------------- | --------------------------------------------------------------------------------------------- |
36
+ | `list_projects` / `get_project` | Confirm UUID ↔ name. Credentials never returned (`REDACTED` warning is normal). |
37
+ | `list_explores` | Summaries only. **Always** pass `search` + `limit`. |
38
+ | `list_dimensions` | Compact `{ name, label, table, type, fieldId }`. Default = base table only. |
39
+ | `get_explore` | **Preferred** metric menu: `tables[baseTable].metrics` names/labels only. Ignore join tables. |
40
+ | `list_metrics` / `get_metric` | Optional catalog / definition dig. Filter `tableName === exploreId`. |
41
+ | `compile_query` | Compile only — never “run”. |
42
+ | `get_field_lineage` | Optional provenance; summarize, don’t dump. |
43
+
44
+ ## Project scope (critical)
45
+
46
+ 1. Every tool call uses the **user-given Lightdash `projectUuid`**. Prefer `get_project` once to confirm the name.
47
+ 2. Without HTTP pin `X-Lightdash-Project`, `list_projects` may list the **entire org**. Do **not** switch projects because a sibling name looks related.
48
+ 3. Lightdash **project UUID** ≠ BigQuery/GCP project. Explores carry `databaseName` / `schemaName` (warehouse). One Lightdash project often embeds explores whose `databaseName` points at another warehouse project — that is normal; stay on the given UUID.
49
+ 4. Optional ceiling `LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS` may already filter `list_projects`; still pass the user’s UUID on tools.
50
+
51
+ ## Answer shape
52
+
53
+ - Explore: `name` / `label` / `schemaName` / `databaseName` + why chosen.
54
+ - Fields: short names + **full `fieldId`** (+ role: time / channel / segment / metric).
55
+ - Compile: insight title(s) + fieldIds + compiled SQL (or errors). Verify every requested fieldId appears as a SELECT alias.
56
+ - Gaps: budget hits, empty explore search, compile blockers.
57
+
58
+ ## Stop / deliverables
59
+
60
+ | Prompt | Stop when |
61
+ | --------------- | ----------------------------------------------------------------- |
62
+ | Explore | Shortlist delivered; **do not compile** unless asked |
63
+ | Compose / debug | Good compile (aliases verified) or clear blocker after ≤2 retries |
64
+ | Multi-insight | N titled compiles on **one** explore; shared discovery |
65
+
66
+ ## Tool order (default)
67
+
68
+ 1. `get_project` (confirm) → `list_explores` (`search`+`limit`) → disambiguate
69
+ 2. `list_dimensions` (base table) → shortlist by role
70
+ 3. `get_explore` → extract **only** `tables[baseTable].metrics` (names/labels)
71
+ 4. `compile_query` with copied fieldIds → verify SELECT aliases → stop
@@ -0,0 +1,79 @@
1
+ # Semantic-layer — explore / discover
2
+
3
+ URI: `lightdash://playbooks/semantic-layer/explore`
4
+
5
+ ## Always search explores
6
+
7
+ On large projects, **never** rely on an unfiltered explore list (alphabetical noise across domains). Always call `lightdash_list_explores` with **`search` + `limit` (≤15)**.
8
+
9
+ Warehouse table / dataset names are **search hints**, not explore IDs. Explore `name` is usually compound (often `{warehouse}__{dataset}__{table}`-style).
10
+
11
+ ## From warehouse inventory → explore
12
+
13
+ | Inventory hint | MCP use |
14
+ | ---------------------------- | ----------------------------------------------------------------- |
15
+ | Dataset | Prefer matching **`schemaName`** |
16
+ | TABLE | `search` = table token; prefer **exact `label`** = table |
17
+ | Partition / time field | Candidate dimension for time-grain compiles |
18
+ | Full `project.dataset.table` | `databaseName` ≈ project, `schemaName` ≈ dataset, `label` ≈ table |
19
+
20
+ Some inventory tables have **no** explore. Empty or irrelevant search → say so; try a related curated/summary table the user cares about.
21
+
22
+ ## Explore disambiguation (do not pick the first hit)
23
+
24
+ Search for `{table}` often returns siblings: staging / EDA / reporting / MRE variants, empty-schema stubs, and the warehouse table.
25
+
26
+ 1. Skip explores with non-empty `errors`.
27
+ 2. Skip rows with **empty `schemaName`** / empty tags / junk `name` (e.g. `_`) unless nothing else matches.
28
+ 3. If the user named a dataset, prefer matching **`schemaName`**.
29
+ 4. Match table via **exact `label`** = `{table}` **or** explore **`name`** containing `__{table}`.
30
+ 5. Prefer tags such as `lightdash` when still tied; deprioritize `eda_` / `reporting_` / staging-style prefixes unless asked.
31
+ 6. Duplicate labels / `_vN` suffixes: prefer the explore **`name`** without an extra version suffix unless the user asked for that version.
32
+ 7. State chosen explore **`name`**, `label`, `schemaName`, and `databaseName` in the answer.
33
+
34
+ Remember: `databaseName` may differ from the Lightdash project’s usual warehouse — stay on the given `projectUuid`.
35
+
36
+ ## Progressive discovery
37
+
38
+ 1. `list_explores` → disambiguate → lock `exploreId` (= explore `name`).
39
+ 2. `list_dimensions` (default `baseTableOnly=true`). Set `baseTableOnly=false` only if you need joined-table fields (payload grows a lot).
40
+ 3. Metrics: **`get_explore` → `tables[baseTable].metrics` only** (see below). Do not dump the explore JSON.
41
+ 4. Stop at a shortlist unless the user asked to compile.
42
+
43
+ ## Metrics: catalog vs explore-local (critical)
44
+
45
+ `list_metrics` searches the **project catalog**, not “metrics on this explore”.
46
+
47
+ | Search token | Typical result |
48
+ | -------------------------------------------- | --------------------------------------------------- |
49
+ | Full explore id | **Often zero** hits |
50
+ | Warehouse table label alone | **Often zero** |
51
+ | Broad domain tokens (`session`, `medico`, …) | Hundreds of **other** tables — flood |
52
+ | Goal keyword from the question | May hit this explore **and** siblings — must filter |
53
+
54
+ Rules:
55
+
56
+ 1. Once the explore is known, prefer **`get_explore` → `tables[baseTable].metrics`** for the local menu (names + labels only). Ignore other keys under `tables` (joins).
57
+ 2. Optional catalog: at most **one** `list_metrics` page. Keep rows where `tableName` **equals the full explore id**.
58
+ 3. `get_metric` `tableName` must be the full explore id. Short labels → “Metric not found”. Call only when definition/SQL is needed; summarize — payloads include huge `availableTimeDimensions` from joins.
59
+ 4. Compile metric ids as `{exploreId}_{metricName}` (same pattern as dimension `fieldId` from `list_dimensions`).
60
+ 5. Dimension-only (`metrics: []`) is valid for volume-by-time; for “insights” prefer real explore metrics when available.
61
+
62
+ ## Dimension shortlist (large explores)
63
+
64
+ Base tables can expose **hundreds** of dimensions; many are nested (`a.b.c` paths / event arrays). Do **not** dump the list.
65
+
66
+ Prefer high-signal fields that **appear in `list_dimensions`**, by **role**:
67
+
68
+ - Time grains that exist as real `fieldId`s (day / week / month; prefer local timezone grains when both UTC and local exist — e.g. `*_jst_day`)
69
+ - Channel / platform / traffic source
70
+ - Segment / demographic / cohort dimensions relevant to the question
71
+ - Core product or entity attributes named in the question
72
+
73
+ Skip nested event dumps and deep struct paths unless the question targets them.
74
+
75
+ **Copy `fieldId` literally.** Do not invent grains like `{explore}_session_day` if that string is not in `list_dimensions`.
76
+
77
+ ## Field lineage
78
+
79
+ `get_field_lineage` accepts full `fieldId` or short `name`. Default: skip. If used once, answer with a short summary (e.g. “upstream models: A → B → explore”) — never paste the graph.
@@ -0,0 +1,13 @@
1
+ # Semantic-layer playbooks
2
+
3
+ URI: `lightdash://playbooks/semantic-layer`
4
+
5
+ Workflow-scoped playbooks (always load **core** plus one topic with a prompt):
6
+
7
+ | Topic | URI |
8
+ | --------------------------------- | ------------------------------------------------------ |
9
+ | Core (bans, budgets, scope, stop) | `lightdash://playbooks/semantic-layer/core` |
10
+ | Explore / discover | `lightdash://playbooks/semantic-layer/explore` |
11
+ | Compose & compile | `lightdash://playbooks/semantic-layer/compose-compile` |
12
+
13
+ Discover the Lightdash semantic layer and **compose + compile** metric queries under default budgets. Stop after a verified compile (or clear compile errors). Do **not** run warehouse queries or mutate content.
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SEMANTIC_LAYER_TOPIC_PLAYBOOKS = exports.SEMANTIC_LAYER_CORE_PLAYBOOK = exports.getAllPlaybookMarkdown = exports.SEMANTIC_LAYER_HARD_BANS = exports.SEMANTIC_LAYER_COMPOSE_COMPILE_URI = exports.SEMANTIC_LAYER_EXPLORE_URI = exports.SEMANTIC_LAYER_CORE_URI = void 0;
7
7
  exports.registerSemanticLayerPlaybook = registerSemanticLayerPlaybook;
8
8
  const playbook_resources_js_1 = require("../../../lib/playbook-resources.js");
9
- const playbooks = (0, playbook_resources_js_1.definePersonaPlaybooks)({
10
- personaId: 'semantic-layer',
9
+ const playbooks = (0, playbook_resources_js_1.defineProfilePlaybooks)({
10
+ profileId: 'semantic-layer',
11
11
  moduleDir: __dirname,
12
12
  /** Shared hard-ban text for prompts (keep in sync with playbooks/core.md Hard bans section). */
13
- hardBans: 'Do not run metric/SQL/chart queries, use SQL runner, trigger validation jobs, mutate content, or call AI/identity tools. Those are not available on this server.',
14
- coreDescription: 'Hard bans, allowed tools, project scope, and stop criteria',
13
+ hardBans: 'Do not run metric/SQL/chart queries, use SQL runner, trigger validation jobs, mutate content, switch away from the given projectUuid, invent fieldIds, dump full explore/metric/lineage payloads, or call AI/identity tools. Those are not available on this server.',
14
+ coreDescription: 'Hard bans, budgets, allowed tools, project scope, and stop criteria',
15
15
  topics: [
16
16
  {
17
17
  id: 'explore',
@@ -1,19 +1,18 @@
1
1
  /**
2
- * Persona type definitions (tools selected from shared registry).
2
+ * Profile packaging types (tools from the operation catalog, ADR-0006).
3
3
  */
4
- import type { ToolId } from '../tools/registry.js';
4
+ import type { ProfileId } from '@lightdash-tools/common';
5
5
  import type { McpServer } from '@modelcontextprotocol/server';
6
- export type PersonaId = 'content-developer' | 'content-governance' | 'content-reader' | 'organization-audit' | 'semantic-layer';
7
- export type PersonaDefinition = {
8
- id: PersonaId;
9
- /** Fixed Streamable HTTP MCP endpoint path for this persona. */
6
+ export type { ProfileId };
7
+ export type ProfileDefinition = {
8
+ id: ProfileId;
9
+ /** Fixed Streamable HTTP MCP endpoint path for this profile. */
10
10
  path: `/${string}`;
11
11
  /**
12
12
  * MCP server display name. Defaults to `lightdash-mcp-${id}`.
13
13
  * Use a shorter name when combined with `lightdash_*` tools would exceed ~60 chars.
14
14
  */
15
15
  serverName?: string;
16
- toolIds: readonly ToolId[];
17
16
  registerPrompts: (server: McpServer) => void;
18
17
  registerResources: (server: McpServer) => void;
19
18
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  /**
3
- * Persona type definitions (tools selected from shared registry).
3
+ * Profile packaging types (tools from the operation catalog, ADR-0006).
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });