@lightdash-tools/mcp 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -170
- package/dist/audit/server-persona.d.ts +10 -0
- package/dist/audit/server-persona.js +19 -0
- package/dist/auth/oauth-broker/pending-store.d.ts +69 -19
- package/dist/auth/oauth-broker/pending-store.js +52 -26
- package/dist/auth/oauth-broker/pending-store.test.d.ts +5 -0
- package/dist/auth/oauth-broker/pending-store.test.js +109 -0
- package/dist/auth/oauth-broker/routes.d.ts +6 -2
- package/dist/auth/oauth-broker/routes.js +25 -20
- package/dist/auth/oauth-broker/routes.test.js +33 -28
- package/dist/auth/request-state-key.d.ts +19 -0
- package/dist/auth/request-state-key.js +49 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +0 -2
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +0 -19
- package/dist/auth/resource-server/www-authenticate.test.js +12 -8
- package/dist/bin.js +30 -2
- package/dist/config/env.d.ts +5 -8
- package/dist/config/env.js +6 -9
- package/dist/config/load-mcp-config.d.ts +0 -4
- package/dist/config/load-mcp-config.js +8 -5
- package/dist/config/load-mcp-config.test.js +7 -0
- package/dist/config/normalize-url.test.js +16 -7
- package/dist/config/runtime.d.ts +3 -3
- package/dist/config/runtime.js +19 -23
- package/dist/config/runtime.test.js +23 -9
- package/dist/config/test-mcp-http-config.js +1 -1
- package/dist/destructive/capability.d.ts +13 -0
- package/dist/destructive/capability.js +37 -0
- package/dist/destructive/capability.test.js +46 -0
- package/dist/destructive/confirmation.d.ts +58 -0
- package/dist/destructive/confirmation.js +99 -0
- package/dist/destructive/confirmation.test.d.ts +1 -0
- package/dist/destructive/confirmation.test.js +75 -0
- package/dist/destructive/content-promote.d.ts +8 -0
- package/dist/destructive/content-promote.js +150 -0
- package/dist/destructive/content-soft-delete.d.ts +7 -0
- package/dist/destructive/content-soft-delete.js +106 -0
- package/dist/destructive/destructive-contract.test.d.ts +1 -0
- package/dist/destructive/destructive-contract.test.js +269 -0
- package/dist/destructive/precondition.d.ts +14 -0
- package/dist/destructive/precondition.js +31 -0
- package/dist/destructive/precondition.test.d.ts +1 -0
- package/dist/destructive/precondition.test.js +72 -0
- package/dist/destructive/promote-contract.test.d.ts +1 -0
- package/dist/destructive/promote-contract.test.js +398 -0
- package/dist/destructive/register-destructive-tool.d.ts +54 -0
- package/dist/destructive/register-destructive-tool.js +283 -0
- package/dist/destructive/request-state.d.ts +12 -0
- package/dist/destructive/request-state.js +41 -0
- package/dist/destructive/types.d.ts +65 -0
- package/dist/destructive/types.js +10 -0
- package/dist/governance/available-projects.d.ts +37 -0
- package/dist/governance/available-projects.js +132 -0
- package/dist/governance/available-projects.test.d.ts +4 -0
- package/dist/governance/available-projects.test.js +107 -0
- package/dist/governance/client-capabilities-cache.d.ts +44 -0
- package/dist/governance/client-capabilities-cache.js +142 -0
- package/dist/governance/client-capabilities-cache.test.d.ts +1 -0
- package/dist/governance/client-capabilities-cache.test.js +148 -0
- package/dist/governance/mcp-client-session.d.ts +10 -0
- package/dist/governance/mcp-client-session.js +31 -0
- package/dist/governance/mcp-client-session.test.d.ts +1 -0
- package/dist/governance/mcp-client-session.test.js +31 -0
- package/dist/governance/project-scope.d.ts +24 -0
- package/dist/governance/project-scope.js +71 -0
- package/dist/governance/project-scope.test.d.ts +4 -0
- package/dist/governance/project-scope.test.js +80 -0
- package/dist/governance/promote-allowlist.d.ts +18 -0
- package/dist/governance/promote-allowlist.js +66 -0
- package/dist/governance/promote-allowlist.test.d.ts +4 -0
- package/dist/governance/promote-allowlist.test.js +87 -0
- package/dist/http.integration.test.js +151 -262
- package/dist/http.test.js +0 -12
- package/dist/index.integration.test.js +0 -4
- package/dist/index.js +3 -1
- package/dist/personas/ai-agent-ops/v1/index.d.ts +8 -0
- package/dist/personas/ai-agent-ops/v1/index.js +41 -0
- package/dist/personas/ai-agent-ops/v1/prompts.d.ts +5 -0
- package/dist/personas/ai-agent-ops/v1/prompts.js +141 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.d.ts +4 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.js +26 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/core.md +39 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/evaluation.md +25 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +28 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/release-gate.md +22 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-developer/v1/index.d.ts +10 -0
- package/dist/personas/content-developer/v1/index.js +52 -0
- package/dist/personas/content-developer/v1/prompts.d.ts +8 -0
- package/dist/personas/content-developer/v1/prompts.js +157 -0
- package/dist/personas/content-developer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-developer/v1/prompts.test.js +231 -0
- package/dist/personas/content-developer/v1/resources/playbooks/chart-types.md +123 -0
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +22 -0
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +105 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboard-design.md +153 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +103 -0
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +15 -0
- package/dist/personas/content-developer/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-developer/v1/resources/playbooks.js +63 -0
- package/dist/personas/content-governance/v1/index.d.ts +9 -0
- package/dist/personas/content-governance/v1/index.js +29 -0
- package/dist/personas/content-governance/v1/prompts.d.ts +5 -0
- package/dist/personas/content-governance/v1/prompts.js +87 -0
- package/dist/personas/content-governance/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-governance/v1/prompts.test.js +75 -0
- package/dist/personas/content-governance/v1/resources/playbooks/charts.md +29 -0
- package/dist/personas/content-governance/v1/resources/playbooks/core.md +52 -0
- package/dist/personas/content-governance/v1/resources/playbooks/dashboards.md +48 -0
- package/dist/personas/content-governance/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/content-governance/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-governance/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-reader/v1/index.d.ts +8 -0
- package/dist/personas/content-reader/v1/index.js +38 -0
- package/dist/personas/content-reader/v1/prompts.d.ts +5 -0
- package/dist/personas/content-reader/v1/prompts.js +162 -0
- package/dist/personas/content-reader/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-reader/v1/prompts.test.js +25 -0
- package/dist/personas/content-reader/v1/resources/playbooks/compare.md +36 -0
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +67 -0
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +35 -0
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +49 -0
- package/dist/personas/content-reader/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/content-reader/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-reader/v1/resources/playbooks.js +49 -0
- package/dist/personas/index.d.ts +4 -0
- package/dist/personas/index.js +31 -10
- package/dist/personas/index.test.js +92 -26
- package/dist/personas/lib/playbook-resources.d.ts +80 -0
- package/dist/personas/lib/playbook-resources.js +169 -0
- package/dist/personas/organization-audit/v1/index.js +2 -2
- package/dist/personas/organization-audit/v1/prompts.js +79 -66
- package/dist/personas/organization-audit/v1/prompts.test.js +4 -4
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +21 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +19 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/core.md +69 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +14 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.js +41 -0
- package/dist/personas/persona.parity.test.d.ts +1 -0
- package/dist/personas/persona.parity.test.js +30 -0
- package/dist/personas/semantic-layer/v1/index.js +2 -2
- package/dist/personas/semantic-layer/v1/prompts.js +56 -67
- package/dist/personas/semantic-layer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/semantic-layer/v1/prompts.test.js +19 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/compose-compile.md +60 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +71 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +79 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.d.ts +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.js +39 -0
- package/dist/personas/types.d.ts +1 -1
- package/dist/policy/content-developer.d.ts +35 -0
- package/dist/policy/content-developer.js +91 -0
- package/dist/policy/content-developer.test.d.ts +4 -0
- package/dist/policy/content-developer.test.js +54 -0
- package/dist/policy/content-reader.d.ts +28 -0
- package/dist/policy/content-reader.js +67 -0
- package/dist/policy/content-reader.test.d.ts +4 -0
- package/dist/policy/content-reader.test.js +23 -0
- package/dist/policy/envelope.d.ts +31 -0
- package/dist/policy/envelope.js +24 -0
- package/dist/policy/preview-ledger-fault.test.d.ts +1 -0
- package/dist/policy/preview-ledger-fault.test.js +202 -0
- package/dist/policy/preview-ledger.d.ts +82 -0
- package/dist/policy/preview-ledger.js +165 -0
- package/dist/policy/preview-ledger.test.d.ts +1 -0
- package/dist/policy/preview-ledger.test.js +393 -0
- package/dist/policy/result-limits.d.ts +32 -0
- package/dist/policy/result-limits.js +106 -0
- package/dist/policy/result-limits.test.d.ts +4 -0
- package/dist/policy/result-limits.test.js +37 -0
- package/dist/server/capabilities.js +3 -1
- package/dist/server/capabilities.test.js +5 -1
- package/dist/server/server.js +16 -1
- package/dist/server/upstream-errors.d.ts +17 -0
- package/dist/server/upstream-errors.js +60 -0
- package/dist/server/upstream-errors.test.d.ts +1 -0
- package/dist/server/upstream-errors.test.js +50 -0
- package/dist/stdio.process.test.js +150 -0
- package/dist/tools/ai-agents/agents.d.ts +7 -0
- package/dist/tools/ai-agents/agents.js +32 -0
- package/dist/tools/ai-agents/agents.test.d.ts +1 -0
- package/dist/tools/ai-agents/agents.test.js +176 -0
- package/dist/tools/ai-agents/discovery.d.ts +9 -0
- package/dist/tools/ai-agents/discovery.js +73 -0
- package/dist/tools/ai-agents/evaluations.d.ts +14 -0
- package/dist/tools/ai-agents/evaluations.js +177 -0
- package/dist/tools/ai-agents/helpers.d.ts +64 -0
- package/dist/tools/ai-agents/helpers.js +323 -0
- package/dist/tools/ai-agents/threads.d.ts +7 -0
- package/dist/tools/ai-agents/threads.js +40 -0
- package/dist/tools/composition/explain-content.d.ts +6 -0
- package/dist/tools/composition/explain-content.js +108 -0
- package/dist/tools/lib/api-errors.d.ts +2 -0
- package/dist/tools/lib/api-errors.js +5 -0
- package/dist/tools/lib/stable-stringify.d.ts +9 -0
- package/dist/tools/lib/stable-stringify.js +35 -0
- package/dist/tools/organization/inventory.js +2 -1
- package/dist/tools/project/content.js +5 -1
- package/dist/tools/project/delete-chart.d.ts +4 -0
- package/dist/tools/project/delete-chart.js +8 -0
- package/dist/tools/project/delete-dashboard.d.ts +4 -0
- package/dist/tools/project/delete-dashboard.js +8 -0
- package/dist/tools/project/developer-content-preview.d.ts +13 -0
- package/dist/tools/project/developer-content-preview.js +291 -0
- package/dist/tools/project/developer-content-shared.d.ts +24 -0
- package/dist/tools/project/developer-content-shared.js +50 -0
- package/dist/tools/project/developer-content-shared.test.d.ts +1 -0
- package/dist/tools/project/developer-content-shared.test.js +25 -0
- package/dist/tools/project/developer-content.d.ts +38 -0
- package/dist/tools/project/developer-content.js +589 -0
- package/dist/tools/project/developer-get-chart-as-code.d.ts +9 -0
- package/dist/tools/project/developer-get-chart-as-code.js +39 -0
- package/dist/tools/project/developer-get-chart-as-code.test.d.ts +4 -0
- package/dist/tools/project/developer-get-chart-as-code.test.js +70 -0
- package/dist/tools/project/developer-helpers.d.ts +180 -0
- package/dist/tools/project/developer-helpers.js +484 -0
- package/dist/tools/project/developer-helpers.test.d.ts +1 -0
- package/dist/tools/project/developer-helpers.test.js +509 -0
- package/dist/tools/project/get-dashboard-promote-diff.d.ts +6 -0
- package/dist/tools/project/get-dashboard-promote-diff.js +52 -0
- package/dist/tools/project/invariants.test.d.ts +4 -0
- package/dist/tools/project/invariants.test.js +44 -0
- package/dist/tools/project/parameters.d.ts +7 -0
- package/dist/tools/project/parameters.js +74 -0
- package/dist/tools/project/projects.d.ts +4 -1
- package/dist/tools/project/projects.js +68 -6
- package/dist/tools/project/projects.test.js +77 -1
- package/dist/tools/project/promote-dashboard.d.ts +4 -0
- package/dist/tools/project/promote-dashboard.js +8 -0
- package/dist/tools/project/reader-content.d.ts +9 -0
- package/dist/tools/project/reader-content.js +208 -0
- package/dist/tools/project/reader-execution.d.ts +7 -0
- package/dist/tools/project/reader-execution.js +214 -0
- package/dist/tools/project/reader-export-chart-image.d.ts +6 -0
- package/dist/tools/project/reader-export-chart-image.js +78 -0
- package/dist/tools/project/reader-export-chart-image.test.d.ts +4 -0
- package/dist/tools/project/reader-export-chart-image.test.js +149 -0
- package/dist/tools/project/schemas/chart-upsert.d.ts +33 -0
- package/dist/tools/project/schemas/chart-upsert.js +66 -0
- package/dist/tools/project/schemas/dashboard-tile.d.ts +29 -0
- package/dist/tools/project/schemas/dashboard-tile.js +57 -0
- package/dist/tools/project/schemas/dashboard.d.ts +70 -0
- package/dist/tools/project/schemas/dashboard.js +101 -0
- package/dist/tools/project/schemas/duplicate.d.ts +30 -0
- package/dist/tools/project/schemas/duplicate.js +86 -0
- package/dist/tools/project/schemas/index.d.ts +7 -0
- package/dist/tools/project/schemas/index.js +26 -0
- package/dist/tools/project/schemas/parse-helpers.d.ts +14 -0
- package/dist/tools/project/schemas/parse-helpers.js +34 -0
- package/dist/tools/project/schemas/payload-schemas.test.d.ts +1 -0
- package/dist/tools/project/schemas/payload-schemas.test.js +204 -0
- package/dist/tools/project/spaces.d.ts +7 -0
- package/dist/tools/project/spaces.js +101 -0
- package/dist/tools/query/bounded-saved-query.d.ts +37 -0
- package/dist/tools/query/bounded-saved-query.js +80 -0
- package/dist/tools/query/bounded-saved-query.test.d.ts +4 -0
- package/dist/tools/query/bounded-saved-query.test.js +82 -0
- package/dist/tools/query/chart-source.d.ts +10 -0
- package/dist/tools/query/chart-source.js +36 -0
- package/dist/tools/query/chart-source.test.d.ts +1 -0
- package/dist/tools/query/chart-source.test.js +62 -0
- package/dist/tools/query/filter-overrides.d.ts +34 -0
- package/dist/tools/query/filter-overrides.js +75 -0
- package/dist/tools/query/filter-overrides.test.d.ts +1 -0
- package/dist/tools/query/filter-overrides.test.js +21 -0
- package/dist/tools/query/lifecycle.d.ts +7 -0
- package/dist/tools/query/lifecycle.js +104 -0
- package/dist/tools/query/query-ledger.d.ts +41 -0
- package/dist/tools/query/query-ledger.js +92 -0
- package/dist/tools/query/query-ledger.test.d.ts +1 -0
- package/dist/tools/query/query-ledger.test.js +75 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +12 -0
- package/dist/tools/query/reader-tool-helpers.js +57 -0
- package/dist/tools/query/reader-tool-helpers.test.d.ts +1 -0
- package/dist/tools/query/reader-tool-helpers.test.js +53 -0
- package/dist/tools/query/result-normalizer.d.ts +27 -0
- package/dist/tools/query/result-normalizer.js +133 -0
- package/dist/tools/query/result-normalizer.test.d.ts +1 -0
- package/dist/tools/query/result-normalizer.test.js +41 -0
- package/dist/tools/query/wait-for-async.d.ts +10 -0
- package/dist/tools/query/wait-for-async.js +46 -0
- package/dist/tools/query/wait-for-async.test.d.ts +1 -0
- package/dist/tools/query/wait-for-async.test.js +45 -0
- package/dist/tools/registry.d.ts +187 -3
- package/dist/tools/registry.js +89 -7
- package/dist/tools/shared.d.ts +52 -10
- package/dist/tools/shared.js +127 -41
- package/dist/tools/shared.test.js +103 -3
- package/dist/transports/streamable-http.js +47 -198
- package/dist/transports/streamable-http.test.js +21 -9
- package/package.json +5 -5
- package/dist/personas/organization-audit/v1/resources/playbook.d.ts +0 -11
- package/dist/personas/organization-audit/v1/resources/playbook.js +0 -40
- package/dist/personas/organization-audit/v1/resources/playbook.md +0 -52
- package/dist/personas/semantic-layer/v1/resources/playbook.d.ts +0 -12
- package/dist/personas/semantic-layer/v1/resources/playbook.js +0 -42
- package/dist/personas/semantic-layer/v1/resources/playbook.md +0 -153
- package/dist/transports/http-request-utils.d.ts +0 -2
- package/dist/transports/http-request-utils.js +0 -13
- package/dist/transports/session-store.d.ts +0 -40
- package/dist/transports/session-store.js +0 -88
- package/dist/transports/session-store.test.js +0 -111
- /package/dist/{transports/session-store.test.d.ts → destructive/capability.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,93 +1,98 @@
|
|
|
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:
|
|
3
|
+
MCP server for Lightdash with **persona-scoped** surfaces. One package, six personas: explore/compile, org audit, saved-content reads, chart/dashboard authoring, soft-delete governance, and AI-agent ops. Uses [`@lightdash-tools/client`](https://www.npmjs.com/package/@lightdash-tools/client) for API access. <!-- markdown-link-check-disable-line -->
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Developing this package? See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Choose a persona
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| Persona | 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/organization-audit-endpoint-inventory.md) |
|
|
13
|
+
| `content-reader` | Discover and run saved content | `/content-reader/v1/mcp` | `content-reader` | [inventory](../../docs/content-reader-endpoint-inventory.md) |
|
|
14
|
+
| `content-developer` | Author charts/dashboards (preview gate) | `/content-developer/v1/mcp` | `content-developer` | [inventory](../../docs/content-developer-endpoint-inventory.md) |
|
|
15
|
+
| `content-governance` | Soft-delete / promote (form elicitation) | `/content-governance/v1/mcp` | `content-governance` | [inventory](../../docs/content-governance-endpoint-inventory.md) |
|
|
16
|
+
| `ai-agent-ops` | Thin AI-agent APIs + product eval runs | `/ai-agent-ops/v1/mcp` | `ai-agent-ops` | [inventory](../../docs/ai-agent-ops-endpoint-inventory.md) |
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
| :------------------------------------------------------ | :--------------------------------------------------- |
|
|
13
|
-
| Shared tools / registry | `src/tools/` (`registry.ts`, domain modules) |
|
|
14
|
-
| Persona (tools allowlist, prompts, playbook, HTTP path) | `src/personas/<id>/` |
|
|
15
|
-
| HTTP transport / sessions | `src/transports/` |
|
|
16
|
-
| HTTP auth | `src/auth/` |
|
|
17
|
-
| Runtime client + guardrail env | `src/config/runtime.ts` |
|
|
18
|
-
| HTTP env / loader | `src/config/env.ts`, `src/config/load-mcp-config.ts` |
|
|
19
|
-
| Audit logging helpers | `src/audit/` |
|
|
20
|
-
| Entrypoints | `src/bin.ts`, `src/index.ts` (stdio), `src/http.ts` |
|
|
18
|
+
Tool names are prefixed with `lightdash_`. MCP display names are shortened where needed for client length limits (e.g. `lightdash-mcp-content`).
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
## Quick start
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
That package was removed (ADR-0006). Migrate as follows:
|
|
27
|
-
|
|
28
|
-
| Removed | Use instead |
|
|
29
|
-
| ------------------------------------- | ------------------------ |
|
|
30
|
-
| `@lightdash-tools/semantic-layer-mcp` | `@lightdash-tools/mcp` |
|
|
31
|
-
| Binary `lightdash-semantic-layer-mcp` | `lightdash-mcp` |
|
|
32
|
-
| HTTP `/mcp` (old) | `/semantic-layer/v1/mcp` |
|
|
33
|
-
| Unprefixed tool names | `lightdash_*` |
|
|
34
|
-
|
|
35
|
-
## Installation
|
|
36
|
-
|
|
37
|
-
You can run the MCP server using `npx`:
|
|
22
|
+
### Stdio (local)
|
|
38
23
|
|
|
39
24
|
```bash
|
|
40
|
-
npx @lightdash-tools/mcp
|
|
25
|
+
npx @lightdash-tools/mcp # semantic-layer (default)
|
|
26
|
+
npx @lightdash-tools/mcp content-reader # other personas by name
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
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)).
|
|
30
|
+
|
|
31
|
+
Example Cursor / Claude Desktop config:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"mcpServers": {
|
|
36
|
+
"lightdash": {
|
|
37
|
+
"command": "npx",
|
|
38
|
+
"args": ["@lightdash-tools/mcp", "content-reader"],
|
|
39
|
+
"env": {
|
|
40
|
+
"LIGHTDASH_URL": "https://app.lightdash.cloud",
|
|
41
|
+
"LIGHTDASH_API_KEY": "your_pat"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
41
46
|
```
|
|
42
47
|
|
|
43
|
-
Or install
|
|
48
|
+
Or install globally: `npm install -g @lightdash-tools/mcp`, then `lightdash-mcp [persona]`.
|
|
49
|
+
|
|
50
|
+
### Streamable HTTP (remote)
|
|
44
51
|
|
|
45
52
|
```bash
|
|
46
|
-
|
|
53
|
+
export LIGHTDASH_URL="https://app.lightdash.cloud"
|
|
54
|
+
export LIGHTDASH_TOOLS_MCP_PUBLIC_URL="https://lightdash-mcp.example.com"
|
|
55
|
+
export LIGHTDASH_TOOLS_OAUTH_CLIENT_ID="..."
|
|
56
|
+
export LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET="..."
|
|
57
|
+
npx @lightdash-tools/mcp serve-http
|
|
47
58
|
```
|
|
48
59
|
|
|
49
|
-
|
|
60
|
+
Persona 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`).
|
|
50
61
|
|
|
51
|
-
-
|
|
52
|
-
-
|
|
62
|
+
- Hosted OAuth (Cursor URL-only): [docs/cursor-lightdash-oauth-mcp.md](../../docs/cursor-lightdash-oauth-mcp.md)
|
|
63
|
+
- Operator guide: [docs/mcp-oauth-http.md](../../docs/mcp-oauth-http.md)
|
|
53
64
|
|
|
54
|
-
|
|
65
|
+
Local Compose smoke: `docker compose -f docker-compose.dev.yml --profile semantic-layer up --build` → `http://localhost:8080/semantic-layer/v1/mcp`.
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
- Speaks the established 2025-era protocol by default (not `2026-07-28` unless a future flag).
|
|
58
|
-
- 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).
|
|
67
|
+
## Configuration
|
|
59
68
|
|
|
60
|
-
|
|
69
|
+
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/secrets-and-credentials.md](../../docs/secrets-and-credentials.md).
|
|
61
70
|
|
|
62
|
-
|
|
71
|
+
### Stdio
|
|
63
72
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
| PRM + broker AS metadata; per-user Bearer to Lightdash | MCP-local scope enforcement for opaque tokens |
|
|
68
|
-
| Session binding to `userUuid` / `organizationUuid` | Horizontal scale without sticky sessions (in-memory broker/MCP sessions) |
|
|
73
|
+
| Required | Optional |
|
|
74
|
+
| :----------------------------------- | :-------------------------------------------------------------------------------------------- |
|
|
75
|
+
| `LIGHTDASH_URL`, `LIGHTDASH_API_KEY` | `LIGHTDASH_TOOLS_AUDIT_LOG` (file; else stderr JSON), `LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS` |
|
|
69
76
|
|
|
70
|
-
|
|
77
|
+
Do **not** set OAuth client secrets for stdio. MCP ignores CLI `SAFETY_MODE` / `DRY_RUN`.
|
|
71
78
|
|
|
72
|
-
|
|
79
|
+
### HTTP OAuth (primary)
|
|
73
80
|
|
|
74
|
-
|
|
81
|
+
| Required | Common optional |
|
|
82
|
+
| :-------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------- |
|
|
83
|
+
| `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 |
|
|
75
84
|
|
|
76
|
-
|
|
85
|
+
On Cloud Run / hosted HTTP, leave `LIGHTDASH_TOOLS_AUDIT_LOG` unset — tool audits are stderr JSON (`channel: "audit"`) → Cloud Logging. See [cloud-run-mcp-oauth.md](../../docs/cloud-run-mcp-oauth.md).
|
|
77
86
|
|
|
78
|
-
|
|
79
|
-
| :----------------------------------- | :-------------------------- |
|
|
80
|
-
| `LIGHTDASH_URL`, `LIGHTDASH_API_KEY` | `LIGHTDASH_TOOLS_AUDIT_LOG` |
|
|
87
|
+
Register Lightdash redirect URI: `{PUBLIC_URL}/oauth/callback`. Clients connect with URL only to a persona path above. Protocol: [MCP Authorization 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization).
|
|
81
88
|
|
|
82
|
-
|
|
89
|
+
### Content-developer / content-governance signing
|
|
83
90
|
|
|
84
|
-
|
|
91
|
+
| Required (non-test) | Notes |
|
|
92
|
+
| :-------------------------------------- | :---------------------------------------------------------------------------------------------- |
|
|
93
|
+
| `LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY` | ≥32-byte secret for HMAC `previewToken` / `requestState` (fail closed if unset; not encryption) |
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
| :-------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------- |
|
|
88
|
-
| `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 |
|
|
89
|
-
|
|
90
|
-
Register Lightdash redirect URI: `{PUBLIC_URL}/oauth/callback`. Clients: URL only to `/semantic-layer/v1/mcp` or `/organization-audit/v1/mcp`.
|
|
95
|
+
Governance soft-delete needs client form elicitation; missing capability → `ELICITATION_REQUIRED`.
|
|
91
96
|
|
|
92
97
|
### HTTP shared-key / local (secondary)
|
|
93
98
|
|
|
@@ -96,140 +101,78 @@ Register Lightdash redirect URI: `{PUBLIC_URL}/oauth/callback`. Clients: URL onl
|
|
|
96
101
|
| Shared-key | `LIGHTDASH_API_KEY` + `LIGHTDASH_TOOLS_MCP_SHARED_KEY` |
|
|
97
102
|
| Local none | `NODE_ENV=development` (not `production`) |
|
|
98
103
|
|
|
99
|
-
Obsolete `
|
|
104
|
+
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).
|
|
100
105
|
|
|
101
|
-
|
|
106
|
+
## Personas at a glance
|
|
102
107
|
|
|
103
|
-
|
|
108
|
+
### `semantic-layer`
|
|
104
109
|
|
|
105
|
-
|
|
110
|
+
Projects, explores, metrics, and `compile_query` (no warehouse run). Playbook: `lightdash://playbooks/semantic-layer`.
|
|
106
111
|
|
|
107
|
-
|
|
112
|
+
### `organization-audit`
|
|
108
113
|
|
|
109
|
-
|
|
110
|
-
npx @lightdash-tools/mcp
|
|
111
|
-
# or explicit personas:
|
|
112
|
-
npx @lightdash-tools/mcp semantic-layer
|
|
113
|
-
npx @lightdash-tools/mcp organization-audit
|
|
114
|
-
```
|
|
114
|
+
Read-only inventory, access, content health, usage, and schedulers. No mutations or warehouse queries. Server name: `lightdash-mcp-org-audit`.
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
### `content-reader`
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
lightdash-mcp
|
|
120
|
-
lightdash-mcp organization-audit
|
|
121
|
-
```
|
|
118
|
+
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`.
|
|
122
119
|
|
|
123
|
-
|
|
120
|
+
### `content-developer`
|
|
124
121
|
|
|
125
|
-
|
|
122
|
+
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`.
|
|
126
123
|
|
|
127
|
-
|
|
128
|
-
# Backward-compatible
|
|
129
|
-
npx @lightdash-tools/mcp --http
|
|
124
|
+
### `content-governance`
|
|
130
125
|
|
|
131
|
-
|
|
132
|
-
npx @lightdash-tools/mcp serve-http
|
|
126
|
+
Soft-delete charts/dashboards and elicitation-gated dashboard promote. Permanent purge stays off MCP. Server name: `lightdash-mcp-gov`.
|
|
133
127
|
|
|
134
|
-
|
|
135
|
-
export LIGHTDASH_URL="https://app.lightdash.cloud"
|
|
136
|
-
export LIGHTDASH_TOOLS_MCP_PUBLIC_URL="https://lightdash-mcp.example.com"
|
|
137
|
-
export LIGHTDASH_TOOLS_OAUTH_CLIENT_ID="..."
|
|
138
|
-
export LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET="..."
|
|
139
|
-
npx @lightdash-tools/mcp serve-http
|
|
140
|
-
```
|
|
128
|
+
### `ai-agent-ops`
|
|
141
129
|
|
|
142
|
-
|
|
130
|
+
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/ai-agent-ops-loop.md](../../docs/ai-agent-ops-loop.md).
|
|
143
131
|
|
|
144
|
-
|
|
145
|
-
- `POST/GET/DELETE /organization-audit/v1/mcp`
|
|
132
|
+
## Safety
|
|
146
133
|
|
|
147
|
-
|
|
134
|
+
- **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)).
|
|
135
|
+
- **Writes:** only on `content-developer` (preview gate). Soft-delete / promote: only on `content-governance` (form elicitation).
|
|
136
|
+
- **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)).
|
|
137
|
+
- **Project scope:** optional HTTP pin `X-Lightdash-Project`, else tool `projectUuid`; optional ceiling `LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS`.
|
|
148
138
|
|
|
149
|
-
|
|
139
|
+
Persona tool allowlists are the capability surface — not CLI safety-mode.
|
|
150
140
|
|
|
151
|
-
|
|
152
|
-
- 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).
|
|
141
|
+
## Upstream API failures
|
|
153
142
|
|
|
154
|
-
|
|
143
|
+
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)).
|
|
155
144
|
|
|
156
|
-
|
|
145
|
+
| Code | Typical cause |
|
|
146
|
+
| :---------------------- | :--------------------------------------------- |
|
|
147
|
+
| `RATE_LIMITED` | HTTP 429 |
|
|
148
|
+
| `UPSTREAM_TRANSIENT` | Network errors, 408, 5xx |
|
|
149
|
+
| `UPSTREAM_NOT_FOUND` | HTTP 404 |
|
|
150
|
+
| `UPSTREAM_FORBIDDEN` | HTTP 403 |
|
|
151
|
+
| `UPSTREAM_UNSUPPORTED` | HTTP 501 |
|
|
152
|
+
| `UPSTREAM_VALIDATION` | HTTP 400 / 422 (including new required fields) |
|
|
153
|
+
| `UPSTREAM_CLIENT_ERROR` | Other 4xx |
|
|
154
|
+
| `UPSTREAM_CONTRACT` | Success HTTP but unexpected response shape |
|
|
155
|
+
| `IMAGE_TOO_LARGE` | Chart PNG over size limit |
|
|
156
|
+
| `UPSTREAM_UNKNOWN` | Non-API throws |
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
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.
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
- **Explores**: `list_explores`, `get_explore`, `list_dimensions`, `get_field_lineage`
|
|
162
|
-
- **Metrics**: `list_metrics`, `get_metric`
|
|
163
|
-
- **Query**: `compile_query` (empty SELECT → `isError`; no run-query)
|
|
160
|
+
## Migration from `@lightdash-tools/semantic-layer-mcp`
|
|
164
161
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
- **Inventory**: `get_org_profile`, `list_org_members`, `get_org_member`, `list_org_groups`, `list_org_projects`
|
|
172
|
-
- **Access**: `list_org_role_assignments`, `list_custom_roles`, `get_custom_role`, `list_project_roles`, `list_project_direct_access`, `list_space_access`, `resolve_effective_access`
|
|
173
|
-
- **Content / health**: `list_content`, `get_dashboard_meta`, `list_validation_results`, `get_project_user_activity`
|
|
174
|
-
- **Delivery**: `list_project_schedulers`, `get_scheduler`
|
|
175
|
-
|
|
176
|
-
Prompts and playbook: `lightdash://playbooks/organization-audit` (host orchestrates multi-step audits via primitives). No mutation, warehouse queries, or user-activity CSV download.
|
|
177
|
-
|
|
178
|
-
### CLI Binary
|
|
179
|
-
|
|
180
|
-
If installed globally, you can use the `lightdash-mcp` binary:
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
lightdash-mcp --help
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### CLI Options
|
|
187
|
-
|
|
188
|
-
- `--http` — Run as HTTP server instead of Stdio.
|
|
189
|
-
- `stdio` / `semantic-layer` / `organization-audit` / `serve-http` — Explicit transport/persona subcommands.
|
|
190
|
-
|
|
191
|
-
## Safety (persona-first)
|
|
192
|
-
|
|
193
|
-
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)):
|
|
194
|
-
|
|
195
|
-
| Concern | Mechanism |
|
|
196
|
-
| :----------- | :------------------------------------------------------------------------------------------------- |
|
|
197
|
-
| Which tools | Persona `toolIds` in code (`semantic-layer` or `organization-audit`) |
|
|
198
|
-
| Who | Auth mode + Lightdash API RBAC |
|
|
199
|
-
| Where (HTTP) | Optional `X-Lightdash-Project` pin |
|
|
200
|
-
| Hardening | Input validation on known ID fields + optional `LIGHTDASH_TOOLS_AUDIT_LOG` + org-audit GET asserts |
|
|
201
|
-
|
|
202
|
-
Process `LIGHTDASH_TOOLS_SAFETY_MODE` / allowlist / dry-run are **CLI-only**, not used by this package.
|
|
203
|
-
|
|
204
|
-
### Agent-safe surface
|
|
205
|
-
|
|
206
|
-
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). Broad admin ops stay on `@lightdash-tools/client` / CLI. The shipped MCP persona is compile/discovery only.
|
|
207
|
-
|
|
208
|
-
### Input validation
|
|
209
|
-
|
|
210
|
-
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).
|
|
211
|
-
|
|
212
|
-
## Testing
|
|
213
|
-
|
|
214
|
-
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.
|
|
215
|
-
|
|
216
|
-
### Running unit tests
|
|
217
|
-
|
|
218
|
-
```bash
|
|
219
|
-
pnpm test
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
### Running integration tests
|
|
223
|
-
|
|
224
|
-
To run tests against a real Lightdash instance, provide your credentials:
|
|
225
|
-
|
|
226
|
-
```bash
|
|
227
|
-
LIGHTDASH_URL=https://app.lightdash.cloud LIGHTDASH_API_KEY=your_api_key pnpm test
|
|
228
|
-
```
|
|
162
|
+
| Removed | Use instead |
|
|
163
|
+
| :------------------------------------ | :----------------------- |
|
|
164
|
+
| `@lightdash-tools/semantic-layer-mcp` | `@lightdash-tools/mcp` |
|
|
165
|
+
| Binary `lightdash-semantic-layer-mcp` | `lightdash-mcp` |
|
|
166
|
+
| HTTP `/mcp` (old) | `/semantic-layer/v1/mcp` |
|
|
167
|
+
| Unprefixed tool names | `lightdash_*` |
|
|
229
168
|
|
|
230
|
-
|
|
169
|
+
## Further reading
|
|
231
170
|
|
|
232
|
-
|
|
171
|
+
- Architecture / contributing — [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
172
|
+
- OAuth operator guide — [docs/mcp-oauth-http.md](../../docs/mcp-oauth-http.md)
|
|
173
|
+
- Cursor hosted OAuth — [docs/cursor-lightdash-oauth-mcp.md](../../docs/cursor-lightdash-oauth-mcp.md)
|
|
174
|
+
- Architecture decisions — [docs/adr/](../../docs/adr/)
|
|
175
|
+
- MCP transports — [2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports)
|
|
233
176
|
|
|
234
177
|
## License
|
|
235
178
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind an MCP server instance to a persona id for audit attribution.
|
|
3
|
+
* Call once in registerCapabilities before registering tools; registerToolSafe
|
|
4
|
+
* reads it at wrap time. Tool behavior that needs personaId still uses
|
|
5
|
+
* registerToolsByIds options (e.g. get_project) — that path is separate.
|
|
6
|
+
*/
|
|
7
|
+
/** Associate a persona id with an MCP server (call before registering tools). */
|
|
8
|
+
export declare function bindServerPersona(server: object, personaId: string): void;
|
|
9
|
+
/** Persona id bound to this server, if any. */
|
|
10
|
+
export declare function getServerPersona(server: object): string | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bind an MCP server instance to a persona id for audit attribution.
|
|
4
|
+
* Call once in registerCapabilities before registering tools; registerToolSafe
|
|
5
|
+
* reads it at wrap time. Tool behavior that needs personaId still uses
|
|
6
|
+
* registerToolsByIds options (e.g. get_project) — that path is separate.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.bindServerPersona = bindServerPersona;
|
|
10
|
+
exports.getServerPersona = getServerPersona;
|
|
11
|
+
const serverPersona = new WeakMap();
|
|
12
|
+
/** Associate a persona id with an MCP server (call before registering tools). */
|
|
13
|
+
function bindServerPersona(server, personaId) {
|
|
14
|
+
serverPersona.set(server, personaId);
|
|
15
|
+
}
|
|
16
|
+
/** Persona id bound to this server, if any. */
|
|
17
|
+
function getServerPersona(server) {
|
|
18
|
+
return serverPersona.get(server);
|
|
19
|
+
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth broker pending / codes / DCR clients (ADR-0007 / ADR-0019).
|
|
3
|
+
*
|
|
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.
|
|
6
|
+
*/
|
|
1
7
|
export interface PendingAuthorization {
|
|
2
8
|
/** Broker state sent to Lightdash (opaque). */
|
|
3
9
|
brokerState: string;
|
|
@@ -29,8 +35,52 @@ export interface RegisteredClient {
|
|
|
29
35
|
redirectUris: ReadonlySet<string>;
|
|
30
36
|
createdAt: number;
|
|
31
37
|
}
|
|
38
|
+
/** Pending authorize→callback state TTL. */
|
|
39
|
+
export declare const DEFAULT_PENDING_TTL_MS: number;
|
|
40
|
+
/** Issued broker authorization code TTL (RFC 6749 recommends ≤10m; keep short). */
|
|
41
|
+
export declare const DEFAULT_CODE_TTL_MS: number;
|
|
42
|
+
/** Registered DCR clients TTL (long enough for interactive OAuth). */
|
|
43
|
+
export declare const DEFAULT_CLIENT_TTL_MS: number;
|
|
44
|
+
export declare const DEFAULT_MAX_PENDING = 10000;
|
|
45
|
+
export declare const DEFAULT_MAX_CODES = 10000;
|
|
46
|
+
export declare const DEFAULT_MAX_CLIENTS = 10000;
|
|
47
|
+
export type OAuthBrokerStoreOptions = {
|
|
48
|
+
pendingTtlMs?: number;
|
|
49
|
+
codeTtlMs?: number;
|
|
50
|
+
clientTtlMs?: number;
|
|
51
|
+
maxPending?: number;
|
|
52
|
+
maxCodes?: number;
|
|
53
|
+
maxClients?: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
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.
|
|
58
|
+
*/
|
|
59
|
+
export interface OAuthBrokerStore {
|
|
60
|
+
registerClient(redirectUris: readonly string[]): Promise<RegisteredClient | undefined>;
|
|
61
|
+
getClient(clientId: string): Promise<RegisteredClient | undefined>;
|
|
62
|
+
isRedirectAllowedForClient(clientId: string, redirectUri: string): Promise<boolean>;
|
|
63
|
+
createPending(input: Omit<PendingAuthorization, 'brokerState' | 'createdAt'>): Promise<PendingAuthorization | undefined>;
|
|
64
|
+
takePending(brokerState: string): Promise<PendingAuthorization | undefined>;
|
|
65
|
+
issueCode(pending: PendingAuthorization, tokens: {
|
|
66
|
+
accessToken: string;
|
|
67
|
+
expiresIn?: number;
|
|
68
|
+
tokenType?: string;
|
|
69
|
+
scope?: string;
|
|
70
|
+
}): Promise<IssuedAuthorizationCode | undefined>;
|
|
71
|
+
/** Atomic get+delete for one-time code consume. */
|
|
72
|
+
takeCode(code: string): Promise<IssuedAuthorizationCode | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Re-insert a previously taken code with remaining TTL based on `createdAt`
|
|
75
|
+
* and store `codeTtlMs`. Skips when already expired.
|
|
76
|
+
*/
|
|
77
|
+
restoreCode(issued: IssuedAuthorizationCode): Promise<void>;
|
|
78
|
+
/** Peek without consuming (tests / diagnostics). Prefer takeCode for grant paths. */
|
|
79
|
+
getCode(code: string): Promise<IssuedAuthorizationCode | undefined>;
|
|
80
|
+
deleteCode(code: string): Promise<void>;
|
|
81
|
+
}
|
|
32
82
|
/** In-memory pending OAuth broker state (single-instance / sticky routing). */
|
|
33
|
-
export declare class OAuthBrokerStore {
|
|
83
|
+
export declare class InMemoryOAuthBrokerStore implements OAuthBrokerStore {
|
|
34
84
|
private readonly pendingByBrokerState;
|
|
35
85
|
private readonly codes;
|
|
36
86
|
private readonly clients;
|
|
@@ -40,37 +90,37 @@ export declare class OAuthBrokerStore {
|
|
|
40
90
|
private readonly maxPending;
|
|
41
91
|
private readonly maxCodes;
|
|
42
92
|
private readonly maxClients;
|
|
43
|
-
constructor(options?:
|
|
44
|
-
pendingTtlMs?: number;
|
|
45
|
-
codeTtlMs?: number;
|
|
46
|
-
clientTtlMs?: number;
|
|
47
|
-
maxPending?: number;
|
|
48
|
-
maxCodes?: number;
|
|
49
|
-
maxClients?: number;
|
|
50
|
-
});
|
|
93
|
+
constructor(options?: OAuthBrokerStoreOptions);
|
|
51
94
|
/**
|
|
52
95
|
* Registers a public MCP client with exact redirect URIs, or returns undefined
|
|
53
96
|
* when the in-memory client cap is reached (after TTL cleanup).
|
|
54
97
|
*/
|
|
55
|
-
registerClient(redirectUris: readonly string[]): RegisteredClient | undefined
|
|
56
|
-
getClient(clientId: string): RegisteredClient | undefined
|
|
98
|
+
registerClient(redirectUris: readonly string[]): Promise<RegisteredClient | undefined>;
|
|
99
|
+
getClient(clientId: string): Promise<RegisteredClient | undefined>;
|
|
57
100
|
/** True when clientId is registered and redirectUri is an exact registered URI. */
|
|
58
|
-
isRedirectAllowedForClient(clientId: string, redirectUri: string): boolean
|
|
101
|
+
isRedirectAllowedForClient(clientId: string, redirectUri: string): Promise<boolean>;
|
|
59
102
|
/**
|
|
60
103
|
* Creates pending state, or returns undefined when the in-memory cap is reached
|
|
61
104
|
* (after TTL cleanup).
|
|
62
105
|
*/
|
|
63
|
-
createPending(input: Omit<PendingAuthorization, 'brokerState' | 'createdAt'>): PendingAuthorization | undefined
|
|
64
|
-
takePending(brokerState: string): PendingAuthorization | undefined
|
|
106
|
+
createPending(input: Omit<PendingAuthorization, 'brokerState' | 'createdAt'>): Promise<PendingAuthorization | undefined>;
|
|
107
|
+
takePending(brokerState: string): Promise<PendingAuthorization | undefined>;
|
|
65
108
|
issueCode(pending: PendingAuthorization, tokens: {
|
|
66
109
|
accessToken: string;
|
|
67
110
|
expiresIn?: number;
|
|
68
111
|
tokenType?: string;
|
|
69
112
|
scope?: string;
|
|
70
|
-
}): IssuedAuthorizationCode | undefined
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
113
|
+
}): Promise<IssuedAuthorizationCode | undefined>;
|
|
114
|
+
/** Atomic get+delete of an issued authorization code. */
|
|
115
|
+
takeCode(code: string): Promise<IssuedAuthorizationCode | undefined>;
|
|
116
|
+
/**
|
|
117
|
+
* Re-insert a taken code if its original TTL has not elapsed.
|
|
118
|
+
* In-memory expiry still uses `createdAt` + `codeTtlMs` on cleanup.
|
|
119
|
+
*/
|
|
120
|
+
restoreCode(issued: IssuedAuthorizationCode): Promise<void>;
|
|
121
|
+
/** Peek at an issued code without consuming it. */
|
|
122
|
+
getCode(code: string): Promise<IssuedAuthorizationCode | undefined>;
|
|
123
|
+
/** Drop a code by id (non-atomic; prefer takeCode for grant paths). */
|
|
124
|
+
deleteCode(code: string): Promise<void>;
|
|
75
125
|
private cleanup;
|
|
76
126
|
}
|