@lightdash-tools/mcp 0.6.0 → 0.8.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 +205 -58
- package/dist/audit/audit.d.ts +5 -0
- package/dist/{audit.js → audit/audit.js} +1 -2
- package/dist/audit/tool-audit-context.d.ts +6 -0
- package/dist/audit/tool-audit-context.js +12 -0
- package/dist/audit/tool-audit-context.test.d.ts +1 -0
- package/dist/audit/tool-audit-context.test.js +19 -0
- package/dist/auth/auth-mode.d.ts +4 -0
- package/dist/auth/auth-mode.js +6 -0
- package/dist/auth/bearer.d.ts +3 -0
- package/dist/auth/bearer.js +13 -0
- package/dist/auth/lightdash-oauth-upstream-contract.d.ts +22 -0
- package/dist/auth/lightdash-oauth-upstream-contract.js +36 -0
- package/dist/auth/lightdash-oauth-upstream-contract.test.d.ts +1 -0
- package/dist/auth/lightdash-oauth-upstream-contract.test.js +56 -0
- package/dist/auth/oauth-broker/as-metadata.d.ts +14 -0
- package/dist/auth/oauth-broker/as-metadata.js +20 -0
- package/dist/auth/oauth-broker/lightdash-token.d.ts +20 -0
- package/dist/auth/oauth-broker/lightdash-token.js +76 -0
- package/dist/auth/oauth-broker/pending-store.d.ts +127 -0
- package/dist/auth/oauth-broker/pending-store.js +151 -0
- package/dist/auth/oauth-broker/pending-store.test.d.ts +6 -0
- package/dist/auth/oauth-broker/pending-store.test.js +146 -0
- package/dist/auth/oauth-broker/pkce.d.ts +2 -0
- package/dist/auth/oauth-broker/pkce.js +17 -0
- package/dist/auth/oauth-broker/routes.d.ts +13 -0
- package/dist/auth/oauth-broker/routes.js +452 -0
- package/dist/auth/oauth-broker/routes.test.d.ts +1 -0
- package/dist/auth/oauth-broker/routes.test.js +242 -0
- package/dist/auth/providers/bearer-context-provider.d.ts +24 -0
- package/dist/auth/providers/bearer-context-provider.js +52 -0
- package/dist/auth/providers/env-context-provider.d.ts +13 -0
- package/dist/auth/providers/env-context-provider.js +19 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +23 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +115 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.test.d.ts +1 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +202 -0
- package/dist/auth/resource-server/lightdash-token-validation.d.ts +14 -0
- package/dist/auth/resource-server/lightdash-token-validation.js +82 -0
- package/dist/auth/resource-server/lightdash-token-validation.test.d.ts +1 -0
- package/dist/auth/resource-server/lightdash-token-validation.test.js +177 -0
- package/dist/auth/resource-server/oauth-protected-resource.d.ts +25 -0
- package/dist/auth/resource-server/oauth-protected-resource.js +67 -0
- package/dist/auth/resource-server/shared-key-middleware.d.ts +13 -0
- package/dist/auth/resource-server/shared-key-middleware.js +24 -0
- package/dist/auth/resource-server/token-scopes.d.ts +15 -0
- package/dist/auth/resource-server/token-scopes.js +76 -0
- package/dist/auth/resource-server/token-scopes.test.d.ts +1 -0
- package/dist/auth/resource-server/token-scopes.test.js +51 -0
- package/dist/auth/resource-server/token-validation-cache.d.ts +15 -0
- package/dist/auth/resource-server/token-validation-cache.js +44 -0
- package/dist/auth/resource-server/token-validation-cache.test.d.ts +1 -0
- package/dist/auth/resource-server/token-validation-cache.test.js +41 -0
- package/dist/auth/resource-server/token-validation-error.d.ts +6 -0
- package/dist/auth/resource-server/token-validation-error.js +13 -0
- package/dist/auth/resource-server/www-authenticate.d.ts +8 -0
- package/dist/auth/resource-server/www-authenticate.js +24 -0
- package/dist/auth/resource-server/www-authenticate.test.d.ts +1 -0
- package/dist/auth/resource-server/www-authenticate.test.js +70 -0
- package/dist/auth/token-hash.d.ts +2 -0
- package/dist/auth/token-hash.js +8 -0
- package/dist/bin.d.ts +0 -4
- package/dist/bin.js +62 -33
- package/dist/config/env.d.ts +57 -0
- package/dist/config/env.js +60 -0
- package/dist/config/load-mcp-config.d.ts +30 -0
- package/dist/config/load-mcp-config.js +286 -0
- package/dist/config/load-mcp-config.test.d.ts +1 -0
- package/dist/config/load-mcp-config.test.js +202 -0
- package/dist/config/normalize-url.d.ts +13 -0
- package/dist/config/normalize-url.js +52 -0
- package/dist/config/normalize-url.test.d.ts +1 -0
- package/dist/config/normalize-url.test.js +47 -0
- package/dist/config/public-url.d.ts +3 -0
- package/dist/config/public-url.js +10 -0
- package/dist/config/runtime.d.ts +15 -0
- package/dist/config/runtime.js +48 -0
- package/dist/config/runtime.test.d.ts +1 -0
- package/dist/config/runtime.test.js +69 -0
- package/dist/config/test-mcp-http-config.d.ts +3 -0
- package/dist/config/test-mcp-http-config.js +7 -0
- package/dist/destructive/capability.d.ts +13 -0
- package/dist/destructive/capability.js +37 -0
- package/dist/destructive/capability.test.d.ts +1 -0
- package/dist/destructive/capability.test.js +46 -0
- package/dist/destructive/confirmation-claim.d.ts +21 -0
- package/dist/destructive/confirmation-claim.js +87 -0
- package/dist/destructive/confirmation-claim.test.d.ts +1 -0
- package/dist/destructive/confirmation-claim.test.js +50 -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 +144 -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 +339 -0
- package/dist/destructive/register-destructive-tool.d.ts +54 -0
- package/dist/destructive/register-destructive-tool.js +301 -0
- package/dist/destructive/request-state.d.ts +16 -0
- package/dist/destructive/request-state.js +76 -0
- package/dist/destructive/types.d.ts +64 -0
- package/dist/destructive/types.js +10 -0
- package/dist/governance/mcp-client-session.d.ts +9 -0
- package/dist/governance/mcp-client-session.js +30 -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-pin.d.ts +14 -0
- package/dist/governance/project-pin.js +44 -0
- package/dist/governance/project-pin.test.d.ts +1 -0
- package/dist/governance/project-pin.test.js +35 -0
- package/dist/governance/project-scope.d.ts +38 -0
- package/dist/governance/project-scope.js +79 -0
- package/dist/governance/project-scope.test.d.ts +4 -0
- package/dist/governance/project-scope.test.js +103 -0
- package/dist/http.d.ts +1 -2
- package/dist/http.integration.test.d.ts +1 -0
- package/dist/http.integration.test.js +722 -0
- package/dist/http.js +3 -170
- package/dist/http.test.d.ts +4 -0
- package/dist/http.test.js +131 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.integration.test.js +73 -30
- package/dist/index.js +28 -27
- package/dist/index.test.js +3 -3
- package/dist/logging/structured.d.ts +27 -0
- package/dist/logging/structured.js +32 -0
- package/dist/logging/structured.test.d.ts +1 -0
- package/dist/logging/structured.test.js +33 -0
- package/dist/personas/content-developer/v1/index.d.ts +10 -0
- package/dist/personas/content-developer/v1/index.js +51 -0
- package/dist/personas/content-developer/v1/prompts.d.ts +5 -0
- package/dist/personas/content-developer/v1/prompts.js +138 -0
- package/dist/personas/content-developer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-developer/v1/prompts.test.js +75 -0
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +15 -0
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +63 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +55 -0
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/content-developer/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-developer/v1/resources/playbooks.js +44 -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 +37 -0
- package/dist/personas/content-reader/v1/prompts.d.ts +5 -0
- package/dist/personas/content-reader/v1/prompts.js +128 -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 +21 -0
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +40 -0
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +13 -0
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +19 -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 +22 -0
- package/dist/personas/index.js +73 -0
- package/dist/personas/index.test.d.ts +1 -0
- package/dist/personas/index.test.js +109 -0
- package/dist/personas/lib/playbook-resources.d.ts +79 -0
- package/dist/personas/lib/playbook-resources.js +165 -0
- package/dist/personas/organization-audit/v1/index.d.ts +8 -0
- package/dist/personas/organization-audit/v1/index.js +42 -0
- package/dist/personas/organization-audit/v1/prompts.d.ts +5 -0
- package/dist/personas/organization-audit/v1/prompts.js +92 -0
- package/dist/personas/organization-audit/v1/prompts.test.d.ts +4 -0
- package/dist/personas/organization-audit/v1/prompts.test.js +25 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +13 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +9 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/core.md +36 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +9 -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 +26 -0
- package/dist/personas/semantic-layer/v1/index.d.ts +8 -0
- package/dist/personas/semantic-layer/v1/index.js +32 -0
- package/dist/personas/semantic-layer/v1/prompts.d.ts +5 -0
- package/dist/personas/semantic-layer/v1/prompts.js +85 -0
- 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 +55 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +39 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +76 -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 +19 -0
- package/dist/personas/types.js +5 -0
- 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 +48 -0
- package/dist/policy/content-reader.d.ts +24 -0
- package/dist/policy/content-reader.js +52 -0
- package/dist/policy/content-reader.test.d.ts +4 -0
- package/dist/policy/content-reader.test.js +22 -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 +527 -0
- package/dist/policy/preview-ledger.d.ts +118 -0
- package/dist/policy/preview-ledger.js +243 -0
- package/dist/policy/preview-ledger.test.d.ts +1 -0
- package/dist/policy/preview-ledger.test.js +267 -0
- package/dist/policy/result-limits.d.ts +27 -0
- package/dist/policy/result-limits.js +107 -0
- package/dist/policy/result-limits.test.d.ts +4 -0
- package/dist/policy/result-limits.test.js +28 -0
- package/dist/protocol-contract.test.d.ts +1 -0
- package/dist/protocol-contract.test.js +42 -0
- package/dist/server/capabilities.d.ts +15 -0
- package/dist/server/capabilities.js +19 -0
- package/dist/server/capabilities.test.d.ts +1 -0
- package/dist/server/capabilities.test.js +41 -0
- package/dist/server/errors.test.d.ts +1 -0
- package/dist/server/errors.test.js +53 -0
- package/dist/server/request-context.d.ts +13 -0
- package/dist/server/request-context.js +2 -0
- package/dist/server/server.d.ts +4 -0
- package/dist/server/server.js +28 -0
- package/dist/server/server.test.d.ts +1 -0
- package/dist/server/server.test.js +15 -0
- package/dist/server/version.d.ts +1 -0
- package/dist/server/version.js +7 -0
- package/dist/server/version.test.d.ts +1 -0
- package/dist/server/version.test.js +9 -0
- package/dist/stdio.process.test.d.ts +1 -0
- package/dist/stdio.process.test.js +274 -0
- package/dist/store/config.d.ts +11 -0
- package/dist/store/config.js +50 -0
- package/dist/store/config.test.d.ts +1 -0
- package/dist/store/config.test.js +56 -0
- package/dist/store/create-oauth-broker-store.d.ts +6 -0
- package/dist/store/create-oauth-broker-store.js +16 -0
- package/dist/store/create-preview-store.d.ts +10 -0
- package/dist/store/create-preview-store.js +30 -0
- package/dist/store/create-session-store.d.ts +19 -0
- package/dist/store/create-session-store.js +24 -0
- package/dist/store/in-memory-preview-store.d.ts +17 -0
- package/dist/store/in-memory-preview-store.js +72 -0
- package/dist/store/redis-client.d.ts +11 -0
- package/dist/store/redis-client.js +48 -0
- package/dist/store/redis-oauth-broker-store.d.ts +42 -0
- package/dist/store/redis-oauth-broker-store.js +167 -0
- package/dist/store/redis-oauth-broker-store.test.d.ts +1 -0
- package/dist/store/redis-oauth-broker-store.test.js +80 -0
- package/dist/store/redis-preview-store.d.ts +23 -0
- package/dist/store/redis-preview-store.js +94 -0
- package/dist/store/redis-preview-store.test.d.ts +1 -0
- package/dist/store/redis-preview-store.test.js +39 -0
- package/dist/store/redis-session-index.d.ts +33 -0
- package/dist/store/redis-session-index.js +49 -0
- package/dist/store/types.d.ts +13 -0
- package/dist/store/types.js +8 -0
- package/dist/tools/composition/explain-content.d.ts +6 -0
- package/dist/tools/composition/explain-content.js +108 -0
- package/dist/tools/index.d.ts +2 -4
- package/dist/tools/index.js +4 -30
- package/dist/tools/index.test.d.ts +1 -0
- package/dist/tools/index.test.js +72 -0
- package/dist/tools/lib/api-errors.d.ts +11 -0
- package/dist/tools/lib/api-errors.js +27 -0
- package/dist/tools/lib/api-shape.d.ts +16 -0
- package/dist/tools/lib/api-shape.js +47 -0
- package/dist/tools/lib/assert-safe.d.ts +13 -0
- package/dist/tools/lib/assert-safe.js +21 -0
- package/dist/tools/lib/assert-safe.test.d.ts +4 -0
- package/dist/tools/lib/assert-safe.test.js +32 -0
- package/dist/tools/lib/concurrency.d.ts +4 -0
- package/dist/tools/lib/concurrency.js +24 -0
- package/dist/tools/lib/contracts.d.ts +34 -0
- package/dist/tools/lib/contracts.js +30 -0
- package/dist/tools/lib/redaction.d.ts +107 -0
- package/dist/tools/lib/redaction.js +299 -0
- package/dist/tools/lib/redaction.test.d.ts +4 -0
- package/dist/tools/lib/redaction.test.js +216 -0
- package/dist/tools/lib/register-org-audit.d.ts +9 -0
- package/dist/tools/lib/register-org-audit.js +20 -0
- package/dist/tools/lib/schema-fields.d.ts +9 -0
- package/dist/tools/lib/schema-fields.js +19 -0
- package/dist/tools/lib/stable-stringify.d.ts +9 -0
- package/dist/tools/lib/stable-stringify.js +35 -0
- package/dist/tools/organization/binding.d.ts +14 -0
- package/dist/tools/organization/binding.js +31 -0
- package/dist/tools/organization/invariants.test.d.ts +4 -0
- package/dist/tools/organization/invariants.test.js +28 -0
- package/dist/tools/organization/inventory.d.ts +10 -0
- package/dist/tools/organization/inventory.js +189 -0
- package/dist/tools/organization/roles.d.ts +10 -0
- package/dist/tools/organization/roles.js +213 -0
- package/dist/tools/project/content.d.ts +9 -0
- package/dist/tools/project/content.js +192 -0
- 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 +12 -0
- package/dist/tools/project/developer-content-preview.js +286 -0
- package/dist/tools/project/developer-content-shared.d.ts +18 -0
- package/dist/tools/project/developer-content-shared.js +46 -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 +39 -0
- package/dist/tools/project/developer-content.js +584 -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 +42 -0
- package/dist/tools/project/invariants.test.d.ts +4 -0
- package/dist/tools/project/invariants.test.js +42 -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 +10 -0
- package/dist/tools/project/projects.js +102 -0
- package/dist/tools/project/projects.test.d.ts +1 -0
- package/dist/tools/project/projects.test.js +154 -0
- 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/schedulers.d.ts +7 -0
- package/dist/tools/project/schedulers.js +115 -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 +112 -0
- package/dist/tools/query/query-ledger.d.ts +34 -0
- package/dist/tools/query/query-ledger.js +86 -0
- package/dist/tools/query/query-ledger.test.d.ts +1 -0
- package/dist/tools/query/query-ledger.test.js +73 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +12 -0
- package/dist/tools/query/reader-tool-helpers.js +59 -0
- package/dist/tools/query/reader-tool-helpers.test.d.ts +1 -0
- package/dist/tools/query/reader-tool-helpers.test.js +49 -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 +225 -0
- package/dist/tools/registry.js +115 -0
- package/dist/tools/semantic/explore-helpers.d.ts +56 -0
- package/dist/tools/semantic/explore-helpers.js +115 -0
- package/dist/tools/semantic/explore-helpers.test.d.ts +1 -0
- package/dist/tools/semantic/explore-helpers.test.js +170 -0
- package/dist/tools/semantic/explores.d.ts +9 -0
- package/dist/tools/semantic/explores.js +80 -0
- package/dist/tools/semantic/metrics.d.ts +7 -0
- package/dist/tools/semantic/metrics.js +53 -0
- package/dist/tools/semantic/query.d.ts +6 -0
- package/dist/tools/semantic/query.js +42 -0
- package/dist/tools/semantic/schema-fields.d.ts +3 -0
- package/dist/tools/semantic/schema-fields.js +7 -0
- package/dist/tools/shared.d.ts +51 -15
- package/dist/tools/shared.js +171 -163
- package/dist/tools/shared.test.js +137 -184
- package/dist/tools/space/access.d.ts +66 -0
- package/dist/tools/space/access.js +322 -0
- package/dist/tools/space/access.test.d.ts +4 -0
- package/dist/tools/space/access.test.js +90 -0
- package/dist/transports/http-body.d.ts +5 -0
- package/dist/transports/http-body.js +50 -0
- package/dist/transports/http-request-utils.d.ts +2 -0
- package/dist/transports/http-request-utils.js +13 -0
- package/dist/transports/http-response.d.ts +6 -0
- package/dist/transports/http-response.js +56 -0
- package/dist/transports/session-store.d.ts +72 -0
- package/dist/transports/session-store.js +143 -0
- package/dist/transports/session-store.test.d.ts +1 -0
- package/dist/transports/session-store.test.js +111 -0
- package/dist/transports/streamable-http.d.ts +9 -0
- package/dist/transports/streamable-http.js +461 -0
- package/dist/transports/streamable-http.test.d.ts +1 -0
- package/dist/transports/streamable-http.test.js +100 -0
- package/package.json +26 -10
- package/dist/audit.d.ts +0 -6
- package/dist/config.d.ts +0 -47
- package/dist/config.js +0 -82
- package/dist/tools/ai-agents.d.ts +0 -6
- package/dist/tools/ai-agents.js +0 -388
- package/dist/tools/charts.d.ts +0 -6
- package/dist/tools/charts.js +0 -55
- package/dist/tools/content.d.ts +0 -6
- package/dist/tools/content.js +0 -37
- package/dist/tools/dashboards.d.ts +0 -6
- package/dist/tools/dashboards.js +0 -28
- package/dist/tools/explores.d.ts +0 -6
- package/dist/tools/explores.js +0 -65
- package/dist/tools/groups.d.ts +0 -6
- package/dist/tools/groups.js +0 -121
- package/dist/tools/metrics.d.ts +0 -6
- package/dist/tools/metrics.js +0 -45
- package/dist/tools/projects.d.ts +0 -6
- package/dist/tools/projects.js +0 -58
- package/dist/tools/query.d.ts +0 -6
- package/dist/tools/query.js +0 -34
- package/dist/tools/schedulers.d.ts +0 -6
- package/dist/tools/schedulers.js +0 -45
- package/dist/tools/spaces.d.ts +0 -6
- package/dist/tools/spaces.js +0 -128
- package/dist/tools/tags.d.ts +0 -6
- package/dist/tools/tags.js +0 -28
- package/dist/tools/users.d.ts +0 -6
- package/dist/tools/users.js +0 -50
- package/src/audit.ts +0 -6
- package/src/bin.ts +0 -58
- package/src/config.ts +0 -83
- package/src/errors.ts +0 -27
- package/src/http.ts +0 -187
- package/src/index.integration.test.ts +0 -57
- package/src/index.test.ts +0 -8
- package/src/index.ts +0 -31
- package/src/tools/ai-agents.ts +0 -759
- package/src/tools/charts.ts +0 -85
- package/src/tools/content.ts +0 -44
- package/src/tools/dashboards.ts +0 -25
- package/src/tools/explores.ts +0 -98
- package/src/tools/groups.ts +0 -180
- package/src/tools/index.ts +0 -35
- package/src/tools/metrics.ts +0 -42
- package/src/tools/projects.ts +0 -74
- package/src/tools/query.ts +0 -47
- package/src/tools/schedulers.ts +0 -42
- package/src/tools/shared.test.ts +0 -365
- package/src/tools/shared.ts +0 -274
- package/src/tools/spaces.ts +0 -217
- package/src/tools/tags.ts +0 -25
- package/src/tools/users.ts +0 -64
- package/tsconfig.json +0 -13
- /package/dist/{errors.d.ts → server/errors.d.ts} +0 -0
- /package/dist/{errors.js → server/errors.js} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
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:
|
|
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).
|
|
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).
|
|
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.
|
|
8
|
+
|
|
9
|
+
## Directory map
|
|
10
|
+
|
|
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` |
|
|
23
|
+
|
|
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_*` |
|
|
4
36
|
|
|
5
37
|
## Installation
|
|
6
38
|
|
|
@@ -21,26 +53,80 @@ npm install -g @lightdash-tools/mcp
|
|
|
21
53
|
- **Stdio** — for local use (e.g. Claude Desktop, IDE). One process per client.
|
|
22
54
|
- **Streamable HTTP** — for remote use. Session-based; supports optional endpoint auth.
|
|
23
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
|
+
|
|
24
74
|
## Environment variables
|
|
25
75
|
|
|
26
|
-
|
|
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)
|
|
27
79
|
|
|
28
|
-
|
|
29
|
-
|
|
80
|
+
| Required | Optional |
|
|
81
|
+
| :----------------------------------- | :-------------------------- |
|
|
82
|
+
| `LIGHTDASH_URL`, `LIGHTDASH_API_KEY` | `LIGHTDASH_TOOLS_AUDIT_LOG` |
|
|
30
83
|
|
|
31
|
-
|
|
84
|
+
Do **not** set OAuth client secrets for stdio. MCP does not use CLI `SAFETY_MODE` / `ALLOWED_PROJECTS` / `DRY_RUN`.
|
|
32
85
|
|
|
33
|
-
|
|
34
|
-
- `LIGHTDASH_TOOLS_ALLOWED_PROJECTS` — Comma-separated project UUIDs to restrict operations (empty = all allowed). CLI `--projects` overrides.
|
|
35
|
-
- `LIGHTDASH_TOOLS_DRY_RUN` — Set to `1`, `true`, or `yes` to simulate write operations without executing.
|
|
86
|
+
### HTTP OAuth (primary)
|
|
36
87
|
|
|
37
|
-
|
|
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 |
|
|
38
91
|
|
|
39
|
-
|
|
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`.
|
|
40
93
|
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
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).
|
|
44
130
|
|
|
45
131
|
## Running
|
|
46
132
|
|
|
@@ -50,53 +136,116 @@ For use with Claude Desktop or IDEs, use `npx`:
|
|
|
50
136
|
|
|
51
137
|
```bash
|
|
52
138
|
npx @lightdash-tools/mcp
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
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
|
|
59
145
|
```
|
|
60
146
|
|
|
61
147
|
Or if installed globally:
|
|
62
148
|
|
|
63
149
|
```bash
|
|
64
150
|
lightdash-mcp
|
|
151
|
+
lightdash-mcp organization-audit
|
|
152
|
+
lightdash-mcp content-reader
|
|
153
|
+
lightdash-mcp content-developer
|
|
154
|
+
lightdash-mcp content-governance
|
|
65
155
|
```
|
|
66
156
|
|
|
67
|
-
Logging goes to stderr only; stdout is JSON-RPC.
|
|
157
|
+
Logging goes to stderr only; stdout is JSON-RPC. Bare `lightdash-mcp` defaults to `semantic-layer`.
|
|
68
158
|
|
|
69
159
|
### Streamable HTTP (remote)
|
|
70
160
|
|
|
71
161
|
```bash
|
|
162
|
+
# Backward-compatible
|
|
72
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
|
+
export LIGHTDASH_URL="https://app.lightdash.cloud"
|
|
170
|
+
export LIGHTDASH_TOOLS_MCP_PUBLIC_URL="https://lightdash-mcp.example.com"
|
|
171
|
+
export LIGHTDASH_TOOLS_OAUTH_CLIENT_ID="..."
|
|
172
|
+
export LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET="..."
|
|
173
|
+
npx @lightdash-tools/mcp serve-http
|
|
73
174
|
```
|
|
74
175
|
|
|
75
|
-
The server listens on `http://localhost:3100` (or `
|
|
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`
|
|
76
183
|
|
|
77
|
-
|
|
184
|
+
Register `{PUBLIC_URL}/oauth/callback` in Lightdash. See [mcp-oauth-http.md](../../docs/mcp-oauth-http.md).
|
|
185
|
+
|
|
186
|
+
**Local Compose (dev):**
|
|
187
|
+
|
|
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).
|
|
78
190
|
|
|
79
191
|
## Tools
|
|
80
192
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- **
|
|
86
|
-
- **
|
|
87
|
-
- **
|
|
88
|
-
- **
|
|
89
|
-
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
193
|
+
### `semantic-layer` persona
|
|
194
|
+
|
|
195
|
+
Registers these tools (names prefixed with `lightdash_`):
|
|
196
|
+
|
|
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)
|
|
201
|
+
|
|
202
|
+
Prompts and playbook: `lightdash://playbooks/semantic-layer` (cite `lightdash_*` names only).
|
|
203
|
+
|
|
204
|
+
### `organization-audit` persona
|
|
205
|
+
|
|
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).
|
|
207
|
+
|
|
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`
|
|
212
|
+
|
|
213
|
+
Prompts and playbook: `lightdash://playbooks/organization-audit` (host orchestrates multi-step audits via primitives). No mutation, warehouse queries, or user-activity CSV download.
|
|
214
|
+
|
|
215
|
+
### `content-reader` persona
|
|
216
|
+
|
|
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).
|
|
218
|
+
|
|
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)
|
|
223
|
+
|
|
224
|
+
Project resolution: `X-Lightdash-Project` → `LIGHTDASH_TOOLS_PROJECT_UUID` → tool `projectUuid`. Prompts and playbook: `lightdash://playbooks/content-reader`.
|
|
225
|
+
|
|
226
|
+
### `content-developer` persona
|
|
227
|
+
|
|
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).
|
|
229
|
+
|
|
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)
|
|
236
|
+
|
|
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`.
|
|
238
|
+
|
|
239
|
+
### `content-governance` persona
|
|
240
|
+
|
|
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).
|
|
242
|
+
|
|
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
|
|
247
|
+
|
|
248
|
+
Prompts and playbooks: `lightdash://playbooks/content-governance` (core + charts + dashboards topics).
|
|
100
249
|
|
|
101
250
|
### CLI Binary
|
|
102
251
|
|
|
@@ -109,32 +258,28 @@ lightdash-mcp --help
|
|
|
109
258
|
### CLI Options
|
|
110
259
|
|
|
111
260
|
- `--http` — Run as HTTP server instead of Stdio.
|
|
112
|
-
-
|
|
113
|
-
- `--projects <uuids>` — Comma-separated list of allowed project UUIDs (overrides `LIGHTDASH_TOOLS_ALLOWED_PROJECTS`; empty = all allowed).
|
|
114
|
-
- `--dry-run` — Simulate write operations without executing them (overrides `LIGHTDASH_TOOLS_DRY_RUN`).
|
|
261
|
+
- `stdio` / `semantic-layer` / `organization-audit` / `content-reader` / `content-developer` / `content-governance` / `serve-http` — Explicit transport/persona subcommands.
|
|
115
262
|
|
|
116
|
-
## Safety
|
|
263
|
+
## Safety (persona-first)
|
|
117
264
|
|
|
118
|
-
|
|
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)):
|
|
119
266
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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 |
|
|
123
273
|
|
|
124
|
-
|
|
274
|
+
Process `LIGHTDASH_TOOLS_SAFETY_MODE` / allowlist / dry-run are **CLI-only**, not used by this package.
|
|
125
275
|
|
|
126
|
-
|
|
127
|
-
2. **Static Filtering (Hidden)**: Using the `--safety-mode` CLI option. Tools not allowed in the selected mode are not registered at all. They are completely hidden from the AI agent.
|
|
276
|
+
### Agent-safe surface
|
|
128
277
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
### Destructive tools
|
|
132
|
-
|
|
133
|
-
Tools with `destructiveHint: true` (e.g. `delete_member`) perform irreversible or high-impact actions. MCP clients should show a warning and/or require user confirmation before executing them. AI agents should ask the user for explicit confirmation before calling such tools.
|
|
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)).
|
|
134
279
|
|
|
135
280
|
### Input validation
|
|
136
281
|
|
|
137
|
-
Resource IDs (project UUIDs, slugs) are validated before execution. Invalid inputs (control characters, `?`, `#`, `%`, path traversal) are rejected.
|
|
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).
|
|
138
283
|
|
|
139
284
|
## Testing
|
|
140
285
|
|
|
@@ -156,6 +301,8 @@ LIGHTDASH_URL=https://app.lightdash.cloud LIGHTDASH_API_KEY=your_api_key pnpm te
|
|
|
156
301
|
|
|
157
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.
|
|
158
303
|
|
|
304
|
+
For OAuth HTTP mode, set `LIGHTDASH_TOOLS_TEST_OAUTH_ACCESS_TOKEN` (and `LIGHTDASH_URL`) to run the optional live OAuth integration test.
|
|
305
|
+
|
|
159
306
|
## License
|
|
160
307
|
|
|
161
308
|
Apache-2.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.initAuditLog = exports.getSessionId = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Re-exports the shared audit logger from @lightdash-tools/common.
|
|
6
6
|
* The canonical implementation lives in common so the CLI can also use it.
|
|
@@ -8,4 +8,3 @@ exports.logAuditEntry = exports.initAuditLog = exports.getSessionId = void 0;
|
|
|
8
8
|
var common_1 = require("@lightdash-tools/common");
|
|
9
9
|
Object.defineProperty(exports, "getSessionId", { enumerable: true, get: function () { return common_1.getSessionId; } });
|
|
10
10
|
Object.defineProperty(exports, "initAuditLog", { enumerable: true, get: function () { return common_1.initAuditLog; } });
|
|
11
|
-
Object.defineProperty(exports, "logAuditEntry", { enumerable: true, get: function () { return common_1.logAuditEntry; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type ToolAuditAuthContext = {
|
|
2
|
+
tokenHash?: string;
|
|
3
|
+
subject?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function runWithToolAuditAuthAsync<T>(auth: ToolAuditAuthContext, fn: () => Promise<T>): Promise<T>;
|
|
6
|
+
export declare function getToolAuditAuth(): ToolAuditAuthContext | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runWithToolAuditAuthAsync = runWithToolAuditAuthAsync;
|
|
4
|
+
exports.getToolAuditAuth = getToolAuditAuth;
|
|
5
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
6
|
+
const storage = new node_async_hooks_1.AsyncLocalStorage();
|
|
7
|
+
async function runWithToolAuditAuthAsync(auth, fn) {
|
|
8
|
+
return storage.run(auth, fn);
|
|
9
|
+
}
|
|
10
|
+
function getToolAuditAuth() {
|
|
11
|
+
return storage.getStore();
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const tool_audit_context_js_1 = require("./tool-audit-context.js");
|
|
5
|
+
(0, vitest_1.describe)('tool-audit-context', () => {
|
|
6
|
+
(0, vitest_1.it)('exposes auth fields within the async scope', async () => {
|
|
7
|
+
const seen = [];
|
|
8
|
+
await (0, tool_audit_context_js_1.runWithToolAuditAuthAsync)({ tokenHash: 'hash-abc', subject: 'user-1' }, async () => {
|
|
9
|
+
seen.push((0, tool_audit_context_js_1.getToolAuditAuth)());
|
|
10
|
+
await Promise.resolve();
|
|
11
|
+
seen.push((0, tool_audit_context_js_1.getToolAuditAuth)());
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.expect)(seen).toEqual([
|
|
14
|
+
{ tokenHash: 'hash-abc', subject: 'user-1' },
|
|
15
|
+
{ tokenHash: 'hash-abc', subject: 'user-1' },
|
|
16
|
+
]);
|
|
17
|
+
(0, vitest_1.expect)((0, tool_audit_context_js_1.getToolAuditAuth)()).toBeUndefined();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MCP_AUTH_MODE_LIGHTDASH_OAUTH = exports.MCP_AUTH_MODE_SHARED_KEY = exports.MCP_AUTH_MODE_NONE = void 0;
|
|
4
|
+
exports.MCP_AUTH_MODE_NONE = 'none';
|
|
5
|
+
exports.MCP_AUTH_MODE_SHARED_KEY = 'shared-key';
|
|
6
|
+
exports.MCP_AUTH_MODE_LIGHTDASH_OAUTH = 'lightdash-oauth';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractBearerToken = extractBearerToken;
|
|
4
|
+
const BEARER_PREFIX = /^bearer\s+/i;
|
|
5
|
+
/** Extracts a bearer token from Authorization header (case-insensitive scheme). */
|
|
6
|
+
function extractBearerToken(req) {
|
|
7
|
+
const authorization = req.headers.authorization;
|
|
8
|
+
if (typeof authorization !== 'string' || !BEARER_PREFIX.test(authorization)) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const token = authorization.replace(BEARER_PREFIX, '').trim();
|
|
12
|
+
return token.length > 0 ? token : undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upstream Lightdash OAuth contract used by MCP token validation.
|
|
3
|
+
*
|
|
4
|
+
* MCP validates identity by calling `GET /api/v1/user` with the user's OAuth access
|
|
5
|
+
* token as `Authorization: Bearer <token>`. This is not an MCP invention: upstream
|
|
6
|
+
* Lightdash wires that route through `allowApiKeyAuthentication`, which authenticates
|
|
7
|
+
* OAuth bearer tokens before personal access tokens.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/lightdash/lightdash/blob/master/packages/backend/src/controllers/userController.ts
|
|
10
|
+
* @see https://github.com/lightdash/lightdash/blob/master/packages/backend/src/controllers/authentication/middlewares.ts
|
|
11
|
+
*/
|
|
12
|
+
export declare const LIGHTDASH_OAUTH_VALIDATION_ENDPOINT: "/api/v1/user";
|
|
13
|
+
export declare const LIGHTDASH_OAUTH_AUTHORIZE_ENDPOINT: "/api/v1/oauth/authorize";
|
|
14
|
+
export declare const LIGHTDASH_OAUTH_TOKEN_ENDPOINT: "/api/v1/oauth/token";
|
|
15
|
+
/** Middleware chain on upstream `GetAuthenticatedUser` (TSOA `UserController`). */
|
|
16
|
+
export declare const LIGHTDASH_GET_AUTHENTICATED_USER_MIDDLEWARE: readonly ["allowApiKeyAuthentication", "isAuthenticated"];
|
|
17
|
+
/**
|
|
18
|
+
* Order enforced by upstream `allowApiKeyAuthentication`:
|
|
19
|
+
* OAuth bearer → service account bearer → personal access token (`ApiKey` header).
|
|
20
|
+
*/
|
|
21
|
+
export declare const LIGHTDASH_ALLOW_API_KEY_AUTH_ORDER: readonly ["oauth-bearer", "service-account-bearer", "personal-access-token"];
|
|
22
|
+
export declare const LIGHTDASH_OAUTH_UPSTREAM_REFERENCES: readonly ["lightdash/lightdash packages/backend/src/controllers/userController.ts — GetAuthenticatedUser uses allowApiKeyAuthentication", "lightdash/lightdash packages/backend/src/controllers/authentication/middlewares.ts — allowApiKeyAuthentication tries oauthService.authenticate() first", "lightdash/lightdash packages/backend/src/routers/oauthRouter.ts — /api/v1/oauth/userinfo also uses allowApiKeyAuthentication (alternate OIDC surface, not used by MCP v1 validation)"];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LIGHTDASH_OAUTH_UPSTREAM_REFERENCES = exports.LIGHTDASH_ALLOW_API_KEY_AUTH_ORDER = exports.LIGHTDASH_GET_AUTHENTICATED_USER_MIDDLEWARE = exports.LIGHTDASH_OAUTH_TOKEN_ENDPOINT = exports.LIGHTDASH_OAUTH_AUTHORIZE_ENDPOINT = exports.LIGHTDASH_OAUTH_VALIDATION_ENDPOINT = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Upstream Lightdash OAuth contract used by MCP token validation.
|
|
6
|
+
*
|
|
7
|
+
* MCP validates identity by calling `GET /api/v1/user` with the user's OAuth access
|
|
8
|
+
* token as `Authorization: Bearer <token>`. This is not an MCP invention: upstream
|
|
9
|
+
* Lightdash wires that route through `allowApiKeyAuthentication`, which authenticates
|
|
10
|
+
* OAuth bearer tokens before personal access tokens.
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/lightdash/lightdash/blob/master/packages/backend/src/controllers/userController.ts
|
|
13
|
+
* @see https://github.com/lightdash/lightdash/blob/master/packages/backend/src/controllers/authentication/middlewares.ts
|
|
14
|
+
*/
|
|
15
|
+
exports.LIGHTDASH_OAUTH_VALIDATION_ENDPOINT = '/api/v1/user';
|
|
16
|
+
exports.LIGHTDASH_OAUTH_AUTHORIZE_ENDPOINT = '/api/v1/oauth/authorize';
|
|
17
|
+
exports.LIGHTDASH_OAUTH_TOKEN_ENDPOINT = '/api/v1/oauth/token';
|
|
18
|
+
/** Middleware chain on upstream `GetAuthenticatedUser` (TSOA `UserController`). */
|
|
19
|
+
exports.LIGHTDASH_GET_AUTHENTICATED_USER_MIDDLEWARE = [
|
|
20
|
+
'allowApiKeyAuthentication',
|
|
21
|
+
'isAuthenticated',
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Order enforced by upstream `allowApiKeyAuthentication`:
|
|
25
|
+
* OAuth bearer → service account bearer → personal access token (`ApiKey` header).
|
|
26
|
+
*/
|
|
27
|
+
exports.LIGHTDASH_ALLOW_API_KEY_AUTH_ORDER = [
|
|
28
|
+
'oauth-bearer',
|
|
29
|
+
'service-account-bearer',
|
|
30
|
+
'personal-access-token',
|
|
31
|
+
];
|
|
32
|
+
exports.LIGHTDASH_OAUTH_UPSTREAM_REFERENCES = [
|
|
33
|
+
'lightdash/lightdash packages/backend/src/controllers/userController.ts — GetAuthenticatedUser uses allowApiKeyAuthentication',
|
|
34
|
+
'lightdash/lightdash packages/backend/src/controllers/authentication/middlewares.ts — allowApiKeyAuthentication tries oauthService.authenticate() first',
|
|
35
|
+
'lightdash/lightdash packages/backend/src/routers/oauthRouter.ts — /api/v1/oauth/userinfo also uses allowApiKeyAuthentication (alternate OIDC surface, not used by MCP v1 validation)',
|
|
36
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const lightdash_oauth_upstream_contract_js_1 = require("./lightdash-oauth-upstream-contract.js");
|
|
5
|
+
(0, vitest_1.describe)('Lightdash OAuth upstream contract', () => {
|
|
6
|
+
(0, vitest_1.it)('documents GET /api/v1/user as the validation endpoint with allowApiKeyAuthentication', () => {
|
|
7
|
+
(0, vitest_1.expect)(lightdash_oauth_upstream_contract_js_1.LIGHTDASH_OAUTH_VALIDATION_ENDPOINT).toBe('/api/v1/user');
|
|
8
|
+
(0, vitest_1.expect)(lightdash_oauth_upstream_contract_js_1.LIGHTDASH_GET_AUTHENTICATED_USER_MIDDLEWARE).toEqual([
|
|
9
|
+
'allowApiKeyAuthentication',
|
|
10
|
+
'isAuthenticated',
|
|
11
|
+
]);
|
|
12
|
+
(0, vitest_1.expect)(lightdash_oauth_upstream_contract_js_1.LIGHTDASH_ALLOW_API_KEY_AUTH_ORDER[0]).toBe('oauth-bearer');
|
|
13
|
+
(0, vitest_1.expect)(lightdash_oauth_upstream_contract_js_1.LIGHTDASH_OAUTH_UPSTREAM_REFERENCES.length).toBeGreaterThanOrEqual(2);
|
|
14
|
+
(0, vitest_1.expect)(lightdash_oauth_upstream_contract_js_1.LIGHTDASH_OAUTH_UPSTREAM_REFERENCES.join(' ')).toContain('userController.ts');
|
|
15
|
+
(0, vitest_1.expect)(lightdash_oauth_upstream_contract_js_1.LIGHTDASH_OAUTH_UPSTREAM_REFERENCES.join(' ')).toContain('middlewares.ts');
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.it)('expects AuthenticatedUser to expose optional organizationUuid for session binding', () => {
|
|
18
|
+
const user = {
|
|
19
|
+
userUuid: 'user-uuid',
|
|
20
|
+
firstName: 'Test',
|
|
21
|
+
lastName: 'User',
|
|
22
|
+
userId: 1,
|
|
23
|
+
isTrackingAnonymized: false,
|
|
24
|
+
isMarketingOptedIn: false,
|
|
25
|
+
isSetupComplete: true,
|
|
26
|
+
isActive: true,
|
|
27
|
+
createdAt: '2026-01-01T00:00:00.000Z',
|
|
28
|
+
updatedAt: '2026-01-01T00:00:00.000Z',
|
|
29
|
+
timezone: null,
|
|
30
|
+
organizationUuid: 'org-uuid',
|
|
31
|
+
impersonation: null,
|
|
32
|
+
avatarUrl: null,
|
|
33
|
+
avatarGradient: null,
|
|
34
|
+
};
|
|
35
|
+
(0, vitest_1.expect)(user.organizationUuid).toBe('org-uuid');
|
|
36
|
+
});
|
|
37
|
+
(0, vitest_1.it)('allows AuthenticatedUser without organizationUuid (org binding falls back to subject only)', () => {
|
|
38
|
+
const user = {
|
|
39
|
+
userUuid: 'user-uuid',
|
|
40
|
+
firstName: 'Test',
|
|
41
|
+
lastName: 'User',
|
|
42
|
+
userId: 1,
|
|
43
|
+
isTrackingAnonymized: false,
|
|
44
|
+
isMarketingOptedIn: false,
|
|
45
|
+
isSetupComplete: true,
|
|
46
|
+
isActive: true,
|
|
47
|
+
createdAt: '2026-01-01T00:00:00.000Z',
|
|
48
|
+
updatedAt: '2026-01-01T00:00:00.000Z',
|
|
49
|
+
timezone: null,
|
|
50
|
+
impersonation: null,
|
|
51
|
+
avatarUrl: null,
|
|
52
|
+
avatarGradient: null,
|
|
53
|
+
};
|
|
54
|
+
(0, vitest_1.expect)(user.organizationUuid).toBeUndefined();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type McpHttpConfig } from '../../config/load-mcp-config.js';
|
|
2
|
+
export interface AuthorizationServerMetadata {
|
|
3
|
+
issuer: string;
|
|
4
|
+
authorization_endpoint: string;
|
|
5
|
+
token_endpoint: string;
|
|
6
|
+
registration_endpoint: string;
|
|
7
|
+
response_types_supported: string[];
|
|
8
|
+
grant_types_supported: string[];
|
|
9
|
+
code_challenge_methods_supported: string[];
|
|
10
|
+
token_endpoint_auth_methods_supported: string[];
|
|
11
|
+
scopes_supported: string[];
|
|
12
|
+
}
|
|
13
|
+
/** RFC 8414 metadata for the MCP-hosted OAuth broker (issuer = PUBLIC_URL). */
|
|
14
|
+
export declare function buildBrokerAuthorizationServerMetadata(config: McpHttpConfig): AuthorizationServerMetadata;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBrokerAuthorizationServerMetadata = buildBrokerAuthorizationServerMetadata;
|
|
4
|
+
const env_js_1 = require("../../config/env.js");
|
|
5
|
+
const public_url_js_1 = require("../../config/public-url.js");
|
|
6
|
+
/** RFC 8414 metadata for the MCP-hosted OAuth broker (issuer = PUBLIC_URL). */
|
|
7
|
+
function buildBrokerAuthorizationServerMetadata(config) {
|
|
8
|
+
const issuer = (0, public_url_js_1.requirePublicUrl)(config, 'authorization server metadata');
|
|
9
|
+
return {
|
|
10
|
+
issuer,
|
|
11
|
+
authorization_endpoint: `${issuer}${env_js_1.OAUTH_AUTHORIZE_PATH}`,
|
|
12
|
+
token_endpoint: `${issuer}${env_js_1.OAUTH_TOKEN_PATH}`,
|
|
13
|
+
registration_endpoint: `${issuer}${env_js_1.OAUTH_REGISTER_PATH}`,
|
|
14
|
+
response_types_supported: ['code'],
|
|
15
|
+
grant_types_supported: ['authorization_code'],
|
|
16
|
+
code_challenge_methods_supported: ['S256'],
|
|
17
|
+
token_endpoint_auth_methods_supported: ['none'],
|
|
18
|
+
scopes_supported: config.scopesSupported,
|
|
19
|
+
};
|
|
20
|
+
}
|