@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
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStreamableHttpServer = createStreamableHttpServer;
|
|
4
|
+
exports.startStreamableHttpServer = startStreamableHttpServer;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const node_http_1 = require("node:http");
|
|
7
|
+
const node_1 = require("@modelcontextprotocol/node");
|
|
8
|
+
const audit_js_1 = require("../audit/audit.js");
|
|
9
|
+
const tool_audit_context_js_1 = require("../audit/tool-audit-context.js");
|
|
10
|
+
const auth_mode_js_1 = require("../auth/auth-mode.js");
|
|
11
|
+
const routes_js_1 = require("../auth/oauth-broker/routes.js");
|
|
12
|
+
const bearer_context_provider_js_1 = require("../auth/providers/bearer-context-provider.js");
|
|
13
|
+
const env_context_provider_js_1 = require("../auth/providers/env-context-provider.js");
|
|
14
|
+
const lightdash_oauth_middleware_js_1 = require("../auth/resource-server/lightdash-oauth-middleware.js");
|
|
15
|
+
const oauth_protected_resource_js_1 = require("../auth/resource-server/oauth-protected-resource.js");
|
|
16
|
+
const shared_key_middleware_js_1 = require("../auth/resource-server/shared-key-middleware.js");
|
|
17
|
+
const token_hash_js_1 = require("../auth/token-hash.js");
|
|
18
|
+
const load_mcp_config_js_1 = require("../config/load-mcp-config.js");
|
|
19
|
+
const runtime_js_1 = require("../config/runtime.js");
|
|
20
|
+
const project_pin_js_1 = require("../governance/project-pin.js");
|
|
21
|
+
const index_js_1 = require("../personas/index.js");
|
|
22
|
+
const server_js_1 = require("../server/server.js");
|
|
23
|
+
const config_js_1 = require("../store/config.js");
|
|
24
|
+
const create_oauth_broker_store_js_1 = require("../store/create-oauth-broker-store.js");
|
|
25
|
+
const create_session_store_js_1 = require("../store/create-session-store.js");
|
|
26
|
+
const http_body_js_1 = require("./http-body.js");
|
|
27
|
+
const http_request_utils_js_1 = require("./http-request-utils.js");
|
|
28
|
+
const http_response_js_1 = require("./http-response.js");
|
|
29
|
+
const ERROR_SESSION_NOT_FOUND = 'Session not found';
|
|
30
|
+
function listen(server, port, host) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
server.once('error', reject);
|
|
33
|
+
server.listen(port, host, () => {
|
|
34
|
+
server.removeListener('error', reject);
|
|
35
|
+
resolve();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function resolveListenHost(host) {
|
|
40
|
+
return host === '0.0.0.0' ? '127.0.0.1' : host;
|
|
41
|
+
}
|
|
42
|
+
function resolvePublicUrl(publicUrl, listenHost, listenPort) {
|
|
43
|
+
if (!publicUrl) {
|
|
44
|
+
return `http://${listenHost}:${listenPort}`;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const url = new URL(publicUrl);
|
|
48
|
+
if (url.port === '0') {
|
|
49
|
+
url.port = String(listenPort);
|
|
50
|
+
return url.origin;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (_a) {
|
|
54
|
+
// Fall through to the configured value when URL parsing fails.
|
|
55
|
+
}
|
|
56
|
+
return publicUrl;
|
|
57
|
+
}
|
|
58
|
+
function resolveHttpConfig(config, listenPort) {
|
|
59
|
+
const listenHost = resolveListenHost(config.host);
|
|
60
|
+
return Object.assign(Object.assign({}, config), { publicUrl: resolvePublicUrl(config.publicUrl, listenHost, listenPort) });
|
|
61
|
+
}
|
|
62
|
+
function getSessionId(req) {
|
|
63
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
64
|
+
return typeof sessionId === 'string' ? sessionId : sessionId === null || sessionId === void 0 ? void 0 : sessionId[0];
|
|
65
|
+
}
|
|
66
|
+
function createEnvContextProvider(config) {
|
|
67
|
+
return new env_context_provider_js_1.EnvContextProvider({
|
|
68
|
+
mode: config.authMode === auth_mode_js_1.MCP_AUTH_MODE_SHARED_KEY ? auth_mode_js_1.MCP_AUTH_MODE_SHARED_KEY : auth_mode_js_1.MCP_AUTH_MODE_NONE,
|
|
69
|
+
client: (0, runtime_js_1.getClient)(),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function closeSessionEntry(entry, sessionId, reason) {
|
|
73
|
+
void Promise.all([entry.transport.close(), entry.server.close()]).catch((err) => {
|
|
74
|
+
console.error(`Failed to close MCP session ${sessionId} (${reason}):`, err);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function createSessionTransport(contextProvider, sessionStore, auth, persona) {
|
|
78
|
+
const holder = {
|
|
79
|
+
server: (0, server_js_1.createLightdashMcpServer)(contextProvider, { persona }),
|
|
80
|
+
};
|
|
81
|
+
const transport = new node_1.NodeStreamableHTTPServerTransport({
|
|
82
|
+
sessionIdGenerator: () => (0, node_crypto_1.randomUUID)(),
|
|
83
|
+
onsessioninitialized: (sessionId) => {
|
|
84
|
+
sessionStore.set(sessionId, {
|
|
85
|
+
transport,
|
|
86
|
+
server: holder.server,
|
|
87
|
+
lastAccessAt: Date.now(),
|
|
88
|
+
auth: {
|
|
89
|
+
mode: auth.mode,
|
|
90
|
+
tokenHash: auth.tokenHash,
|
|
91
|
+
subject: auth.subject,
|
|
92
|
+
organizationUuid: auth.organizationUuid,
|
|
93
|
+
},
|
|
94
|
+
contextProvider,
|
|
95
|
+
personaId: persona.id,
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
onsessionclosed: (sessionId) => {
|
|
99
|
+
const entry = sessionStore.get(sessionId);
|
|
100
|
+
sessionStore.delete(sessionId);
|
|
101
|
+
if (entry) {
|
|
102
|
+
closeSessionEntry(entry, sessionId, 'closed');
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
holder.server.connect(transport).catch((err) => {
|
|
107
|
+
console.error('MCP server connect error:', err);
|
|
108
|
+
});
|
|
109
|
+
return transport;
|
|
110
|
+
}
|
|
111
|
+
function handleHealth(path, res, config) {
|
|
112
|
+
if (path === '/health/live') {
|
|
113
|
+
(0, http_response_js_1.sendJson)(res, 200, { status: 'ok' });
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
if ((0, load_mcp_config_js_1.requiresLightdashApiKey)(config.authMode)) {
|
|
118
|
+
(0, runtime_js_1.getClient)();
|
|
119
|
+
}
|
|
120
|
+
(0, http_response_js_1.sendJson)(res, 200, { status: 'ready' });
|
|
121
|
+
}
|
|
122
|
+
catch (_a) {
|
|
123
|
+
(0, http_response_js_1.sendJson)(res, 503, { status: 'not ready' });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Auth helpers for persona MCP routes. PRM path resolution lives in
|
|
128
|
+
* `oauth-protected-resource.ts` (single owner for well-known PRM grammar).
|
|
129
|
+
*/
|
|
130
|
+
async function ensureEndpointAuth(req, res, config, mcpPath) {
|
|
131
|
+
if (config.authMode === auth_mode_js_1.MCP_AUTH_MODE_NONE) {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
if (config.authMode === auth_mode_js_1.MCP_AUTH_MODE_SHARED_KEY) {
|
|
135
|
+
const result = (0, shared_key_middleware_js_1.authenticateSharedKey)(req, config);
|
|
136
|
+
if (!result.ok) {
|
|
137
|
+
(0, http_response_js_1.sendJson)(res, result.status, result.body);
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(req, config, mcpPath);
|
|
143
|
+
if (!result.ok) {
|
|
144
|
+
(0, lightdash_oauth_middleware_js_1.writeOAuthAuthFailure)(res, result);
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
req.lightdashOAuth = result;
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
function getOAuthAuditContext(req) {
|
|
151
|
+
const oauth = req.lightdashOAuth;
|
|
152
|
+
if (!(oauth === null || oauth === void 0 ? void 0 : oauth.ok)) {
|
|
153
|
+
return {};
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
tokenHash: (0, token_hash_js_1.hashToken)(oauth.accessToken),
|
|
157
|
+
subject: oauth.user.userUuid,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function verifySessionAuth(req, res, config, mcpPath, entry) {
|
|
161
|
+
var _a, _b;
|
|
162
|
+
if (!entry || config.authMode !== auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
const oauth = req.lightdashOAuth;
|
|
166
|
+
if (!(oauth === null || oauth === void 0 ? void 0 : oauth.accessToken)) {
|
|
167
|
+
(0, lightdash_oauth_middleware_js_1.writeOAuthAuthFailure)(res, (0, lightdash_oauth_middleware_js_1.buildBearerRequiredFailure)(config, mcpPath));
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (entry.auth.subject && entry.auth.subject !== oauth.user.userUuid) {
|
|
171
|
+
(0, lightdash_oauth_middleware_js_1.writeOAuthAuthFailure)(res, (0, lightdash_oauth_middleware_js_1.buildInvalidTokenFailure)(config, mcpPath, 'Session subject mismatch'));
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
const previousOrg = (_a = entry.auth.organizationUuid) !== null && _a !== void 0 ? _a : null;
|
|
175
|
+
const nextOrg = (_b = oauth.user.organizationUuid) !== null && _b !== void 0 ? _b : null;
|
|
176
|
+
if (previousOrg !== nextOrg) {
|
|
177
|
+
(0, lightdash_oauth_middleware_js_1.writeOAuthAuthFailure)(res, (0, lightdash_oauth_middleware_js_1.buildInvalidTokenFailure)(config, mcpPath, 'Session organization mismatch'));
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
const nextTokenHash = (0, token_hash_js_1.hashToken)(oauth.accessToken);
|
|
181
|
+
if (entry.auth.tokenHash !== nextTokenHash) {
|
|
182
|
+
entry.auth.tokenHash = nextTokenHash;
|
|
183
|
+
if (entry.contextProvider instanceof bearer_context_provider_js_1.BearerContextProvider) {
|
|
184
|
+
entry.contextProvider.updateAccessToken(oauth.accessToken);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
async function handleExistingSessionPost(ctx, sid, body) {
|
|
190
|
+
var _a, _b;
|
|
191
|
+
const { req, res, config, sessionStore, persona } = ctx;
|
|
192
|
+
const entry = sessionStore.get(sid);
|
|
193
|
+
if (!entry) {
|
|
194
|
+
(0, http_response_js_1.sendJson)(res, 404, { error: ERROR_SESSION_NOT_FOUND });
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (entry.personaId !== persona.id) {
|
|
198
|
+
(0, http_response_js_1.sendJson)(res, 404, { error: ERROR_SESSION_NOT_FOUND });
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (!verifySessionAuth(req, res, config, persona.path, entry))
|
|
202
|
+
return;
|
|
203
|
+
sessionStore.touch(sid);
|
|
204
|
+
const auditAuth = getOAuthAuditContext(req);
|
|
205
|
+
await (0, tool_audit_context_js_1.runWithToolAuditAuthAsync)({
|
|
206
|
+
tokenHash: (_a = auditAuth.tokenHash) !== null && _a !== void 0 ? _a : entry.auth.tokenHash,
|
|
207
|
+
subject: (_b = auditAuth.subject) !== null && _b !== void 0 ? _b : entry.auth.subject,
|
|
208
|
+
}, () => entry.transport.handleRequest(req, res, body));
|
|
209
|
+
}
|
|
210
|
+
async function handleInitializePost(ctx, body) {
|
|
211
|
+
const { req, res, config, sessionStore, persona } = ctx;
|
|
212
|
+
const oauth = config.authMode === auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH
|
|
213
|
+
? req.lightdashOAuth
|
|
214
|
+
: undefined;
|
|
215
|
+
const sessionSubject = (oauth === null || oauth === void 0 ? void 0 : oauth.ok) ? oauth.user.userUuid : undefined;
|
|
216
|
+
if (!sessionStore.canAcceptNewSession(sessionSubject, (entry, sessionId) => {
|
|
217
|
+
closeSessionEntry(entry, sessionId, 'expired');
|
|
218
|
+
})) {
|
|
219
|
+
(0, http_response_js_1.sendJson)(res, 503, { error: 'Service Unavailable: max sessions reached' });
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (config.authMode === auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH) {
|
|
223
|
+
// ensureEndpointAuth already ran; oauth must be present for this auth mode.
|
|
224
|
+
if (!(oauth === null || oauth === void 0 ? void 0 : oauth.ok)) {
|
|
225
|
+
(0, lightdash_oauth_middleware_js_1.writeOAuthAuthFailure)(res, (0, lightdash_oauth_middleware_js_1.buildBearerRequiredFailure)(config, persona.path));
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const contextProvider = (0, bearer_context_provider_js_1.createOAuthBearerProvider)(config, {
|
|
229
|
+
accessToken: oauth.accessToken,
|
|
230
|
+
subject: oauth.user.userUuid,
|
|
231
|
+
});
|
|
232
|
+
const transport = createSessionTransport(contextProvider, sessionStore, {
|
|
233
|
+
mode: auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH,
|
|
234
|
+
tokenHash: contextProvider.getTokenHash(),
|
|
235
|
+
subject: oauth.user.userUuid,
|
|
236
|
+
organizationUuid: oauth.user.organizationUuid,
|
|
237
|
+
}, persona);
|
|
238
|
+
await (0, tool_audit_context_js_1.runWithToolAuditAuthAsync)({
|
|
239
|
+
tokenHash: contextProvider.getTokenHash(),
|
|
240
|
+
subject: oauth.user.userUuid,
|
|
241
|
+
}, () => transport.handleRequest(req, res, body));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const transport = createSessionTransport(createEnvContextProvider(config), sessionStore, {
|
|
245
|
+
mode: config.authMode,
|
|
246
|
+
}, persona);
|
|
247
|
+
await transport.handleRequest(req, res, body);
|
|
248
|
+
}
|
|
249
|
+
async function handleMcpPost(ctx, sid) {
|
|
250
|
+
const { req, res, config, persona } = ctx;
|
|
251
|
+
if (config.authMode === auth_mode_js_1.MCP_AUTH_MODE_SHARED_KEY ||
|
|
252
|
+
config.authMode === auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH) {
|
|
253
|
+
if (!(await ensureEndpointAuth(req, res, config, persona.path))) {
|
|
254
|
+
(0, http_body_js_1.drainRequestBody)(req);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const raw = await (0, http_body_js_1.readBody)(req, res, config.maxBodyBytes);
|
|
259
|
+
if (raw === undefined)
|
|
260
|
+
return;
|
|
261
|
+
let body;
|
|
262
|
+
if (raw.length > 0) {
|
|
263
|
+
try {
|
|
264
|
+
body = (0, http_body_js_1.parseJsonBody)(raw);
|
|
265
|
+
}
|
|
266
|
+
catch (_a) {
|
|
267
|
+
(0, http_response_js_1.sendJson)(res, 400, { error: 'Bad Request: invalid JSON body' });
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (sid) {
|
|
272
|
+
await handleExistingSessionPost(ctx, sid, body);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (body !== undefined && (0, http_request_utils_js_1.isInitializeMessage)(body)) {
|
|
276
|
+
await handleInitializePost(ctx, body);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
(0, http_response_js_1.sendJson)(res, 400, {
|
|
280
|
+
error: 'Bad Request: Mcp-Session-Id required for non-initialize requests',
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
async function handleMcpGetOrDelete(ctx, sid) {
|
|
284
|
+
var _a, _b;
|
|
285
|
+
const { req, res, config, sessionStore, persona } = ctx;
|
|
286
|
+
if (!sid) {
|
|
287
|
+
(0, http_response_js_1.sendJson)(res, 400, { error: 'Bad Request: Mcp-Session-Id required' });
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (config.authMode !== auth_mode_js_1.MCP_AUTH_MODE_NONE) {
|
|
291
|
+
if (!(await ensureEndpointAuth(req, res, config, persona.path)))
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const entry = sessionStore.get(sid);
|
|
295
|
+
if (!entry || entry.personaId !== persona.id) {
|
|
296
|
+
(0, http_response_js_1.sendJson)(res, 404, { error: ERROR_SESSION_NOT_FOUND });
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (!verifySessionAuth(req, res, config, persona.path, entry))
|
|
300
|
+
return;
|
|
301
|
+
sessionStore.touch(sid);
|
|
302
|
+
const auditAuth = getOAuthAuditContext(req);
|
|
303
|
+
await (0, tool_audit_context_js_1.runWithToolAuditAuthAsync)({
|
|
304
|
+
tokenHash: (_a = auditAuth.tokenHash) !== null && _a !== void 0 ? _a : entry.auth.tokenHash,
|
|
305
|
+
subject: (_b = auditAuth.subject) !== null && _b !== void 0 ? _b : entry.auth.subject,
|
|
306
|
+
}, () => entry.transport.handleRequest(req, res));
|
|
307
|
+
}
|
|
308
|
+
async function createStreamableHttpServer(config) {
|
|
309
|
+
var _a;
|
|
310
|
+
const inputConfig = config !== null && config !== void 0 ? config : (0, load_mcp_config_js_1.loadMcpHttpConfig)();
|
|
311
|
+
(0, load_mcp_config_js_1.emitMcpHttpSecurityWarnings)(inputConfig);
|
|
312
|
+
(0, audit_js_1.initAuditLog)((0, runtime_js_1.getAuditLogPath)());
|
|
313
|
+
const ephemeralStoreConfig = (0, config_js_1.resolveEphemeralStoreConfig)();
|
|
314
|
+
const sessionStore = (0, create_session_store_js_1.createSessionStore)(ephemeralStoreConfig, {
|
|
315
|
+
sessionTtlMs: inputConfig.sessionTtlMs,
|
|
316
|
+
maxSessions: inputConfig.maxSessions,
|
|
317
|
+
maxSessionsPerSubject: inputConfig.maxSessionsPerSubject,
|
|
318
|
+
});
|
|
319
|
+
let httpConfig = inputConfig;
|
|
320
|
+
const cleanupTimer = setInterval(() => {
|
|
321
|
+
sessionStore.cleanupExpired((entry, sessionId) => {
|
|
322
|
+
closeSessionEntry(entry, sessionId, 'expired');
|
|
323
|
+
});
|
|
324
|
+
}, inputConfig.sessionCleanupMs);
|
|
325
|
+
cleanupTimer.unref();
|
|
326
|
+
let oauthBroker;
|
|
327
|
+
const server = (0, node_http_1.createServer)((req, res) => {
|
|
328
|
+
handleHttpRequest(req, res, httpConfig, sessionStore, oauthBroker).catch((err) => {
|
|
329
|
+
console.error('MCP HTTP handler error:', err);
|
|
330
|
+
if (!res.headersSent) {
|
|
331
|
+
(0, http_response_js_1.sendJson)(res, 500, { error: 'Internal Server Error' });
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
await listen(server, inputConfig.port, inputConfig.host);
|
|
336
|
+
const address = server.address();
|
|
337
|
+
const port = typeof address === 'object' && address !== null ? address.port : inputConfig.port;
|
|
338
|
+
httpConfig = resolveHttpConfig(inputConfig, port);
|
|
339
|
+
const baseUrl = (_a = httpConfig.publicUrl) !== null && _a !== void 0 ? _a : `http://${resolveListenHost(httpConfig.host)}:${port}`;
|
|
340
|
+
if (httpConfig.authMode === auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH) {
|
|
341
|
+
oauthBroker = (0, routes_js_1.createOAuthBroker)(httpConfig, (0, create_oauth_broker_store_js_1.createOAuthBrokerStore)(ephemeralStoreConfig));
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
port,
|
|
345
|
+
baseUrl,
|
|
346
|
+
config: httpConfig,
|
|
347
|
+
close: () => new Promise((resolve, reject) => {
|
|
348
|
+
clearInterval(cleanupTimer);
|
|
349
|
+
sessionStore.drainAll((entry, sessionId) => {
|
|
350
|
+
closeSessionEntry(entry, sessionId, 'shutdown');
|
|
351
|
+
});
|
|
352
|
+
server.close((err) => {
|
|
353
|
+
if (err)
|
|
354
|
+
reject(err);
|
|
355
|
+
else
|
|
356
|
+
resolve();
|
|
357
|
+
});
|
|
358
|
+
}),
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function startStreamableHttpServer(config) {
|
|
362
|
+
void createStreamableHttpServer(config)
|
|
363
|
+
.then(({ baseUrl, config: httpConfig }) => {
|
|
364
|
+
const paths = (0, index_js_1.listPersonaPaths)()
|
|
365
|
+
.map((p) => `${baseUrl}${p}`)
|
|
366
|
+
.join(', ');
|
|
367
|
+
console.error(`Lightdash MCP server listening on ${paths} (auth: ${httpConfig.authMode})`);
|
|
368
|
+
if (httpConfig.authMode === auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH) {
|
|
369
|
+
console.error(`OAuth PRM: ${(0, oauth_protected_resource_js_1.getProtectedResourceMetadataUrl)(httpConfig)}`);
|
|
370
|
+
console.error(`OAuth callback (register in Lightdash): ${(0, load_mcp_config_js_1.getOAuthCallbackUrl)(httpConfig)}`);
|
|
371
|
+
}
|
|
372
|
+
})
|
|
373
|
+
.catch((err) => {
|
|
374
|
+
console.error('Failed to start MCP HTTP server:', err);
|
|
375
|
+
process.exit(1);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function requestOrigin(req) {
|
|
379
|
+
return typeof req.headers.origin === 'string' ? req.headers.origin : undefined;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Applies CORS reflect headers without blocking.
|
|
383
|
+
* When `reflectAnyOrigin` is true (OAuth AS / PRM), always echo Origin and ignore
|
|
384
|
+
* `ALLOWED_ORIGINS` so Cursor loopback (`http://localhost:8787`) can read token JSON
|
|
385
|
+
* even if persona MCP routes use a browser allowlist.
|
|
386
|
+
*/
|
|
387
|
+
function applyOptionalCorsHeaders(req, res, config, reflectAnyOrigin = false) {
|
|
388
|
+
const allowed = reflectAnyOrigin ? [] : config.allowedOrigins;
|
|
389
|
+
(0, http_response_js_1.applyResponseHeaders)(res, (0, http_response_js_1.buildCorsHeaders)(requestOrigin(req), allowed, reflectAnyOrigin));
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Validates Origin and applies CORS headers for persona MCP routes.
|
|
393
|
+
* Short-circuits OPTIONS preflight with 204; returns true when the request is fully handled.
|
|
394
|
+
*/
|
|
395
|
+
function applyOriginGuardAndCors(req, res, config) {
|
|
396
|
+
const origin = requestOrigin(req);
|
|
397
|
+
if (!(0, http_response_js_1.checkOrigin)(origin, config.allowedOrigins)) {
|
|
398
|
+
(0, http_response_js_1.sendJson)(res, 403, { error: 'Forbidden: origin not allowed' });
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
const corsHeaders = (0, http_response_js_1.buildCorsHeaders)(origin, config.allowedOrigins);
|
|
402
|
+
(0, http_response_js_1.applyResponseHeaders)(res, corsHeaders);
|
|
403
|
+
if (req.method === 'OPTIONS') {
|
|
404
|
+
res.writeHead(204, corsHeaders).end();
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Health, OAuth broker, and PRM discovery — no Origin allowlist gate.
|
|
411
|
+
* Returns true when the request was fully handled.
|
|
412
|
+
*/
|
|
413
|
+
async function handlePublicHttpPaths(req, res, config, path, oauthBroker) {
|
|
414
|
+
if (path === '/health/live' || path === '/health/ready') {
|
|
415
|
+
applyOptionalCorsHeaders(req, res, config);
|
|
416
|
+
handleHealth(path, res, config);
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
if (oauthBroker !== undefined && (0, routes_js_1.isOAuthBrokerPath)(path)) {
|
|
420
|
+
applyOptionalCorsHeaders(req, res, config, true);
|
|
421
|
+
return oauthBroker.handle(req, res, path);
|
|
422
|
+
}
|
|
423
|
+
const prmMcpPath = config.authMode === auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH
|
|
424
|
+
? (0, oauth_protected_resource_js_1.resolveProtectedResourceMcpPath)(path, config)
|
|
425
|
+
: undefined;
|
|
426
|
+
if (prmMcpPath !== undefined) {
|
|
427
|
+
applyOptionalCorsHeaders(req, res, config, true);
|
|
428
|
+
(0, http_response_js_1.sendJson)(res, 200, (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(config, prmMcpPath));
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
async function handleHttpRequest(req, res, config, sessionStore, oauthBroker) {
|
|
434
|
+
var _a, _b;
|
|
435
|
+
const path = (_b = ((_a = req.url) !== null && _a !== void 0 ? _a : '').split('?')[0]) !== null && _b !== void 0 ? _b : '';
|
|
436
|
+
if (await handlePublicHttpPaths(req, res, config, path, oauthBroker)) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
// Persona MCP routes: Origin allowlist is enforced (CSRF / browser blast-radius).
|
|
440
|
+
if (applyOriginGuardAndCors(req, res, config)) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
const persona = (0, index_js_1.getPersonaByPath)(path);
|
|
444
|
+
if (!persona) {
|
|
445
|
+
(0, http_response_js_1.sendJson)(res, 404, { error: 'Not Found' });
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const sid = getSessionId(req);
|
|
449
|
+
const pinnedProjectUuid = (0, project_pin_js_1.extractPinnedProjectFromRequest)(req);
|
|
450
|
+
await (0, project_pin_js_1.runWithProjectPinAsync)(pinnedProjectUuid, async () => {
|
|
451
|
+
if (req.method === 'POST') {
|
|
452
|
+
await handleMcpPost({ req, res, config, sessionStore, persona }, sid);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (req.method === 'GET' || req.method === 'DELETE') {
|
|
456
|
+
await handleMcpGetOrDelete({ req, res, config, sessionStore, persona }, sid);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
res.writeHead(405, { Allow: 'GET, POST, DELETE' }).end();
|
|
460
|
+
});
|
|
461
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const oauth_protected_resource_js_1 = require("../auth/resource-server/oauth-protected-resource.js");
|
|
5
|
+
const www_authenticate_js_1 = require("../auth/resource-server/www-authenticate.js");
|
|
6
|
+
const env_js_1 = require("../config/env.js");
|
|
7
|
+
const load_mcp_config_js_1 = require("../config/load-mcp-config.js");
|
|
8
|
+
const test_mcp_http_config_js_1 = require("../config/test-mcp-http-config.js");
|
|
9
|
+
const index_js_1 = require("../personas/content-reader/v1/index.js");
|
|
10
|
+
const index_js_2 = require("../personas/organization-audit/v1/index.js");
|
|
11
|
+
const index_js_3 = require("../personas/semantic-layer/v1/index.js");
|
|
12
|
+
const http_response_js_1 = require("./http-response.js");
|
|
13
|
+
const streamable_http_js_1 = require("./streamable-http.js");
|
|
14
|
+
const oauthConfig = (0, test_mcp_http_config_js_1.makeTestMcpHttpConfig)({
|
|
15
|
+
port: 0,
|
|
16
|
+
oauthClientId: 'client-id',
|
|
17
|
+
sessionTtlMs: 10000,
|
|
18
|
+
maxSessions: 1000,
|
|
19
|
+
maxSessionsPerSubject: 50,
|
|
20
|
+
validateToken: false,
|
|
21
|
+
tokenValidationCacheTtlMs: 60000,
|
|
22
|
+
});
|
|
23
|
+
const originalEnv = Object.assign({}, process.env);
|
|
24
|
+
function clearMcpEnv() {
|
|
25
|
+
for (const key of Object.keys(process.env)) {
|
|
26
|
+
if (key.startsWith('LIGHTDASH_TOOLS_MCP_') ||
|
|
27
|
+
key.startsWith('LIGHTDASH_TOOLS_OAUTH_') ||
|
|
28
|
+
key.startsWith('MCP_')) {
|
|
29
|
+
delete process.env[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
delete process.env.LIGHTDASH_URL;
|
|
33
|
+
}
|
|
34
|
+
(0, vitest_1.afterEach)(() => {
|
|
35
|
+
process.env = Object.assign({}, originalEnv);
|
|
36
|
+
vitest_1.vi.restoreAllMocks();
|
|
37
|
+
});
|
|
38
|
+
(0, vitest_1.describe)('streamable HTTP security policy', () => {
|
|
39
|
+
(0, vitest_1.beforeEach)(() => {
|
|
40
|
+
clearMcpEnv();
|
|
41
|
+
vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
42
|
+
});
|
|
43
|
+
(0, vitest_1.it)('rejects obsolete AUTH_MODE in favor of credential inference', () => {
|
|
44
|
+
process.env.NODE_ENV = 'production';
|
|
45
|
+
process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
|
|
46
|
+
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE] = 'lightdash-oauth';
|
|
47
|
+
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL] = 'https://mcp.example.com';
|
|
48
|
+
(0, vitest_1.expect)(() => (0, load_mcp_config_js_1.loadMcpHttpConfig)()).toThrow(/is removed/);
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.it)('infers production OAuth from client credentials without CORS allowlist', () => {
|
|
51
|
+
process.env.NODE_ENV = 'production';
|
|
52
|
+
process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
|
|
53
|
+
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL] = 'https://mcp.example.com';
|
|
54
|
+
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_ID] = 'id';
|
|
55
|
+
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET] = 'secret';
|
|
56
|
+
const config = (0, load_mcp_config_js_1.loadMcpHttpConfig)();
|
|
57
|
+
(0, vitest_1.expect)(config.authMode).toBe('lightdash-oauth');
|
|
58
|
+
});
|
|
59
|
+
(0, vitest_1.it)('rejects unauthenticated HTTP in production', () => {
|
|
60
|
+
process.env.NODE_ENV = 'production';
|
|
61
|
+
process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
|
|
62
|
+
(0, vitest_1.expect)(() => (0, load_mcp_config_js_1.loadMcpHttpConfig)()).toThrow(/not allowed in production/);
|
|
63
|
+
});
|
|
64
|
+
(0, vitest_1.it)('rejects browser origins when CORS allowlist is empty', () => {
|
|
65
|
+
(0, vitest_1.expect)((0, http_response_js_1.checkOrigin)('https://browser.example.com', [])).toBe(false);
|
|
66
|
+
(0, vitest_1.expect)((0, http_response_js_1.buildCorsHeaders)('https://browser.example.com', [])).toEqual({});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.describe)('streamable HTTP OAuth metadata', () => {
|
|
70
|
+
(0, vitest_1.it)('builds protected resource metadata with MCP host as authorization_servers', () => {
|
|
71
|
+
const metadata = (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(oauthConfig, index_js_3.SEMANTIC_LAYER_PERSONA_PATH);
|
|
72
|
+
(0, vitest_1.expect)(metadata.authorization_servers).toEqual(['https://mcp.example.com']);
|
|
73
|
+
(0, vitest_1.expect)(metadata.resource).toBe(`https://mcp.example.com${index_js_3.SEMANTIC_LAYER_PERSONA_PATH}`);
|
|
74
|
+
(0, vitest_1.expect)((0, oauth_protected_resource_js_1.getAuthorizationServerMetadataUrl)(metadata.authorization_servers[0])).toBe('https://mcp.example.com/.well-known/oauth-authorization-server');
|
|
75
|
+
});
|
|
76
|
+
(0, vitest_1.it)('builds organization-audit protected resource metadata', () => {
|
|
77
|
+
const metadata = (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(oauthConfig, index_js_2.ORGANIZATION_AUDIT_PERSONA_PATH);
|
|
78
|
+
(0, vitest_1.expect)(metadata.resource).toBe(`https://mcp.example.com${index_js_2.ORGANIZATION_AUDIT_PERSONA_PATH}`);
|
|
79
|
+
});
|
|
80
|
+
(0, vitest_1.it)('builds content-reader protected resource metadata', () => {
|
|
81
|
+
const metadata = (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(oauthConfig, index_js_1.CONTENT_READER_PERSONA_PATH);
|
|
82
|
+
(0, vitest_1.expect)(metadata.resource).toBe(`https://mcp.example.com${index_js_1.CONTENT_READER_PERSONA_PATH}`);
|
|
83
|
+
});
|
|
84
|
+
(0, vitest_1.it)('builds WWW-Authenticate challenges with resource_metadata for OAuth clients', () => {
|
|
85
|
+
const header = (0, www_authenticate_js_1.buildWwwAuthenticateHeader)({
|
|
86
|
+
resourceMetadataUrl: 'https://mcp.example.com/.well-known/oauth-protected-resource/semantic-layer/v1/mcp',
|
|
87
|
+
scope: 'mcp:read',
|
|
88
|
+
error: 'invalid_token',
|
|
89
|
+
});
|
|
90
|
+
(0, vitest_1.expect)(header).toContain('error="invalid_token"');
|
|
91
|
+
(0, vitest_1.expect)(header).toContain('resource_metadata=');
|
|
92
|
+
(0, vitest_1.expect)(header).toContain('scope="mcp:read"');
|
|
93
|
+
});
|
|
94
|
+
(0, vitest_1.it)('exports startStreamableHttpServer', () => {
|
|
95
|
+
(0, vitest_1.expect)(typeof streamable_http_js_1.startStreamableHttpServer).toBe('function');
|
|
96
|
+
});
|
|
97
|
+
(0, vitest_1.it)('exports createStreamableHttpServer', () => {
|
|
98
|
+
(0, vitest_1.expect)(typeof streamable_http_js_1.createStreamableHttpServer).toBe('function');
|
|
99
|
+
});
|
|
100
|
+
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash-tools/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "MCP server
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "MCP server for Lightdash semantic-layer, organization-audit, content-reader, content-developer, and content-governance personas.",
|
|
5
5
|
"keywords": [],
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/yu-iskw/lightdash-tools.git",
|
|
9
|
+
"directory": "packages/mcp"
|
|
10
|
+
},
|
|
6
11
|
"license": "Apache-2.0",
|
|
7
12
|
"author": "",
|
|
8
13
|
"main": "dist/index.js",
|
|
@@ -10,19 +15,30 @@
|
|
|
10
15
|
"bin": {
|
|
11
16
|
"lightdash-mcp": "./dist/bin.js"
|
|
12
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
13
21
|
"dependencies": {
|
|
14
|
-
"@modelcontextprotocol/
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
22
|
+
"@modelcontextprotocol/node": "2.0.0",
|
|
23
|
+
"@modelcontextprotocol/server": "2.0.0",
|
|
24
|
+
"commander": "^15.0.0",
|
|
25
|
+
"hono": "^4.12.32",
|
|
26
|
+
"redis": "^6.2.0",
|
|
27
|
+
"zod": "^4.4.3",
|
|
28
|
+
"@lightdash-tools/client": "0.8.0",
|
|
29
|
+
"@lightdash-tools/common": "0.8.0"
|
|
19
30
|
},
|
|
20
31
|
"devDependencies": {
|
|
21
|
-
"@
|
|
32
|
+
"@modelcontextprotocol/client": "2.0.0",
|
|
33
|
+
"@types/node": "^25.9.3"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
22
37
|
},
|
|
23
38
|
"scripts": {
|
|
24
|
-
"build": "tsc",
|
|
39
|
+
"build": "rm -rf dist && tsc && for p in semantic-layer organization-audit content-reader content-developer content-governance; do mkdir -p dist/personas/$p/v1/resources/playbooks && cp -R src/personas/$p/v1/resources/playbooks/. dist/personas/$p/v1/resources/playbooks/; done",
|
|
25
40
|
"start": "node dist/index.js",
|
|
26
|
-
"start:http": "node dist/http.js"
|
|
41
|
+
"start:http": "node dist/http.js",
|
|
42
|
+
"test": "pnpm --dir ../.. exec vitest run packages/mcp/src"
|
|
27
43
|
}
|
|
28
44
|
}
|
package/dist/audit.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-exports the shared audit logger from @lightdash-tools/common.
|
|
3
|
-
* The canonical implementation lives in common so the CLI can also use it.
|
|
4
|
-
*/
|
|
5
|
-
export { getSessionId, initAuditLog, logAuditEntry } from '@lightdash-tools/common';
|
|
6
|
-
export type { AuditLogEntry, AuditStatus } from '@lightdash-tools/common';
|
package/dist/config.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP server config: build Lightdash client config from environment.
|
|
3
|
-
* Uses same env vars as CLI: LIGHTDASH_URL, LIGHTDASH_API_KEY.
|
|
4
|
-
*/
|
|
5
|
-
import { LightdashClient } from '@lightdash-tools/client';
|
|
6
|
-
import type { PartialLightdashClientConfig } from '@lightdash-tools/client';
|
|
7
|
-
import type { SafetyMode } from '@lightdash-tools/common';
|
|
8
|
-
/**
|
|
9
|
-
* Gets the safety mode for dynamic enforcement.
|
|
10
|
-
*/
|
|
11
|
-
export declare function getSafetyMode(): SafetyMode;
|
|
12
|
-
/**
|
|
13
|
-
* Gets the safety mode for static tool filtering (binding).
|
|
14
|
-
*/
|
|
15
|
-
export declare function getStaticSafetyMode(): SafetyMode | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Sets the static safety mode (from CLI).
|
|
18
|
-
*/
|
|
19
|
-
export declare function setStaticSafetyMode(mode: SafetyMode): void;
|
|
20
|
-
/**
|
|
21
|
-
* Returns the effective project UUID allowlist.
|
|
22
|
-
* CLI-provided values override the environment variable.
|
|
23
|
-
* An empty array means all projects are allowed.
|
|
24
|
-
*/
|
|
25
|
-
export declare function getAllowedProjectUuids(): string[];
|
|
26
|
-
/**
|
|
27
|
-
* Sets the project UUID allowlist from the CLI (overrides LIGHTDASH_TOOLS_ALLOWED_PROJECTS).
|
|
28
|
-
*/
|
|
29
|
-
export declare function setStaticAllowedProjectUuids(uuids: string[]): void;
|
|
30
|
-
/**
|
|
31
|
-
* Returns true when dry-run mode is active.
|
|
32
|
-
* CLI flag overrides the LIGHTDASH_TOOLS_DRY_RUN environment variable.
|
|
33
|
-
*/
|
|
34
|
-
export declare function isDryRunMode(): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Enables or disables dry-run mode (from CLI).
|
|
37
|
-
*/
|
|
38
|
-
export declare function setDryRunMode(enabled: boolean): void;
|
|
39
|
-
/**
|
|
40
|
-
* Returns the audit log file path from LIGHTDASH_TOOLS_AUDIT_LOG, or undefined to use stderr.
|
|
41
|
-
*/
|
|
42
|
-
export declare function getAuditLogPath(): string | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Builds a LightdashClient from environment variables (and optional overrides).
|
|
45
|
-
* Throws if LIGHTDASH_URL or LIGHTDASH_API_KEY are missing.
|
|
46
|
-
*/
|
|
47
|
-
export declare function getClient(config?: PartialLightdashClientConfig): LightdashClient;
|