@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
package/README.md CHANGED
@@ -1,307 +1,183 @@
1
1
  # [@lightdash-tools/mcp](https://www.npmjs.com/package/@lightdash-tools/mcp) <!-- markdown-link-check-disable-line -->
2
2
 
3
- MCP server for Lightdash with **persona-scoped** surfaces: `semantic-layer` (explore/compile), `organization-audit` (read-only org governance), `content-reader` (saved-content discovery + bounded execution), `content-developer` (project-scoped authoring with a hard preview gate), and `content-governance` (elicitation-gated soft-delete). Tools live in a shared registry; each persona selects an explicit `lightdash_*` allowlist, prompts, and playbook. Uses `@lightdash-tools/client` for API access. See [ADR-0006](../../docs/adr/0006-mcp-personas-shared-registry-fixed-paths.md), [ADR-0010](../../docs/adr/0010-mcp-organization-audit-persona-read-only-boundary.md), [ADR-0012](../../docs/adr/0012-mcp-content-reader-persona-saved-content-execution-boundary.md), [ADR-0014](../../docs/adr/0014-mcp-content-developer-persona-mutation-boundary.md), and [ADR-0015](../../docs/adr/0015-mcp-content-governance-persona-elicitation-required-soft-delete-boundary.md).
3
+ MCP server for Lightdash with **profile-scoped** surfaces. One package, seven profiles: explore/compile, org audit, saved-content reads, chart/dashboard authoring, soft-delete governance, AI-agent ops, and ad-hoc Explore queries. Uses [`@lightdash-tools/client`](https://www.npmjs.com/package/@lightdash-tools/client) for API access. <!-- markdown-link-check-disable-line -->
4
4
 
5
- Irrecoverable admin deletes, permanent content purge, and broad org mutations stay off MCP — use `@lightdash-tools/client` or the CLI. Reversible content authoring is on `content-developer` only (preview → confirm_preview → apply; 25 tools). Soft-delete of charts/dashboards is on `content-governance` only (form elicitation required).
5
+ Developing this package? See [CONTRIBUTING.md](./CONTRIBUTING.md).
6
6
 
7
- **Response sensitivity** ([ADR-0011](../../docs/adr/0011-mcp-tool-response-sensitivity-classes.md)): `list_projects` / `get_project` return project metadata only (warehouse/dbt connection secrets are never exposed). Organization-audit tools mask emails by default (`includeEmail=true` to reveal) and redact scheduler destinations by default (`revealDestinations=true` to reveal). There is no global `withSensitive` flag.
7
+ ## Choose a profile
8
8
 
9
- ## Directory map
9
+ | Profile | Use when | HTTP path | Stdio | Catalog |
10
+ | :------------------- | :--------------------------------------- | :--------------------------- | :------------------- | :--------------------------------------------------------------- |
11
+ | `semantic-layer` | Explore metrics, compile queries | `/semantic-layer/v1/mcp` | **default** | — |
12
+ | `organization-audit` | Read-only org governance | `/organization-audit/v1/mcp` | `organization-audit` | [inventory](../../docs/profiles/organization-audit/inventory.md) |
13
+ | `content-reader` | Discover and run saved content | `/content-reader/v1/mcp` | `content-reader` | [inventory](../../docs/profiles/content-reader/inventory.md) |
14
+ | `content-developer` | Author charts/dashboards (preview gate) | `/content-developer/v1/mcp` | `content-developer` | [inventory](../../docs/profiles/content-developer/inventory.md) |
15
+ | `content-governance` | Soft-delete / promote (form elicitation) | `/content-governance/v1/mcp` | `content-governance` | [inventory](../../docs/profiles/content-governance/inventory.md) |
16
+ | `ai-agent-ops` | Thin AI-agent APIs + product eval runs | `/ai-agent-ops/v1/mcp` | `ai-agent-ops` | [inventory](../../docs/profiles/ai-agent-ops/inventory.md) |
17
+ | `data-analyst` | Unsaved Explore metric queries | `/data-analyst/v1/mcp` | `data-analyst` | [inventory](../../docs/profiles/data-analyst/inventory.md) |
10
18
 
11
- | Edit… | Path |
12
- | :------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------ |
13
- | Shared tools / registry | `src/tools/` (`registry.ts`, domain modules) |
14
- | Persona (tools allowlist, prompts, playbook, HTTP path) | `src/personas/<id>/` |
15
- | Destructive confirmation (form elicitation / MRTR) | `src/destructive/` |
16
- | HTTP transport / sessions | `src/transports/` |
17
- | HTTP auth | `src/auth/` |
18
- | Runtime client + guardrail env | `src/config/runtime.ts` |
19
- | HTTP env / loader | `src/config/env.ts`, `src/config/load-mcp-config.ts` |
20
- | Ephemeral store (memory/redis) | `src/store/` ([ADR-0016](../../docs/adr/0016-mcp-pluggable-ephemeral-store-for-http-preview-sessions-and-oauth.md)) |
21
- | Audit logging helpers | `src/audit/` |
22
- | Entrypoints | `src/bin.ts`, `src/index.ts` (stdio), `src/http.ts` |
19
+ Tool names are prefixed with `lightdash_`. MCP display names are shortened where needed for client length limits (e.g. `lightdash-mcp-content`).
23
20
 
24
- Prompts and resources are **persona-owned** (e.g. `src/personas/semantic-layer/v1/`). There is no package-level `src/prompts/` or `src/resources/`.
25
-
26
- ## Replaces `@lightdash-tools/semantic-layer-mcp`
27
-
28
- That package was removed (ADR-0006). Migrate as follows:
29
-
30
- | Removed | Use instead |
31
- | ------------------------------------- | ------------------------ |
32
- | `@lightdash-tools/semantic-layer-mcp` | `@lightdash-tools/mcp` |
33
- | Binary `lightdash-semantic-layer-mcp` | `lightdash-mcp` |
34
- | HTTP `/mcp` (old) | `/semantic-layer/v1/mcp` |
35
- | Unprefixed tool names | `lightdash_*` |
36
-
37
- ## Installation
38
-
39
- You can run the MCP server using `npx`:
40
-
41
- ```bash
42
- npx @lightdash-tools/mcp
43
- ```
44
-
45
- Or install it globally:
46
-
47
- ```bash
48
- npm install -g @lightdash-tools/mcp
49
- ```
50
-
51
- ## Transports
52
-
53
- - **Stdio** — for local use (e.g. Claude Desktop, IDE). One process per client.
54
- - **Streamable HTTP** — for remote use. Session-based; supports optional endpoint auth.
55
-
56
- ### SDK / protocol compatibility
57
-
58
- - Uses MCP TypeScript SDK v2 (`@modelcontextprotocol/server`, `@modelcontextprotocol/node`).
59
- - Speaks the established 2025-era protocol by default (not `2026-07-28` unless a future flag).
60
- - Hosted OAuth client setup: [docs/cursor-lightdash-oauth-mcp.md](../../docs/cursor-lightdash-oauth-mcp.md). Protocol/auth details: [docs/mcp-oauth-http.md](../../docs/mcp-oauth-http.md).
61
-
62
- ### Hosted OAuth (primary HTTP)
63
-
64
- Auth is **inferred** from credentials ([ADR-0007](../../docs/adr/0007-mcp-http-transport-auth-modes-sdk-v2.md)). The MCP host holds the Lightdash OAuth app client id/secret and brokers login; Claude Code / Cursor use URL-only config. Protocol reference: [MCP Authorization 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization).
65
-
66
- | What works | Gap |
67
- | :-------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
68
- | Server-held confidential client + `{PUBLIC_URL}/oauth/callback` | Full RFC 8707 audience binding on opaque Lightdash tokens |
69
- | PRM + broker AS metadata; per-user Bearer to Lightdash | MCP-local scope enforcement for opaque tokens |
70
- | Session binding to `userUuid` / `organizationUuid` | Multi-instance scale: default in-memory needs sticky routing; opt into Redis via `LIGHTDASH_TOOLS_MCP_STORE=redis` ([ADR-0016](../../docs/adr/0016-mcp-pluggable-ephemeral-store-for-http-preview-sessions-and-oauth.md)) |
71
-
72
- Authorization: Lightdash RBAC + persona tool surface ([ADR-0006](../../docs/adr/0006-mcp-personas-shared-registry-fixed-paths.md)) + optional `X-Lightdash-Project` pin. See [mcp-oauth-http.md](../../docs/mcp-oauth-http.md).
73
-
74
- ## Environment variables
75
-
76
- Preferred names use the `LIGHTDASH_TOOLS_*` prefixes (see [ADR-0009](../../docs/adr/0009-cross-cutting-conventions.md)). Prefer env vars from the parent process. Avoid plaintext `.env` when AI agents have file access. If using `.env`, use [dotenvx](https://dotenvx.com/). See [docs/secrets-and-credentials.md](../../docs/secrets-and-credentials.md).
77
-
78
- ### Stdio (secondary)
79
-
80
- | Required | Optional |
81
- | :----------------------------------- | :-------------------------- |
82
- | `LIGHTDASH_URL`, `LIGHTDASH_API_KEY` | `LIGHTDASH_TOOLS_AUDIT_LOG` |
83
-
84
- Do **not** set OAuth client secrets for stdio. MCP does not use CLI `SAFETY_MODE` / `ALLOWED_PROJECTS` / `DRY_RUN`.
85
-
86
- ### HTTP OAuth (primary)
87
-
88
- | Required | Common optional |
89
- | :-------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------- |
90
- | `LIGHTDASH_URL`, `LIGHTDASH_TOOLS_MCP_PUBLIC_URL`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_ID`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET` | port, `ALLOWED_ORIGINS`, audit log, token cache TTL |
91
-
92
- Register Lightdash redirect URI: `{PUBLIC_URL}/oauth/callback`. Clients: URL only to `/semantic-layer/v1/mcp`, `/organization-audit/v1/mcp`, `/content-reader/v1/mcp`, `/content-developer/v1/mcp`, or `/content-governance/v1/mcp`.
93
-
94
- ### Content-governance (destructive soft-delete)
95
-
96
- | Required (non-test) | Notes |
97
- | :-------------------------------------- | :------------------------------------------------------------------------------------------ |
98
- | `LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY` | ≥32-byte secret for HMAC-signed opaque `requestState` (not encrypted; fail closed if unset) |
99
- | Client form elicitation | Missing capability → `ELICITATION_REQUIRED`; no DELETE / promote |
100
-
101
- ### HTTP shared-key / local (secondary)
102
-
103
- | Mode | Env |
104
- | :--------- | :----------------------------------------------------- |
105
- | Shared-key | `LIGHTDASH_API_KEY` + `LIGHTDASH_TOOLS_MCP_SHARED_KEY` |
106
- | Local none | `NODE_ENV=development` (not `production`) |
107
-
108
- Obsolete `LIGHTDASH_TOOLS_MCP_AUTH_MODE`, `EXPERIMENTAL_*`, `DANGEROUSLY_*`, and `INSECURE_DEV` vars are **rejected**. Endpoint path is persona-owned (`LIGHTDASH_TOOLS_MCP_PATH` rejected).
109
-
110
- ### Ephemeral store (HTTP sessions / preview / OAuth)
111
-
112
- Start with **memory** (default). Add **Redis** when scaling beyond a single HTTP instance ([ADR-0016](../../docs/adr/0016-mcp-pluggable-ephemeral-store-for-http-preview-sessions-and-oauth.md)).
113
-
114
- | Env | Default | Notes |
115
- | :------------------------------ | :------- | :---------------------------------------- |
116
- | `LIGHTDASH_TOOLS_MCP_STORE` | `memory` | `memory` \| `redis` |
117
- | `LIGHTDASH_TOOLS_MCP_REDIS_URL` | — | Required when `STORE=redis` (fail closed) |
118
-
119
- What Redis shares vs what stays local:
120
-
121
- | Concern | memory | redis |
122
- | :---------------------------------- | :------------ | :-------------------------------------------------------------------------------------------------- |
123
- | Content-developer preview ledger | process-local | shared |
124
- | OAuth pending / codes / DCR clients | process-local | shared (full multi-instance OAuth) |
125
- | Streamable HTTP session transports | process-local | process-local + Redis session _index_; sticky or single instance still required for live transports |
126
-
127
- Stdio and tests use memory. Production may use memory on a single instance (HTTP logs a multi-instance/restart warning).
128
-
129
- See also: [mcp-oauth-http.md](../../docs/mcp-oauth-http.md), [cursor-lightdash-oauth-mcp.md](../../docs/cursor-lightdash-oauth-mcp.md), [cloud-run-mcp-oauth.md](../../docs/cloud-run-mcp-oauth.md), [threat model](../../docs/security/mcp-oauth-threat-model.md).
130
-
131
- ## Running
21
+ ## Quick start
132
22
 
133
23
  ### Stdio (local)
134
24
 
135
- For use with Claude Desktop or IDEs, use `npx`:
136
-
137
25
  ```bash
138
- npx @lightdash-tools/mcp
139
- # or explicit personas:
140
- npx @lightdash-tools/mcp semantic-layer
141
- npx @lightdash-tools/mcp organization-audit
142
- npx @lightdash-tools/mcp content-reader
143
- npx @lightdash-tools/mcp content-developer
144
- npx @lightdash-tools/mcp content-governance
26
+ npx @lightdash-tools/mcp # semantic-layer (default)
27
+ npx @lightdash-tools/mcp content-reader # other profiles by name
145
28
  ```
146
29
 
147
- Or if installed globally:
148
-
149
- ```bash
150
- lightdash-mcp
151
- lightdash-mcp organization-audit
152
- lightdash-mcp content-reader
153
- lightdash-mcp content-developer
154
- lightdash-mcp content-governance
30
+ Required env: `LIGHTDASH_URL`, `LIGHTDASH_API_KEY`. Logs go to **stderr**; stdout is JSON-RPC only ([stdio transport](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/stdio)).
31
+
32
+ Example Cursor / Claude Desktop config:
33
+
34
+ ```json
35
+ {
36
+ "mcpServers": {
37
+ "lightdash": {
38
+ "command": "npx",
39
+ "args": ["@lightdash-tools/mcp", "content-reader"],
40
+ "env": {
41
+ "LIGHTDASH_URL": "https://app.lightdash.cloud",
42
+ "LIGHTDASH_API_KEY": "your_pat"
43
+ }
44
+ }
45
+ }
46
+ }
155
47
  ```
156
48
 
157
- Logging goes to stderr only; stdout is JSON-RPC. Bare `lightdash-mcp` defaults to `semantic-layer`.
49
+ Or install globally: `npm install -g @lightdash-tools/mcp`, then `lightdash-mcp [profile]`.
158
50
 
159
51
  ### Streamable HTTP (remote)
160
52
 
161
53
  ```bash
162
- # Backward-compatible
163
- npx @lightdash-tools/mcp --http
164
-
165
- # Explicit subcommand
166
- npx @lightdash-tools/mcp serve-http
167
-
168
- # Hosted OAuth (server-held Lightdash confidential client)
169
54
  export LIGHTDASH_URL="https://app.lightdash.cloud"
170
55
  export LIGHTDASH_TOOLS_MCP_PUBLIC_URL="https://lightdash-mcp.example.com"
171
56
  export LIGHTDASH_TOOLS_OAUTH_CLIENT_ID="..."
172
57
  export LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET="..."
173
- npx @lightdash-tools/mcp serve-http
58
+ npx @lightdash-tools/mcp http
174
59
  ```
175
60
 
176
- The server listens on `http://localhost:3100` (or `LIGHTDASH_TOOLS_MCP_HTTP_PORT`). Persona MCP endpoints:
177
-
178
- - `POST/GET/DELETE /semantic-layer/v1/mcp`
179
- - `POST/GET/DELETE /organization-audit/v1/mcp`
180
- - `POST/GET/DELETE /content-reader/v1/mcp`
181
- - `POST/GET/DELETE /content-developer/v1/mcp`
182
- - `POST/GET/DELETE /content-governance/v1/mcp`
183
-
184
- Register `{PUBLIC_URL}/oauth/callback` in Lightdash. See [mcp-oauth-http.md](../../docs/mcp-oauth-http.md).
61
+ Profile MCP endpoints accept **POST** only ([Streamable HTTP 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http); no protocol sessions). Default listen port: `3100` (`LIGHTDASH_TOOLS_MCP_HTTP_PORT`).
185
62
 
186
- **Local Compose (dev):**
63
+ - Hosted OAuth (Cursor URL-only): [docs/operators/cursor-claude.md](../../docs/operators/cursor-claude.md)
64
+ - Operator guide: [docs/operators/mcp-oauth.md](../../docs/operators/mcp-oauth.md)
187
65
 
188
- - Unauthenticated / PAT smoke: `docker compose -f docker-compose.dev.yml --profile semantic-layer up --build` then Cursor `url: http://localhost:8080/semantic-layer/v1/mcp` (`NODE_ENV=development` + PAT from `.env`).
189
- - Hosted OAuth smoke: expose `:3100` with Cloudflare Tunnel (`cloudflared tunnel --url http://127.0.0.1:3100`), set `LIGHTDASH_TOOLS_MCP_PUBLIC_URL` in `.env` to the `*.trycloudflare.com` URL, recreate the container, register `{PUBLIC_URL}/oauth/callback` in Lightdash, and point Cursor at `{PUBLIC_URL}/semantic-layer/v1/mcp`. Do not use free ngrok. Details: [cursor-lightdash-oauth-mcp.md](../../docs/cursor-lightdash-oauth-mcp.md).
66
+ Local Compose smoke: `docker compose -f docker-compose.dev.yml --profile semantic-layer up --build` → `http://localhost:8080/semantic-layer/v1/mcp`.
190
67
 
191
- ## Tools
68
+ ## Configuration
192
69
 
193
- ### `semantic-layer` persona
70
+ Prefer `LIGHTDASH_TOOLS_*` env from the parent process. Avoid plaintext `.env` when agents can read files; if needed, use [dotenvx](https://dotenvx.com/). See [docs/operators/secrets.md](../../docs/operators/secrets.md).
194
71
 
195
- Registers these tools (names prefixed with `lightdash_`):
72
+ ### Stdio
196
73
 
197
- - **Projects**: `list_projects`, `get_project`
198
- - **Explores**: `list_explores`, `get_explore`, `list_dimensions`, `get_field_lineage`
199
- - **Metrics**: `list_metrics`, `get_metric`
200
- - **Query**: `compile_query` (empty SELECT → `isError`; no run-query)
74
+ | Required | Optional |
75
+ | :----------------------------------- | :-------------------------------------------------------------------------------------------- |
76
+ | `LIGHTDASH_URL`, `LIGHTDASH_API_KEY` | `LIGHTDASH_TOOLS_AUDIT_LOG` (file; else stderr JSON), `LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS` |
201
77
 
202
- Prompts and playbook: `lightdash://playbooks/semantic-layer` (cite `lightdash_*` names only).
78
+ Do **not** set OAuth client secrets for stdio. MCP ignores CLI `SAFETY_MODE` / `DRY_RUN`.
203
79
 
204
- ### `organization-audit` persona
80
+ ### HTTP OAuth (primary)
205
81
 
206
- Read-only organization inventory, access, content health, usage signals, and schedulers ([ADR-0010](../../docs/adr/0010-mcp-organization-audit-persona-read-only-boundary.md)). MCP server display name is `lightdash-mcp-org-audit` (60-char client limit). Endpoint inventory: [docs/organization-audit-endpoint-inventory.md](../../docs/organization-audit-endpoint-inventory.md).
82
+ | Required | Common optional |
83
+ | :-------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------- |
84
+ | `LIGHTDASH_URL`, `LIGHTDASH_TOOLS_MCP_PUBLIC_URL`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_ID`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET` | port, `ALLOWED_ORIGINS`, `ALLOWED_PROJECT_UUIDS`, token cache TTL |
207
85
 
208
- - **Inventory**: `get_org_profile`, `list_org_members`, `get_org_member`, `list_org_groups`, `list_org_projects`
209
- - **Access**: `list_org_role_assignments`, `list_custom_roles`, `get_custom_role`, `list_project_roles`, `list_project_direct_access`, `list_space_access`, `resolve_effective_access`
210
- - **Content / health**: `list_content`, `get_dashboard_meta`, `list_validation_results`, `get_project_user_activity`
211
- - **Delivery**: `list_project_schedulers`, `get_scheduler`
86
+ On Cloud Run / hosted HTTP, leave `LIGHTDASH_TOOLS_AUDIT_LOG` unset — tool audits are stderr JSON (`channel: "audit"`) → Cloud Logging. See [cloud-run.md](../../docs/operators/cloud-run.md).
212
87
 
213
- Prompts and playbook: `lightdash://playbooks/organization-audit` (host orchestrates multi-step audits via primitives). No mutation, warehouse queries, or user-activity CSV download.
88
+ Register Lightdash redirect URI: `{PUBLIC_URL}/oauth/callback`. Clients connect with URL only to a profile path above. Protocol: [MCP Authorization 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization).
214
89
 
215
- ### `content-reader` persona
90
+ ### Content-developer / content-governance signing
216
91
 
217
- Project-scoped saved-content consumption ([ADR-0012](../../docs/adr/0012-mcp-content-reader-persona-saved-content-execution-boundary.md)). MCP server display name is `lightdash-mcp-content` (60-char client limit). Endpoint inventory: [docs/content-reader-endpoint-inventory.md](../../docs/content-reader-endpoint-inventory.md).
92
+ | Required (non-test) | Notes |
93
+ | :-------------------------------------- | :---------------------------------------------------------------------------------------------- |
94
+ | `LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY` | ≥32-byte secret for HMAC `previewToken` / `requestState` (fail closed if unset; not encryption) |
218
95
 
219
- - **Scope / discovery**: `get_project`, `search_content`, `list_spaces`, `get_space`
220
- - **Metadata**: `get_dashboard`, `get_chart`, `list_project_parameters`, `get_project_parameters`, `explain_content`
221
- - **Execution**: `run_chart`, `run_dashboard_tile` (semantic saved content only; SQL charts disabled by default)
222
- - **Lifecycle**: `get_query_result`, `cancel_query` (session-owned ledger)
96
+ Governance soft-delete needs client form elicitation; missing capability → `ELICITATION_REQUIRED`.
223
97
 
224
- Project resolution: `X-Lightdash-Project` → `LIGHTDASH_TOOLS_PROJECT_UUID` → tool `projectUuid`. Prompts and playbook: `lightdash://playbooks/content-reader`.
98
+ ### HTTP shared-key / local (secondary)
225
99
 
226
- ### `content-developer` persona
100
+ | Mode | Env |
101
+ | :--------- | :----------------------------------------------------- |
102
+ | Shared-key | `LIGHTDASH_API_KEY` + `LIGHTDASH_TOOLS_MCP_SHARED_KEY` |
103
+ | Local none | `NODE_ENV=development` (not `production`) |
227
104
 
228
- Project-scoped content authoring ([ADR-0014](../../docs/adr/0014-mcp-content-developer-persona-mutation-boundary.md)). MCP server display name is `lightdash-mcp-cdev` (60-char client limit). Endpoint inventory: [docs/content-developer-endpoint-inventory.md](../../docs/content-developer-endpoint-inventory.md).
105
+ Obsolete vars (`AUTH_MODE`, `EXPERIMENTAL_*`, `DANGEROUSLY_*`, `INSECURE_DEV`, `MCP_STORE`, `MCP_REDIS_URL`, free-form `MCP_PATH`) are **rejected**. See [ADR-0019](../../docs/adr/0019-mcp-stateless-protocol-core-without-redis-ephemeral-store.md).
229
106
 
230
- - **Discovery**: `get_project`, `search_content`, `list_spaces`, `get_space`, `get_dashboard`, `get_chart`
231
- - **Preview / confirm / validate / diff**: `preview_chart_changes`, `preview_dashboard_changes`, `preview_content_move`, `confirm_preview`, `validate_chart`, `validate_dashboard`, `compare_chart_versions`, `compare_dashboard_versions`
232
- - **Charts (as-code)**: `create_chart`, `update_chart`, `duplicate_chart`
233
- - **Dashboards (REST)**: `create_dashboard`, `update_dashboard`, `duplicate_dashboard`
234
- - **Layout**: `add_dashboard_tile`, `move_dashboard_tile`, `remove_dashboard_tile`, `resize_dashboard_tile`
235
- - **Spaces**: `list_spaces`, `get_space`, `move_content` (no create/update space; use `preview_content_move` before apply)
107
+ ## Profiles at a glance
236
108
 
237
- Hard gate (25 tools): every SAFE_WRITE requires preview → `confirm_preview` → apply. Apply is claim → mutate → mark applied (not delete-before-I/O); `contentHash` must match the apply payload. Ephemeral preview ledger defaults to `LIGHTDASH_TOOLS_MCP_STORE=memory`; use `redis` for multi-instance HTTP ([ADR-0016](../../docs/adr/0016-mcp-pluggable-ephemeral-store-for-http-preview-sessions-and-oauth.md)). No warehouse execution, SQL authoring, or hard delete in v1. Same project resolution as content-reader. Prompts and playbook: `lightdash://playbooks/content-developer`.
109
+ ### `semantic-layer`
238
110
 
239
- ### `content-governance` persona
111
+ Projects, explores, metrics, and `compile_query` (no warehouse run). Playbook: `lightdash://playbooks/semantic-layer`.
240
112
 
241
- Project-scoped soft-delete with form elicitation ([ADR-0015](../../docs/adr/0015-mcp-content-governance-persona-elicitation-required-soft-delete-boundary.md)). MCP server display name is `lightdash-mcp-gov` (60-char client limit). Endpoint inventory: [docs/content-governance-endpoint-inventory.md](../../docs/content-governance-endpoint-inventory.md). Client matrix: [docs/content-governance-client-compatibility.md](../../docs/content-governance-client-compatibility.md).
113
+ ### `organization-audit`
242
114
 
243
- - **Soft-delete**: `delete_chart`, `delete_dashboard` (restorable; permanent purge is client-only)
244
- - **Promote**: `get_dashboard_promote_diff`, elicitation-gated `promote_dashboard` (upstream via Data Ops config)
245
- - **Confirmation**: MCP form elicitation (`decision` + typed `confirmationText`) + HMAC-signed opaque `requestState` (do not put secrets in the token payload); fail closed without form capability
246
- - **Not included**: bulk delete, space delete, permanent purge, chart/SQL promote, authoring, warehouse queries
115
+ Read-only inventory, access, content health, usage, and schedulers. No mutations or warehouse queries. Server name: `lightdash-mcp-org-audit`.
247
116
 
248
- Prompts and playbooks: `lightdash://playbooks/content-governance` (core + charts + dashboards topics).
117
+ ### `content-reader`
249
118
 
250
- ### CLI Binary
119
+ Project-scoped discovery, metadata, bounded `run_chart` / `run_dashboard_tile`, and `export_chart_image` (PNG). SQL charts off by default. Project: `X-Lightdash-Project` or tool `projectUuid`. Server name: `lightdash-mcp-content`.
251
120
 
252
- If installed globally, you can use the `lightdash-mcp` binary:
121
+ ### `content-developer`
253
122
 
254
- ```bash
255
- lightdash-mcp --help
256
- ```
123
+ Author charts (as-code) and dashboards behind preview → `confirm_preview` → apply with HMAC `previewToken`. No warehouse execution or hard delete. Server name: `lightdash-mcp-cdev`.
257
124
 
258
- ### CLI Options
125
+ ### `content-governance`
259
126
 
260
- - `--http` — Run as HTTP server instead of Stdio.
261
- - `stdio` / `semantic-layer` / `organization-audit` / `content-reader` / `content-developer` / `content-governance` / `serve-http` — Explicit transport/persona subcommands.
127
+ Soft-delete charts/dashboards and elicitation-gated dashboard promote. Permanent purge stays off MCP. Server name: `lightdash-mcp-gov`.
262
128
 
263
- ## Safety (persona-first)
129
+ ### `ai-agent-ops`
264
130
 
265
- MCP safety is **persona-first** ([ADR-0006](../../docs/adr/0006-mcp-personas-shared-registry-fixed-paths.md), [ADR-0008](../../docs/adr/0008-mcp-request-scope-and-hardening.md)):
131
+ Thin AI-agent inventory, readiness, thread reads, and product evaluation suite/run APIs. No agent CRUD or thread generate on MCP. Server name: `lightdash-mcp-aops`. Loop engineering: [docs/profiles/ai-agent-ops/loop.md](../../docs/profiles/ai-agent-ops/loop.md).
266
132
 
267
- | Concern | Mechanism |
268
- | :----------- | :----------------------------------------------------------------------------------------------------------------- |
269
- | Which tools | Persona `toolIds` in code (including `content-governance` soft-delete) |
270
- | Who | Auth mode + Lightdash API RBAC |
271
- | Where (HTTP) | Optional `X-Lightdash-Project` pin; content-reader/content-developer also use `LIGHTDASH_TOOLS_PROJECT_UUID` |
272
- | Hardening | Input validation + audit log + org-audit GET asserts + preview ledger + elicitation/`requestState` for soft-delete |
133
+ ### `data-analyst`
273
134
 
274
- Process `LIGHTDASH_TOOLS_SAFETY_MODE` / allowlist / dry-run are **CLI-only**, not used by this package.
135
+ Unsaved Explore-style metric queries (`run_metric_query`) with explore discovery and optional `compile_query`. Bounded rows; no chart save. Server name: `lightdash-mcp-analyst`.
275
136
 
276
- ### Agent-safe surface
137
+ ## Safety
277
138
 
278
- See [ADR-0004](../../docs/adr/0004-agent-safe-exposure-mcp-cli-vs-client-only.md) and [ADR-0006](../../docs/adr/0006-mcp-personas-shared-registry-fixed-paths.md). Irrecoverable admin deletes and permanent content purge stay on `@lightdash-tools/client` / CLI. Content authoring is limited to `content-developer` ([ADR-0014](../../docs/adr/0014-mcp-content-developer-persona-mutation-boundary.md)). Soft-delete is limited to `content-governance` with form elicitation ([ADR-0015](../../docs/adr/0015-mcp-content-governance-persona-elicitation-required-soft-delete-boundary.md)).
139
+ - **Off MCP:** irrecoverable admin deletes, permanent content purge, broad org mutations — use `@lightdash-tools/client` or the CLI ([ADR-0004](../../docs/adr/0004-agent-safe-exposure-mcp-cli-vs-client-only.md)).
140
+ - **Writes:** only on `content-developer` (preview gate). Soft-delete / promote: only on `content-governance` (form elicitation).
141
+ - **Redaction:** emails masked unless `includeEmail=true`; scheduler destinations redacted unless `revealDestinations=true`; warehouse/dbt connection secrets never on MCP ([ADR-0011](../../docs/adr/0011-mcp-tool-response-sensitivity-classes.md)).
142
+ - **Project scope:** optional HTTP pin `X-Lightdash-Project`, else tool `projectUuid`; optional ceiling `LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS`.
279
143
 
280
- ### Input validation
144
+ Profile tool allowlists are the capability surface — not CLI safety-mode.
281
145
 
282
- Resource IDs (project UUIDs, slugs) are validated before execution. Invalid inputs (control characters, `?`, `#`, `%`, path traversal) are rejected. See [docs/agent-context/CONTEXT.md](../../docs/agent-context/CONTEXT.md).
146
+ ## Upstream API failures
283
147
 
284
- ## Testing
148
+ When a tool handler throws (for example a Lightdash HTTP/API failure), MCP returns a **tool execution error** (`isError: true`) with structured `{ error: { code, message } }` — not a JSON-RPC protocol error — so clients/models can self-correct ([MCP tools error handling](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling)).
285
149
 
286
- This package includes unit tests and integration tests. Integration tests run against a real Lightdash API and are only executed if the required environment variables are set.
150
+ | Code | Typical cause |
151
+ | :---------------------- | :--------------------------------------------- |
152
+ | `RATE_LIMITED` | HTTP 429 |
153
+ | `UPSTREAM_TRANSIENT` | Network errors, 408, 5xx |
154
+ | `UPSTREAM_NOT_FOUND` | HTTP 404 |
155
+ | `UPSTREAM_FORBIDDEN` | HTTP 403 |
156
+ | `UPSTREAM_UNSUPPORTED` | HTTP 501 |
157
+ | `UPSTREAM_VALIDATION` | HTTP 400 / 422 (including new required fields) |
158
+ | `UPSTREAM_CLIENT_ERROR` | Other 4xx |
159
+ | `UPSTREAM_CONTRACT` | Success HTTP but unexpected response shape |
160
+ | `IMAGE_TOO_LARGE` | Chart PNG over size limit |
161
+ | `UPSTREAM_UNKNOWN` | Non-API throws |
287
162
 
288
- ### Running unit tests
163
+ Intentional API upgrades still go through the pinned OpenAPI sync (`config/lightdash-openapi-ref.txt`). This layer only makes runtime drift fail safely and legibly.
289
164
 
290
- ```bash
291
- pnpm test
292
- ```
165
+ ## Migration from `@lightdash-tools/semantic-layer-mcp`
293
166
 
294
- ### Running integration tests
295
-
296
- To run tests against a real Lightdash instance, provide your credentials:
297
-
298
- ```bash
299
- LIGHTDASH_URL=https://app.lightdash.cloud LIGHTDASH_API_KEY=your_api_key pnpm test
300
- ```
167
+ | Removed | Use instead |
168
+ | :------------------------------------ | :----------------------- |
169
+ | `@lightdash-tools/semantic-layer-mcp` | `@lightdash-tools/mcp` |
170
+ | Binary `lightdash-semantic-layer-mcp` | `lightdash-mcp` |
171
+ | HTTP `/mcp` (old) | `/semantic-layer/v1/mcp` |
172
+ | Unprefixed tool names | `lightdash_*` |
301
173
 
302
- The integration tests will automatically detect these environment variables and run additional scenarios, such as verifying authentication and tool execution against the live API.
174
+ ## Further reading
303
175
 
304
- For OAuth HTTP mode, set `LIGHTDASH_TOOLS_TEST_OAUTH_ACCESS_TOKEN` (and `LIGHTDASH_URL`) to run the optional live OAuth integration test.
176
+ - Architecture / contributing — [CONTRIBUTING.md](./CONTRIBUTING.md)
177
+ - OAuth operator guide — [docs/operators/mcp-oauth.md](../../docs/operators/mcp-oauth.md)
178
+ - Cursor hosted OAuth — [docs/operators/cursor-claude.md](../../docs/operators/cursor-claude.md)
179
+ - Architecture decisions — [docs/adr/](../../docs/adr/)
180
+ - MCP transports — [2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports)
305
181
 
306
182
  ## License
307
183
 
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Bind an MCP server instance to a profile id for audit attribution and
3
+ * profile-aware tool registration (envelopes, get_project capabilities).
4
+ * Call once in registerCapabilities before registering tools; registerToolSafe
5
+ * and tool registrars read it via getServerProfile / requireServerProfile.
6
+ */
7
+ import type { ProfileId } from '@lightdash-tools/common';
8
+ /** Associate a profile id with an MCP server (call before registering tools). */
9
+ export declare function bindServerProfile(server: object, profileId: ProfileId): void;
10
+ /** Profile id bound to this server, if any. */
11
+ export declare function getServerProfile(server: object): ProfileId | undefined;
12
+ /** Fail closed when a registrar runs without bindServerProfile. */
13
+ export declare function requireServerProfile(server: object, toolId: string): ProfileId;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Bind an MCP server instance to a profile id for audit attribution and
4
+ * profile-aware tool registration (envelopes, get_project capabilities).
5
+ * Call once in registerCapabilities before registering tools; registerToolSafe
6
+ * and tool registrars read it via getServerProfile / requireServerProfile.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.bindServerProfile = bindServerProfile;
10
+ exports.getServerProfile = getServerProfile;
11
+ exports.requireServerProfile = requireServerProfile;
12
+ const serverProfile = new WeakMap();
13
+ /** Associate a profile id with an MCP server (call before registering tools). */
14
+ function bindServerProfile(server, profileId) {
15
+ serverProfile.set(server, profileId);
16
+ }
17
+ /** Profile id bound to this server, if any. */
18
+ function getServerProfile(server) {
19
+ return serverProfile.get(server);
20
+ }
21
+ /** Fail closed when a registrar runs without bindServerProfile. */
22
+ function requireServerProfile(server, toolId) {
23
+ const profile = getServerProfile(server);
24
+ if (!profile) {
25
+ throw new Error(`profileId is required to register ${toolId}`);
26
+ }
27
+ return profile;
28
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const server_profile_js_1 = require("./server-profile.js");
5
+ (0, vitest_1.describe)('server-profile', () => {
6
+ (0, vitest_1.it)('bindServerProfile / getServerProfile round-trip', () => {
7
+ const server = {};
8
+ (0, vitest_1.expect)((0, server_profile_js_1.getServerProfile)(server)).toBeUndefined();
9
+ (0, server_profile_js_1.bindServerProfile)(server, 'content-developer');
10
+ (0, vitest_1.expect)((0, server_profile_js_1.getServerProfile)(server)).toBe('content-developer');
11
+ });
12
+ (0, vitest_1.it)('requireServerProfile returns the bound id', () => {
13
+ const server = {};
14
+ (0, server_profile_js_1.bindServerProfile)(server, 'content-reader');
15
+ (0, vitest_1.expect)((0, server_profile_js_1.requireServerProfile)(server, 'list_spaces')).toBe('content-reader');
16
+ });
17
+ (0, vitest_1.it)('requireServerProfile throws when unbound', () => {
18
+ const server = {};
19
+ (0, vitest_1.expect)(() => (0, server_profile_js_1.requireServerProfile)(server, 'list_spaces')).toThrow(/profileId is required/);
20
+ });
21
+ });
@@ -1,9 +1,8 @@
1
1
  /**
2
- * OAuth broker pending / codes / DCR clients (ADR-0007 / ADR-0016).
2
+ * OAuth broker pending / codes / DCR clients (ADR-0007 / ADR-0019).
3
3
  *
4
- * All values are JSON-serializable (redirect URI sets become string arrays on Redis).
5
- * Backends: in-memory (default) or Redis via `createOAuthBrokerStore` — full multi-instance
6
- * handoff for authorize → callback → token when STORE=redis.
4
+ * All values are JSON-serializable. Backend: in-memory only — process-local.
5
+ * Multi-instance OAuth needs sticky `/oauth/*` or a single replica until signed-state/CIMD.
7
6
  */
8
7
  export interface PendingAuthorization {
9
8
  /** Broker state sent to Lightdash (opaque). */
@@ -54,8 +53,8 @@ export type OAuthBrokerStoreOptions = {
54
53
  maxClients?: number;
55
54
  };
56
55
  /**
57
- * Pluggable OAuth broker ephemeral store (ADR-0016).
58
- * All methods are async so Redis and memory share one call-site shape.
56
+ * OAuth broker ephemeral store (ADR-0019). In-memory only (process-local).
57
+ * Async methods keep call sites await-uniform for future backends if needed.
59
58
  */
60
59
  export interface OAuthBrokerStore {
61
60
  registerClient(redirectUris: readonly string[]): Promise<RegisteredClient | undefined>;
@@ -69,7 +68,7 @@ export interface OAuthBrokerStore {
69
68
  tokenType?: string;
70
69
  scope?: string;
71
70
  }): Promise<IssuedAuthorizationCode | undefined>;
72
- /** Atomic get+delete (multi-instance-safe consume). */
71
+ /** Atomic get+delete for one-time code consume. */
73
72
  takeCode(code: string): Promise<IssuedAuthorizationCode | undefined>;
74
73
  /**
75
74
  * Re-insert a previously taken code with remaining TTL based on `createdAt`
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  /**
3
- * OAuth broker pending / codes / DCR clients (ADR-0007 / ADR-0016).
3
+ * OAuth broker pending / codes / DCR clients (ADR-0007 / ADR-0019).
4
4
  *
5
- * All values are JSON-serializable (redirect URI sets become string arrays on Redis).
6
- * Backends: in-memory (default) or Redis via `createOAuthBrokerStore` — full multi-instance
7
- * handoff for authorize → callback → token when STORE=redis.
5
+ * All values are JSON-serializable. Backend: in-memory only — process-local.
6
+ * Multi-instance OAuth needs sticky `/oauth/*` or a single replica until signed-state/CIMD.
8
7
  */
9
8
  Object.defineProperty(exports, "__esModule", { value: true });
10
9
  exports.InMemoryOAuthBrokerStore = exports.DEFAULT_MAX_CLIENTS = exports.DEFAULT_MAX_CODES = exports.DEFAULT_MAX_PENDING = exports.DEFAULT_CLIENT_TTL_MS = exports.DEFAULT_CODE_TTL_MS = exports.DEFAULT_PENDING_TTL_MS = void 0;
@@ -1,6 +1,5 @@
1
1
  /**
2
- * In-memory OAuthBrokerStore unit tests (ADR-0016).
3
- * Redis path is covered only when LIGHTDASH_TOOLS_MCP_REDIS_URL is set
4
- * (skipped otherwise — no Redis required for default CI).
2
+ * In-memory OAuthBrokerStore unit tests (ADR-0019).
3
+ * Redis backend removed per ADR-0019; always memory.
5
4
  */
6
5
  export {};
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
2
  /**
3
- * In-memory OAuthBrokerStore unit tests (ADR-0016).
4
- * Redis path is covered only when LIGHTDASH_TOOLS_MCP_REDIS_URL is set
5
- * (skipped otherwise — no Redis required for default CI).
3
+ * In-memory OAuthBrokerStore unit tests (ADR-0019).
4
+ * Redis backend removed per ADR-0019; always memory.
6
5
  */
7
6
  Object.defineProperty(exports, "__esModule", { value: true });
8
7
  const vitest_1 = require("vitest");
9
- const create_oauth_broker_store_js_1 = require("../../store/create-oauth-broker-store.js");
10
- const redis_client_js_1 = require("../../store/redis-client.js");
11
8
  const pending_store_js_1 = require("./pending-store.js");
12
9
  (0, vitest_1.describe)('InMemoryOAuthBrokerStore', () => {
13
10
  (0, vitest_1.it)('createPending / takePending is single-use', async () => {
@@ -110,37 +107,3 @@ const pending_store_js_1 = require("./pending-store.js");
110
107
  (0, vitest_1.expect)(await store.registerClient(['http://127.0.0.1:1/cb2'])).toBeUndefined();
111
108
  });
112
109
  });
113
- (0, vitest_1.describe)('createOAuthBrokerStore', () => {
114
- var _a;
115
- (0, vitest_1.it)('returns memory store by default', async () => {
116
- const store = (0, create_oauth_broker_store_js_1.createOAuthBrokerStore)({ backend: 'memory' });
117
- const pending = await store.createPending({
118
- clientId: 'c1',
119
- redirectUri: 'http://127.0.0.1:1/cb',
120
- codeChallenge: 'ch',
121
- codeChallengeMethod: 'S256',
122
- });
123
- (0, vitest_1.expect)(pending === null || pending === void 0 ? void 0 : pending.brokerState).toBeTruthy();
124
- });
125
- const redisUrl = (_a = process.env.LIGHTDASH_TOOLS_MCP_REDIS_URL) === null || _a === void 0 ? void 0 : _a.trim();
126
- const describeRedis = redisUrl ? vitest_1.describe : vitest_1.describe.skip;
127
- describeRedis('redis backend', () => {
128
- (0, vitest_1.afterEach)(async () => {
129
- await (0, redis_client_js_1.resetSharedRedisClientForTests)();
130
- });
131
- (0, vitest_1.it)('persists pending across store instances', async () => {
132
- const config = { backend: 'redis', redisUrl: redisUrl };
133
- const a = (0, create_oauth_broker_store_js_1.createOAuthBrokerStore)(config);
134
- const pending = await a.createPending({
135
- clientId: 'c1',
136
- redirectUri: 'http://127.0.0.1:1/cb',
137
- codeChallenge: 'ch',
138
- codeChallengeMethod: 'S256',
139
- });
140
- (0, vitest_1.expect)(pending).toBeDefined();
141
- const b = (0, create_oauth_broker_store_js_1.createOAuthBrokerStore)(config);
142
- const taken = await b.takePending(pending.brokerState);
143
- (0, vitest_1.expect)(taken === null || taken === void 0 ? void 0 : taken.clientId).toBe('c1');
144
- });
145
- });
146
- });