@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,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Redaction unit tests.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const redaction_js_1 = require("./redaction.js");
|
|
8
|
+
(0, vitest_1.describe)('organization-audit redaction', () => {
|
|
9
|
+
(0, vitest_1.it)('redacts email local-part', () => {
|
|
10
|
+
(0, vitest_1.expect)((0, redaction_js_1.redactEmail)('alice@example.com')).toEqual({
|
|
11
|
+
email: 'a***@example.com',
|
|
12
|
+
domain: 'example.com',
|
|
13
|
+
isExternalDomain: false,
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
(0, vitest_1.it)('marks external domains when allowlist provided', () => {
|
|
17
|
+
(0, vitest_1.expect)((0, redaction_js_1.redactEmail)('bob@evil.example', ['example.com']).isExternalDomain).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.it)('returns full email when includeEmail is true', () => {
|
|
20
|
+
(0, vitest_1.expect)((0, redaction_js_1.maybeRedactEmail)('alice@example.com', true)).toBe('alice@example.com');
|
|
21
|
+
});
|
|
22
|
+
(0, vitest_1.it)('redacts non-email destinations', () => {
|
|
23
|
+
const result = (0, redaction_js_1.redactDestination)('slack_channel', 'C0123456789');
|
|
24
|
+
(0, vitest_1.expect)(result.redactedDestination).toMatch(/^C0/);
|
|
25
|
+
(0, vitest_1.expect)(result.redactedDestination).not.toBe('C0123456789');
|
|
26
|
+
});
|
|
27
|
+
(0, vitest_1.it)('strips webhook secrets when revealDestinations is false', () => {
|
|
28
|
+
const sanitized = (0, redaction_js_1.sanitizeSchedulerTarget)({
|
|
29
|
+
type: 'ms_teams',
|
|
30
|
+
webhook: 'https://outlook.office.com/webhook/secret-token',
|
|
31
|
+
}, false);
|
|
32
|
+
(0, vitest_1.expect)(sanitized).not.toHaveProperty('webhook');
|
|
33
|
+
(0, vitest_1.expect)(String(sanitized.redactedDestination)).toContain('outlook.office.com');
|
|
34
|
+
(0, vitest_1.expect)(String(sanitized.redactedDestination)).not.toContain('secret-token');
|
|
35
|
+
});
|
|
36
|
+
(0, vitest_1.it)('does not spread raw google chat webhook URLs', () => {
|
|
37
|
+
const normalized = (0, redaction_js_1.normalizeScheduler)({
|
|
38
|
+
schedulerUuid: 's1',
|
|
39
|
+
targets: [
|
|
40
|
+
{
|
|
41
|
+
type: 'google_chat',
|
|
42
|
+
googleChatWebhook: 'https://chat.googleapis.com/v1/spaces/AAA/messages?key=secret',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
}, false);
|
|
46
|
+
const target = normalized.targets[0];
|
|
47
|
+
(0, vitest_1.expect)(target).not.toHaveProperty('googleChatWebhook');
|
|
48
|
+
(0, vitest_1.expect)(JSON.stringify(normalized)).not.toContain('secret');
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.it)('strips latestRun PII and opaque details', () => {
|
|
51
|
+
const normalized = (0, redaction_js_1.normalizeScheduler)({
|
|
52
|
+
schedulerUuid: 's1',
|
|
53
|
+
targets: [],
|
|
54
|
+
latestRun: {
|
|
55
|
+
runId: 'r1',
|
|
56
|
+
createdByUserName: 'Alice Admin',
|
|
57
|
+
createdByUserUuid: 'u1',
|
|
58
|
+
details: { recipient: 'secret@evil.example' },
|
|
59
|
+
runStatus: 'completed',
|
|
60
|
+
},
|
|
61
|
+
}, false);
|
|
62
|
+
const latestRun = normalized.latestRun;
|
|
63
|
+
(0, vitest_1.expect)(latestRun).not.toHaveProperty('createdByUserName');
|
|
64
|
+
(0, vitest_1.expect)(latestRun).not.toHaveProperty('details');
|
|
65
|
+
(0, vitest_1.expect)(latestRun.createdByUserUuid).toBe('u1');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.describe)('toProjectSummary', () => {
|
|
69
|
+
(0, vitest_1.it)('omits warehouse, dbt, and contact override fields', () => {
|
|
70
|
+
const summary = (0, redaction_js_1.toProjectSummary)({
|
|
71
|
+
projectUuid: 'p1',
|
|
72
|
+
name: 'Prod',
|
|
73
|
+
type: 'DEFAULT',
|
|
74
|
+
organizationUuid: 'o1',
|
|
75
|
+
createdByUserUuid: 'u1',
|
|
76
|
+
createdByUserName: 'Alice',
|
|
77
|
+
warehouseType: 'bigquery',
|
|
78
|
+
warehouseConnection: {
|
|
79
|
+
type: 'bigquery',
|
|
80
|
+
password: 'warehouse-secret',
|
|
81
|
+
},
|
|
82
|
+
dbtConnection: {
|
|
83
|
+
type: 'github',
|
|
84
|
+
personal_access_token: 'ghp_secret_token',
|
|
85
|
+
},
|
|
86
|
+
schedulerFailureContactOverride: 'ops@example.com',
|
|
87
|
+
});
|
|
88
|
+
(0, vitest_1.expect)(summary).toEqual({
|
|
89
|
+
projectUuid: 'p1',
|
|
90
|
+
name: 'Prod',
|
|
91
|
+
type: 'DEFAULT',
|
|
92
|
+
organizationUuid: 'o1',
|
|
93
|
+
createdByUserUuid: 'u1',
|
|
94
|
+
warehouseType: 'bigquery',
|
|
95
|
+
});
|
|
96
|
+
(0, vitest_1.expect)(summary).not.toHaveProperty('warehouseConnection');
|
|
97
|
+
(0, vitest_1.expect)(summary).not.toHaveProperty('dbtConnection');
|
|
98
|
+
(0, vitest_1.expect)(summary).not.toHaveProperty('schedulerFailureContactOverride');
|
|
99
|
+
(0, vitest_1.expect)(summary).not.toHaveProperty('createdByUserName');
|
|
100
|
+
(0, vitest_1.expect)(JSON.stringify(summary)).not.toContain('secret');
|
|
101
|
+
(0, vitest_1.expect)(JSON.stringify(summary)).not.toContain('ops@example.com');
|
|
102
|
+
});
|
|
103
|
+
(0, vitest_1.it)('falls back to warehouseConnection.type when warehouseType is absent', () => {
|
|
104
|
+
const summary = (0, redaction_js_1.toProjectSummary)({
|
|
105
|
+
projectUuid: 'p2',
|
|
106
|
+
name: 'Pinned',
|
|
107
|
+
type: 'DEFAULT',
|
|
108
|
+
warehouseConnection: { type: 'snowflake', password: 'nope' },
|
|
109
|
+
dbtConnection: { type: 'none' },
|
|
110
|
+
});
|
|
111
|
+
(0, vitest_1.expect)(summary.warehouseType).toBe('snowflake');
|
|
112
|
+
(0, vitest_1.expect)(JSON.stringify(summary)).not.toContain('nope');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
(0, vitest_1.describe)('toProjectMemberAccessSummary', () => {
|
|
116
|
+
(0, vitest_1.it)('redacts email by default and keeps names', () => {
|
|
117
|
+
const row = (0, redaction_js_1.toProjectMemberAccessSummary)({
|
|
118
|
+
userUuid: 'u1',
|
|
119
|
+
projectUuid: 'p1',
|
|
120
|
+
firstName: 'Ada',
|
|
121
|
+
lastName: 'Lovelace',
|
|
122
|
+
email: 'ada@example.com',
|
|
123
|
+
role: 'editor',
|
|
124
|
+
roleUuid: 'r1',
|
|
125
|
+
}, false);
|
|
126
|
+
(0, vitest_1.expect)(row.firstName).toBe('Ada');
|
|
127
|
+
(0, vitest_1.expect)(row.lastName).toBe('Lovelace');
|
|
128
|
+
(0, vitest_1.expect)(row.email).toEqual({
|
|
129
|
+
email: 'a***@example.com',
|
|
130
|
+
domain: 'example.com',
|
|
131
|
+
isExternalDomain: false,
|
|
132
|
+
});
|
|
133
|
+
(0, vitest_1.expect)(JSON.stringify(row)).not.toContain('ada@example.com');
|
|
134
|
+
});
|
|
135
|
+
(0, vitest_1.it)('returns full email when includeEmail is true', () => {
|
|
136
|
+
const row = (0, redaction_js_1.toProjectMemberAccessSummary)({
|
|
137
|
+
userUuid: 'u1',
|
|
138
|
+
projectUuid: 'p1',
|
|
139
|
+
firstName: 'Ada',
|
|
140
|
+
lastName: 'Lovelace',
|
|
141
|
+
email: 'ada@example.com',
|
|
142
|
+
role: 'viewer',
|
|
143
|
+
}, true);
|
|
144
|
+
(0, vitest_1.expect)(row.email).toBe('ada@example.com');
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
(0, vitest_1.describe)('toGroupSummary', () => {
|
|
148
|
+
(0, vitest_1.it)('allowlists group fields and redacts member emails', () => {
|
|
149
|
+
const summary = (0, redaction_js_1.toGroupSummary)({
|
|
150
|
+
uuid: 'g1',
|
|
151
|
+
name: 'Admins',
|
|
152
|
+
organizationUuid: 'o1',
|
|
153
|
+
createdAt: '2026-01-01',
|
|
154
|
+
updatedAt: '2026-01-02',
|
|
155
|
+
createdByUserUuid: 'u0',
|
|
156
|
+
updatedByUserUuid: 'u9',
|
|
157
|
+
memberUuids: ['u1'],
|
|
158
|
+
members: [
|
|
159
|
+
{
|
|
160
|
+
userUuid: 'u1',
|
|
161
|
+
firstName: 'Ada',
|
|
162
|
+
lastName: 'Lovelace',
|
|
163
|
+
email: 'ada@example.com',
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
unexpectedSecret: 'should-drop',
|
|
167
|
+
}, false, ['example.com']);
|
|
168
|
+
(0, vitest_1.expect)(summary).toEqual({
|
|
169
|
+
uuid: 'g1',
|
|
170
|
+
name: 'Admins',
|
|
171
|
+
organizationUuid: 'o1',
|
|
172
|
+
createdAt: '2026-01-01',
|
|
173
|
+
updatedAt: '2026-01-02',
|
|
174
|
+
createdByUserUuid: 'u0',
|
|
175
|
+
memberUuids: ['u1'],
|
|
176
|
+
members: [
|
|
177
|
+
{
|
|
178
|
+
userUuid: 'u1',
|
|
179
|
+
firstName: 'Ada',
|
|
180
|
+
lastName: 'Lovelace',
|
|
181
|
+
email: {
|
|
182
|
+
email: 'a***@example.com',
|
|
183
|
+
domain: 'example.com',
|
|
184
|
+
isExternalDomain: false,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
(0, vitest_1.expect)(summary).not.toHaveProperty('updatedByUserUuid');
|
|
190
|
+
(0, vitest_1.expect)(summary).not.toHaveProperty('unexpectedSecret');
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
(0, vitest_1.describe)('toOrgMemberSummary', () => {
|
|
194
|
+
(0, vitest_1.it)('redacts email and drops avatar fields', () => {
|
|
195
|
+
const row = (0, redaction_js_1.toOrgMemberSummary)({
|
|
196
|
+
userUuid: 'u1',
|
|
197
|
+
organizationUuid: 'o1',
|
|
198
|
+
firstName: 'Ada',
|
|
199
|
+
lastName: 'Lovelace',
|
|
200
|
+
email: 'ada@evil.example',
|
|
201
|
+
isActive: true,
|
|
202
|
+
isInviteExpired: false,
|
|
203
|
+
role: 'admin',
|
|
204
|
+
roleUuid: 'r1',
|
|
205
|
+
avatarUrl: 'https://example.com/a.png',
|
|
206
|
+
avatarGradient: 'g',
|
|
207
|
+
}, false, ['example.com']);
|
|
208
|
+
(0, vitest_1.expect)(row.email).toEqual({
|
|
209
|
+
email: 'a***@evil.example',
|
|
210
|
+
domain: 'evil.example',
|
|
211
|
+
isExternalDomain: true,
|
|
212
|
+
});
|
|
213
|
+
(0, vitest_1.expect)(row).not.toHaveProperty('avatarUrl');
|
|
214
|
+
(0, vitest_1.expect)(JSON.stringify(row)).not.toContain('ada@evil.example');
|
|
215
|
+
});
|
|
216
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared registration helper for organization-audit tools.
|
|
3
|
+
*/
|
|
4
|
+
import type { ToolHandler, ToolOptions } from '../shared.js';
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
|
+
/** Register a GET read-only org-audit tool after safety asserts. */
|
|
7
|
+
export declare function registerOrgAuditTool(server: McpServer, shortName: string, options: Omit<ToolOptions, 'annotations'> & {
|
|
8
|
+
annotations?: ToolOptions['annotations'];
|
|
9
|
+
}, handler: ToolHandler): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared registration helper for organization-audit tools.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerOrgAuditTool = registerOrgAuditTool;
|
|
7
|
+
const common_1 = require("@lightdash-tools/common");
|
|
8
|
+
const shared_js_1 = require("../shared.js");
|
|
9
|
+
const assert_safe_js_1 = require("./assert-safe.js");
|
|
10
|
+
/** Register a GET read-only org-audit tool after safety asserts. */
|
|
11
|
+
function registerOrgAuditTool(server, shortName, options, handler) {
|
|
12
|
+
var _a;
|
|
13
|
+
const annotations = (_a = options.annotations) !== null && _a !== void 0 ? _a : common_1.READ_ONLY_DEFAULT;
|
|
14
|
+
(0, assert_safe_js_1.assertOrganizationAuditToolSafe)({
|
|
15
|
+
shortName,
|
|
16
|
+
annotations,
|
|
17
|
+
httpMethod: 'GET',
|
|
18
|
+
});
|
|
19
|
+
(0, shared_js_1.registerToolSafe)(server, shortName, Object.assign(Object.assign({}, options), { annotations }), handler);
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const PROJECT_UUID_DESC = "Project UUID";
|
|
3
|
+
export declare const projectUuidField: () => z.ZodString;
|
|
4
|
+
/** OpenAPI UuidOrSlug field (dashboard/chart identifiers). */
|
|
5
|
+
export declare const uuidOrSlugField: (description?: string) => z.ZodString;
|
|
6
|
+
/** Opt-in full email addresses in MCP responses (default redacted). */
|
|
7
|
+
export declare const includeEmailField: () => z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
/** Domains treated as internal when classifying redacted emails. */
|
|
9
|
+
export declare const allowedEmailDomainsField: () => z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allowedEmailDomainsField = exports.includeEmailField = exports.uuidOrSlugField = exports.projectUuidField = exports.PROJECT_UUID_DESC = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.PROJECT_UUID_DESC = 'Project UUID';
|
|
6
|
+
const projectUuidField = () => zod_1.z.string().describe(exports.PROJECT_UUID_DESC);
|
|
7
|
+
exports.projectUuidField = projectUuidField;
|
|
8
|
+
/** OpenAPI UuidOrSlug field (dashboard/chart identifiers). */
|
|
9
|
+
const uuidOrSlugField = (description = 'UUID or slug') => zod_1.z.string().describe(description);
|
|
10
|
+
exports.uuidOrSlugField = uuidOrSlugField;
|
|
11
|
+
/** Opt-in full email addresses in MCP responses (default redacted). */
|
|
12
|
+
const includeEmailField = () => zod_1.z.boolean().optional().describe('Return full emails when true (default false)');
|
|
13
|
+
exports.includeEmailField = includeEmailField;
|
|
14
|
+
/** Domains treated as internal when classifying redacted emails. */
|
|
15
|
+
const allowedEmailDomainsField = () => zod_1.z
|
|
16
|
+
.array(zod_1.z.string())
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Domains treated as internal when classifying redacted emails');
|
|
19
|
+
exports.allowedEmailDomainsField = allowedEmailDomainsField;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic JSON stringify for digests and diffs (persona-neutral).
|
|
3
|
+
*/
|
|
4
|
+
/** True for plain objects (not null, not arrays). */
|
|
5
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
6
|
+
/** Stable JSON stringify (sorted object keys); structurally-equal values serialize identically. */
|
|
7
|
+
export declare function stableStringify(value: unknown): string;
|
|
8
|
+
/** SHA-256 hex digest of `stableStringify(value)` for precondition / preview hashes. */
|
|
9
|
+
export declare function hashStableValue(value: unknown): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Deterministic JSON stringify for digests and diffs (persona-neutral).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isRecord = isRecord;
|
|
7
|
+
exports.stableStringify = stableStringify;
|
|
8
|
+
exports.hashStableValue = hashStableValue;
|
|
9
|
+
const node_crypto_1 = require("node:crypto");
|
|
10
|
+
/** True for plain objects (not null, not arrays). */
|
|
11
|
+
function isRecord(value) {
|
|
12
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function sortKeysDeep(value) {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
return value.map(sortKeysDeep);
|
|
17
|
+
}
|
|
18
|
+
if (isRecord(value)) {
|
|
19
|
+
const sorted = {};
|
|
20
|
+
for (const key of Object.keys(value).sort()) {
|
|
21
|
+
// eslint-disable-next-line security/detect-object-injection -- key comes from Object.keys of the same record
|
|
22
|
+
sorted[key] = sortKeysDeep(value[key]);
|
|
23
|
+
}
|
|
24
|
+
return sorted;
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
/** Stable JSON stringify (sorted object keys); structurally-equal values serialize identically. */
|
|
29
|
+
function stableStringify(value) {
|
|
30
|
+
return JSON.stringify(sortKeysDeep(value));
|
|
31
|
+
}
|
|
32
|
+
/** SHA-256 hex digest of `stableStringify(value)` for precondition / preview hashes. */
|
|
33
|
+
function hashStableValue(value) {
|
|
34
|
+
return (0, node_crypto_1.createHash)('sha256').update(stableStringify(value)).digest('hex');
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session organization binding for organization-audit tools.
|
|
3
|
+
*/
|
|
4
|
+
import type { LightdashClient } from '@lightdash-tools/client';
|
|
5
|
+
export type SessionOrganization = {
|
|
6
|
+
organizationUuid: string;
|
|
7
|
+
organizationName?: string;
|
|
8
|
+
currentUserUuid: string;
|
|
9
|
+
currentUserOrganizationRole?: string;
|
|
10
|
+
currentUserRoleUuid?: string;
|
|
11
|
+
auditVisibility: 'organization_admin' | 'partial' | 'unknown';
|
|
12
|
+
};
|
|
13
|
+
/** Resolve authenticated org/user for the current session. */
|
|
14
|
+
export declare function resolveSessionOrganization(client: LightdashClient): Promise<SessionOrganization>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Session organization binding for organization-audit tools.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveSessionOrganization = resolveSessionOrganization;
|
|
7
|
+
/** Resolve authenticated org/user for the current session. */
|
|
8
|
+
async function resolveSessionOrganization(client) {
|
|
9
|
+
var _a;
|
|
10
|
+
const user = await client.v1.users.getAuthenticatedUser();
|
|
11
|
+
const organizationUuid = user.organizationUuid;
|
|
12
|
+
if (!organizationUuid) {
|
|
13
|
+
throw new Error('Authenticated user has no organizationUuid');
|
|
14
|
+
}
|
|
15
|
+
const role = user.role;
|
|
16
|
+
let auditVisibility = 'unknown';
|
|
17
|
+
if (role === 'admin') {
|
|
18
|
+
auditVisibility = 'organization_admin';
|
|
19
|
+
}
|
|
20
|
+
else if (role) {
|
|
21
|
+
auditVisibility = 'partial';
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
organizationUuid,
|
|
25
|
+
organizationName: user.organizationName,
|
|
26
|
+
currentUserUuid: user.userUuid,
|
|
27
|
+
currentUserOrganizationRole: role,
|
|
28
|
+
currentUserRoleUuid: (_a = user.roleUuid) !== null && _a !== void 0 ? _a : undefined,
|
|
29
|
+
auditVisibility,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Persona safety invariant: all org-audit tools register as read-only GET.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const common_1 = require("@lightdash-tools/common");
|
|
7
|
+
const vitest_1 = require("vitest");
|
|
8
|
+
const index_js_1 = require("../../personas/organization-audit/v1/index.js");
|
|
9
|
+
const registry_js_1 = require("../registry.js");
|
|
10
|
+
const shared_js_1 = require("../shared.js");
|
|
11
|
+
(0, vitest_1.describe)('organization-audit safety invariants', () => {
|
|
12
|
+
(0, vitest_1.it)('registers only readOnlyHint tools for the allowlist', () => {
|
|
13
|
+
const annotationsByName = new Map();
|
|
14
|
+
const mockServer = {
|
|
15
|
+
registerTool: vitest_1.vi.fn((name, options) => {
|
|
16
|
+
annotationsByName.set(name, options.annotations);
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
const mockCtx = { getContext: async () => ({ lightdashClient: {} }) };
|
|
20
|
+
(0, registry_js_1.registerToolsByIds)(mockServer, mockCtx, index_js_1.ORGANIZATION_AUDIT_TOOL_IDS);
|
|
21
|
+
(0, vitest_1.expect)(annotationsByName.size).toBe(index_js_1.ORGANIZATION_AUDIT_TOOL_IDS.length);
|
|
22
|
+
for (const id of index_js_1.ORGANIZATION_AUDIT_TOOL_IDS) {
|
|
23
|
+
const annotations = annotationsByName.get(`${shared_js_1.TOOL_PREFIX}${id}`);
|
|
24
|
+
(0, vitest_1.expect)(annotations === null || annotations === void 0 ? void 0 : annotations.readOnlyHint).toBe(true);
|
|
25
|
+
(0, vitest_1.expect)(annotations).toMatchObject(common_1.READ_ONLY_DEFAULT);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization inventory primitive tools.
|
|
3
|
+
*/
|
|
4
|
+
import type { McpContextProvider } from '../../server/request-context.js';
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
|
+
export declare function registerGetOrgProfile(server: McpServer, contextProvider: McpContextProvider): void;
|
|
7
|
+
export declare function registerListOrgMembers(server: McpServer, contextProvider: McpContextProvider): void;
|
|
8
|
+
export declare function registerGetOrgMember(server: McpServer, contextProvider: McpContextProvider): void;
|
|
9
|
+
export declare function registerListOrgGroups(server: McpServer, contextProvider: McpContextProvider): void;
|
|
10
|
+
export declare function registerListOrgProjects(server: McpServer, contextProvider: McpContextProvider): void;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Organization inventory primitive tools.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerGetOrgProfile = registerGetOrgProfile;
|
|
7
|
+
exports.registerListOrgMembers = registerListOrgMembers;
|
|
8
|
+
exports.registerGetOrgMember = registerGetOrgMember;
|
|
9
|
+
exports.registerListOrgGroups = registerListOrgGroups;
|
|
10
|
+
exports.registerListOrgProjects = registerListOrgProjects;
|
|
11
|
+
const zod_1 = require("zod");
|
|
12
|
+
const project_pin_js_1 = require("../../governance/project-pin.js");
|
|
13
|
+
const contracts_js_1 = require("../lib/contracts.js");
|
|
14
|
+
const redaction_js_1 = require("../lib/redaction.js");
|
|
15
|
+
const register_org_audit_js_1 = require("../lib/register-org-audit.js");
|
|
16
|
+
const schema_fields_js_1 = require("../lib/schema-fields.js");
|
|
17
|
+
const shared_js_1 = require("../shared.js");
|
|
18
|
+
const binding_js_1 = require("./binding.js");
|
|
19
|
+
function registerGetOrgProfile(server, contextProvider) {
|
|
20
|
+
(0, register_org_audit_js_1.registerOrgAuditTool)(server, 'get_org_profile', {
|
|
21
|
+
title: 'Get organization profile',
|
|
22
|
+
description: 'Resolve the authenticated organization identity, caller role, and audit visibility',
|
|
23
|
+
inputSchema: {},
|
|
24
|
+
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async () => {
|
|
25
|
+
var _a;
|
|
26
|
+
const session = await (0, binding_js_1.resolveSessionOrganization)(c);
|
|
27
|
+
const org = await c.v1.organizations.getCurrentOrganization();
|
|
28
|
+
return (0, shared_js_1.jsonToolResult)({
|
|
29
|
+
organizationUuid: session.organizationUuid,
|
|
30
|
+
name: (_a = org.name) !== null && _a !== void 0 ? _a : session.organizationName,
|
|
31
|
+
currentUserUuid: session.currentUserUuid,
|
|
32
|
+
currentUserOrganizationRole: session.currentUserOrganizationRole,
|
|
33
|
+
currentUserRoleUuid: session.currentUserRoleUuid,
|
|
34
|
+
auditVisibility: session.auditVisibility,
|
|
35
|
+
capabilities: [
|
|
36
|
+
'members',
|
|
37
|
+
'groups',
|
|
38
|
+
'projects',
|
|
39
|
+
'roles',
|
|
40
|
+
'content',
|
|
41
|
+
'validation',
|
|
42
|
+
'user_activity',
|
|
43
|
+
'schedulers',
|
|
44
|
+
],
|
|
45
|
+
coverage: (0, contracts_js_1.emptyCoverage)(session.organizationUuid, (0, project_pin_js_1.getPinnedProjectUuid)()),
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
function registerListOrgMembers(server, contextProvider) {
|
|
50
|
+
(0, register_org_audit_js_1.registerOrgAuditTool)(server, 'list_org_members', {
|
|
51
|
+
title: 'List organization members',
|
|
52
|
+
description: 'List organization members with optional search and email redaction',
|
|
53
|
+
inputSchema: {
|
|
54
|
+
search: zod_1.z.string().optional().describe('Search query'),
|
|
55
|
+
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
56
|
+
includeGroups: zod_1.z.boolean().optional(),
|
|
57
|
+
includeEmail: (0, schema_fields_js_1.includeEmailField)(),
|
|
58
|
+
allowedEmailDomains: (0, schema_fields_js_1.allowedEmailDomainsField)(),
|
|
59
|
+
page: zod_1.z.number().int().positive().optional(),
|
|
60
|
+
pageSize: zod_1.z.number().int().positive().optional(),
|
|
61
|
+
},
|
|
62
|
+
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
|
|
63
|
+
var _a, _b, _c, _d, _e, _f;
|
|
64
|
+
const session = await (0, binding_js_1.resolveSessionOrganization)(c);
|
|
65
|
+
const includeEmail = args.includeEmail === true;
|
|
66
|
+
const result = await c.v1.users.listMembers({
|
|
67
|
+
searchQuery: args.search,
|
|
68
|
+
projectUuid: args.projectUuid,
|
|
69
|
+
includeGroups: args.includeGroups ? 10 : undefined,
|
|
70
|
+
page: args.page,
|
|
71
|
+
pageSize: args.pageSize,
|
|
72
|
+
});
|
|
73
|
+
const data = ((_a = result.data) !== null && _a !== void 0 ? _a : []).map((m) => (0, redaction_js_1.toOrgMemberSummary)(m, includeEmail, args.allowedEmailDomains));
|
|
74
|
+
const complete = (0, contracts_js_1.isPageComplete)(data.length, (_b = result.pagination) === null || _b === void 0 ? void 0 : _b.totalResults, (_c = result.pagination) === null || _c === void 0 ? void 0 : _c.totalPageCount, (_d = args.page) !== null && _d !== void 0 ? _d : (_e = result.pagination) === null || _e === void 0 ? void 0 : _e.page);
|
|
75
|
+
return (0, shared_js_1.jsonToolResult)({
|
|
76
|
+
data,
|
|
77
|
+
pagination: {
|
|
78
|
+
returned: data.length,
|
|
79
|
+
totalResults: (_f = result.pagination) === null || _f === void 0 ? void 0 : _f.totalResults,
|
|
80
|
+
complete,
|
|
81
|
+
},
|
|
82
|
+
coverage: Object.assign(Object.assign({}, (0, contracts_js_1.emptyCoverage)(session.organizationUuid, (0, project_pin_js_1.getPinnedProjectUuid)())), { complete, apiResolutions: [
|
|
83
|
+
{
|
|
84
|
+
capability: 'organization_members',
|
|
85
|
+
selectedVersion: 'v1',
|
|
86
|
+
method: 'GET',
|
|
87
|
+
pathTemplate: '/api/v1/org/users',
|
|
88
|
+
reason: 'v2_unavailable',
|
|
89
|
+
},
|
|
90
|
+
] }),
|
|
91
|
+
warnings: (0, redaction_js_1.emailRedactionWarnings)(includeEmail),
|
|
92
|
+
});
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
function registerGetOrgMember(server, contextProvider) {
|
|
96
|
+
(0, register_org_audit_js_1.registerOrgAuditTool)(server, 'get_org_member', {
|
|
97
|
+
title: 'Get organization member',
|
|
98
|
+
description: 'Get one organization member by UUID',
|
|
99
|
+
inputSchema: {
|
|
100
|
+
userUuid: zod_1.z.string().describe('User UUID'),
|
|
101
|
+
includeEmail: (0, schema_fields_js_1.includeEmailField)(),
|
|
102
|
+
allowedEmailDomains: (0, schema_fields_js_1.allowedEmailDomainsField)(),
|
|
103
|
+
},
|
|
104
|
+
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
|
|
105
|
+
const session = await (0, binding_js_1.resolveSessionOrganization)(c);
|
|
106
|
+
const includeEmail = args.includeEmail === true;
|
|
107
|
+
const m = await c.v1.users.getMemberByUuid(args.userUuid);
|
|
108
|
+
return (0, shared_js_1.jsonToolResult)(Object.assign(Object.assign({}, (0, redaction_js_1.toOrgMemberSummary)(m, includeEmail, args.allowedEmailDomains)), { coverage: (0, contracts_js_1.emptyCoverage)(session.organizationUuid, (0, project_pin_js_1.getPinnedProjectUuid)()), warnings: (0, redaction_js_1.emailRedactionWarnings)(includeEmail) }));
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
function registerListOrgGroups(server, contextProvider) {
|
|
112
|
+
(0, register_org_audit_js_1.registerOrgAuditTool)(server, 'list_org_groups', {
|
|
113
|
+
title: 'List organization groups',
|
|
114
|
+
description: 'List organization groups with optional bounded member inclusion',
|
|
115
|
+
inputSchema: {
|
|
116
|
+
search: zod_1.z.string().optional(),
|
|
117
|
+
includeMembers: zod_1.z.number().int().min(0).max(100).optional(),
|
|
118
|
+
includeEmail: (0, schema_fields_js_1.includeEmailField)(),
|
|
119
|
+
allowedEmailDomains: (0, schema_fields_js_1.allowedEmailDomainsField)(),
|
|
120
|
+
page: zod_1.z.number().int().positive().optional(),
|
|
121
|
+
pageSize: zod_1.z.number().int().positive().optional(),
|
|
122
|
+
},
|
|
123
|
+
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
|
|
124
|
+
var _a, _b, _c, _d, _e, _f;
|
|
125
|
+
const session = await (0, binding_js_1.resolveSessionOrganization)(c);
|
|
126
|
+
const includeEmail = args.includeEmail === true;
|
|
127
|
+
const result = await c.v1.groups.listGroups({
|
|
128
|
+
searchQuery: args.search,
|
|
129
|
+
includeMembers: args.includeMembers,
|
|
130
|
+
page: args.page,
|
|
131
|
+
pageSize: args.pageSize,
|
|
132
|
+
});
|
|
133
|
+
const raw = (_a = result.data) !== null && _a !== void 0 ? _a : [];
|
|
134
|
+
const data = raw.map((g) => (0, redaction_js_1.toGroupSummary)(g, includeEmail, args.allowedEmailDomains));
|
|
135
|
+
const complete = (0, contracts_js_1.isPageComplete)(data.length, (_b = result.pagination) === null || _b === void 0 ? void 0 : _b.totalResults, (_c = result.pagination) === null || _c === void 0 ? void 0 : _c.totalPageCount, (_d = args.page) !== null && _d !== void 0 ? _d : (_e = result.pagination) === null || _e === void 0 ? void 0 : _e.page);
|
|
136
|
+
return (0, shared_js_1.jsonToolResult)({
|
|
137
|
+
data,
|
|
138
|
+
pagination: {
|
|
139
|
+
returned: data.length,
|
|
140
|
+
totalResults: (_f = result.pagination) === null || _f === void 0 ? void 0 : _f.totalResults,
|
|
141
|
+
complete,
|
|
142
|
+
},
|
|
143
|
+
coverage: Object.assign(Object.assign({}, (0, contracts_js_1.emptyCoverage)(session.organizationUuid, (0, project_pin_js_1.getPinnedProjectUuid)())), { complete, apiResolutions: [
|
|
144
|
+
{
|
|
145
|
+
capability: 'organization_groups',
|
|
146
|
+
selectedVersion: 'v1',
|
|
147
|
+
method: 'GET',
|
|
148
|
+
pathTemplate: '/api/v1/org/groups',
|
|
149
|
+
reason: 'v2_unavailable',
|
|
150
|
+
},
|
|
151
|
+
] }),
|
|
152
|
+
warnings: args.includeMembers ? (0, redaction_js_1.emailRedactionWarnings)(includeEmail) : [],
|
|
153
|
+
});
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
function registerListOrgProjects(server, contextProvider) {
|
|
157
|
+
(0, register_org_audit_js_1.registerOrgAuditTool)(server, 'list_org_projects', {
|
|
158
|
+
title: 'List organization projects',
|
|
159
|
+
description: 'Inventory organization projects (warehouse type only; no credentials)',
|
|
160
|
+
inputSchema: {
|
|
161
|
+
includePreviewProjects: zod_1.z.boolean().optional(),
|
|
162
|
+
},
|
|
163
|
+
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
|
|
164
|
+
const session = await (0, binding_js_1.resolveSessionOrganization)(c);
|
|
165
|
+
const pinned = (0, project_pin_js_1.getPinnedProjectUuid)();
|
|
166
|
+
let projects = await c.v1.projects.listProjects();
|
|
167
|
+
if (pinned) {
|
|
168
|
+
projects = projects.filter((p) => p.projectUuid === pinned);
|
|
169
|
+
}
|
|
170
|
+
if (!args.includePreviewProjects) {
|
|
171
|
+
projects = projects.filter((p) => p.type !== 'PREVIEW');
|
|
172
|
+
}
|
|
173
|
+
const data = projects.map((p) => (0, redaction_js_1.toProjectSummary)(p));
|
|
174
|
+
return (0, shared_js_1.jsonToolResult)({
|
|
175
|
+
data,
|
|
176
|
+
pagination: { returned: data.length, complete: true },
|
|
177
|
+
coverage: Object.assign(Object.assign({}, (0, contracts_js_1.emptyCoverage)(session.organizationUuid, pinned)), { projectUuids: data.map((p) => p.projectUuid), apiResolutions: [
|
|
178
|
+
{
|
|
179
|
+
capability: 'organization_projects',
|
|
180
|
+
selectedVersion: 'v1',
|
|
181
|
+
method: 'GET',
|
|
182
|
+
pathTemplate: '/api/v1/org/projects',
|
|
183
|
+
reason: 'v2_unavailable',
|
|
184
|
+
},
|
|
185
|
+
] }),
|
|
186
|
+
warnings: [redaction_js_1.CREDENTIALS_OMITTED_WARNING],
|
|
187
|
+
});
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Roles and project access primitive tools.
|
|
3
|
+
*/
|
|
4
|
+
import type { McpContextProvider } from '../../server/request-context.js';
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
|
+
export declare function registerListOrgRoleAssignments(server: McpServer, contextProvider: McpContextProvider): void;
|
|
7
|
+
export declare function registerListCustomRoles(server: McpServer, contextProvider: McpContextProvider): void;
|
|
8
|
+
export declare function registerGetCustomRole(server: McpServer, contextProvider: McpContextProvider): void;
|
|
9
|
+
export declare function registerListProjectRoles(server: McpServer, contextProvider: McpContextProvider): void;
|
|
10
|
+
export declare function registerListProjectDirectAccess(server: McpServer, contextProvider: McpContextProvider): void;
|