@lightdash-tools/mcp 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +205 -58
- package/dist/audit/audit.d.ts +5 -0
- package/dist/{audit.js → audit/audit.js} +1 -2
- package/dist/audit/tool-audit-context.d.ts +6 -0
- package/dist/audit/tool-audit-context.js +12 -0
- package/dist/audit/tool-audit-context.test.d.ts +1 -0
- package/dist/audit/tool-audit-context.test.js +19 -0
- package/dist/auth/auth-mode.d.ts +4 -0
- package/dist/auth/auth-mode.js +6 -0
- package/dist/auth/bearer.d.ts +3 -0
- package/dist/auth/bearer.js +13 -0
- package/dist/auth/lightdash-oauth-upstream-contract.d.ts +22 -0
- package/dist/auth/lightdash-oauth-upstream-contract.js +36 -0
- package/dist/auth/lightdash-oauth-upstream-contract.test.d.ts +1 -0
- package/dist/auth/lightdash-oauth-upstream-contract.test.js +56 -0
- package/dist/auth/oauth-broker/as-metadata.d.ts +14 -0
- package/dist/auth/oauth-broker/as-metadata.js +20 -0
- package/dist/auth/oauth-broker/lightdash-token.d.ts +20 -0
- package/dist/auth/oauth-broker/lightdash-token.js +76 -0
- package/dist/auth/oauth-broker/pending-store.d.ts +127 -0
- package/dist/auth/oauth-broker/pending-store.js +151 -0
- package/dist/auth/oauth-broker/pending-store.test.d.ts +6 -0
- package/dist/auth/oauth-broker/pending-store.test.js +146 -0
- package/dist/auth/oauth-broker/pkce.d.ts +2 -0
- package/dist/auth/oauth-broker/pkce.js +17 -0
- package/dist/auth/oauth-broker/routes.d.ts +13 -0
- package/dist/auth/oauth-broker/routes.js +452 -0
- package/dist/auth/oauth-broker/routes.test.d.ts +1 -0
- package/dist/auth/oauth-broker/routes.test.js +242 -0
- package/dist/auth/providers/bearer-context-provider.d.ts +24 -0
- package/dist/auth/providers/bearer-context-provider.js +52 -0
- package/dist/auth/providers/env-context-provider.d.ts +13 -0
- package/dist/auth/providers/env-context-provider.js +19 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +23 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +115 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.test.d.ts +1 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +202 -0
- package/dist/auth/resource-server/lightdash-token-validation.d.ts +14 -0
- package/dist/auth/resource-server/lightdash-token-validation.js +82 -0
- package/dist/auth/resource-server/lightdash-token-validation.test.d.ts +1 -0
- package/dist/auth/resource-server/lightdash-token-validation.test.js +177 -0
- package/dist/auth/resource-server/oauth-protected-resource.d.ts +25 -0
- package/dist/auth/resource-server/oauth-protected-resource.js +67 -0
- package/dist/auth/resource-server/shared-key-middleware.d.ts +13 -0
- package/dist/auth/resource-server/shared-key-middleware.js +24 -0
- package/dist/auth/resource-server/token-scopes.d.ts +15 -0
- package/dist/auth/resource-server/token-scopes.js +76 -0
- package/dist/auth/resource-server/token-scopes.test.d.ts +1 -0
- package/dist/auth/resource-server/token-scopes.test.js +51 -0
- package/dist/auth/resource-server/token-validation-cache.d.ts +15 -0
- package/dist/auth/resource-server/token-validation-cache.js +44 -0
- package/dist/auth/resource-server/token-validation-cache.test.d.ts +1 -0
- package/dist/auth/resource-server/token-validation-cache.test.js +41 -0
- package/dist/auth/resource-server/token-validation-error.d.ts +6 -0
- package/dist/auth/resource-server/token-validation-error.js +13 -0
- package/dist/auth/resource-server/www-authenticate.d.ts +8 -0
- package/dist/auth/resource-server/www-authenticate.js +24 -0
- package/dist/auth/resource-server/www-authenticate.test.d.ts +1 -0
- package/dist/auth/resource-server/www-authenticate.test.js +70 -0
- package/dist/auth/token-hash.d.ts +2 -0
- package/dist/auth/token-hash.js +8 -0
- package/dist/bin.d.ts +0 -4
- package/dist/bin.js +62 -33
- package/dist/config/env.d.ts +57 -0
- package/dist/config/env.js +60 -0
- package/dist/config/load-mcp-config.d.ts +30 -0
- package/dist/config/load-mcp-config.js +286 -0
- package/dist/config/load-mcp-config.test.d.ts +1 -0
- package/dist/config/load-mcp-config.test.js +202 -0
- package/dist/config/normalize-url.d.ts +13 -0
- package/dist/config/normalize-url.js +52 -0
- package/dist/config/normalize-url.test.d.ts +1 -0
- package/dist/config/normalize-url.test.js +47 -0
- package/dist/config/public-url.d.ts +3 -0
- package/dist/config/public-url.js +10 -0
- package/dist/config/runtime.d.ts +15 -0
- package/dist/config/runtime.js +48 -0
- package/dist/config/runtime.test.d.ts +1 -0
- package/dist/config/runtime.test.js +69 -0
- package/dist/config/test-mcp-http-config.d.ts +3 -0
- package/dist/config/test-mcp-http-config.js +7 -0
- package/dist/destructive/capability.d.ts +13 -0
- package/dist/destructive/capability.js +37 -0
- package/dist/destructive/capability.test.d.ts +1 -0
- package/dist/destructive/capability.test.js +46 -0
- package/dist/destructive/confirmation-claim.d.ts +21 -0
- package/dist/destructive/confirmation-claim.js +87 -0
- package/dist/destructive/confirmation-claim.test.d.ts +1 -0
- package/dist/destructive/confirmation-claim.test.js +50 -0
- package/dist/destructive/confirmation.d.ts +58 -0
- package/dist/destructive/confirmation.js +99 -0
- package/dist/destructive/confirmation.test.d.ts +1 -0
- package/dist/destructive/confirmation.test.js +75 -0
- package/dist/destructive/content-promote.d.ts +8 -0
- package/dist/destructive/content-promote.js +144 -0
- package/dist/destructive/content-soft-delete.d.ts +7 -0
- package/dist/destructive/content-soft-delete.js +106 -0
- package/dist/destructive/destructive-contract.test.d.ts +1 -0
- package/dist/destructive/destructive-contract.test.js +269 -0
- package/dist/destructive/precondition.d.ts +14 -0
- package/dist/destructive/precondition.js +31 -0
- package/dist/destructive/precondition.test.d.ts +1 -0
- package/dist/destructive/precondition.test.js +72 -0
- package/dist/destructive/promote-contract.test.d.ts +1 -0
- package/dist/destructive/promote-contract.test.js +339 -0
- package/dist/destructive/register-destructive-tool.d.ts +54 -0
- package/dist/destructive/register-destructive-tool.js +301 -0
- package/dist/destructive/request-state.d.ts +16 -0
- package/dist/destructive/request-state.js +76 -0
- package/dist/destructive/types.d.ts +64 -0
- package/dist/destructive/types.js +10 -0
- package/dist/governance/mcp-client-session.d.ts +9 -0
- package/dist/governance/mcp-client-session.js +30 -0
- package/dist/governance/mcp-client-session.test.d.ts +1 -0
- package/dist/governance/mcp-client-session.test.js +31 -0
- package/dist/governance/project-pin.d.ts +14 -0
- package/dist/governance/project-pin.js +44 -0
- package/dist/governance/project-pin.test.d.ts +1 -0
- package/dist/governance/project-pin.test.js +35 -0
- package/dist/governance/project-scope.d.ts +38 -0
- package/dist/governance/project-scope.js +79 -0
- package/dist/governance/project-scope.test.d.ts +4 -0
- package/dist/governance/project-scope.test.js +103 -0
- package/dist/http.d.ts +1 -2
- package/dist/http.integration.test.d.ts +1 -0
- package/dist/http.integration.test.js +722 -0
- package/dist/http.js +3 -170
- package/dist/http.test.d.ts +4 -0
- package/dist/http.test.js +131 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.integration.test.js +73 -30
- package/dist/index.js +28 -27
- package/dist/index.test.js +3 -3
- package/dist/logging/structured.d.ts +27 -0
- package/dist/logging/structured.js +32 -0
- package/dist/logging/structured.test.d.ts +1 -0
- package/dist/logging/structured.test.js +33 -0
- package/dist/personas/content-developer/v1/index.d.ts +10 -0
- package/dist/personas/content-developer/v1/index.js +51 -0
- package/dist/personas/content-developer/v1/prompts.d.ts +5 -0
- package/dist/personas/content-developer/v1/prompts.js +138 -0
- package/dist/personas/content-developer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-developer/v1/prompts.test.js +75 -0
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +15 -0
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +63 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +55 -0
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/content-developer/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-developer/v1/resources/playbooks.js +44 -0
- package/dist/personas/content-governance/v1/index.d.ts +9 -0
- package/dist/personas/content-governance/v1/index.js +29 -0
- package/dist/personas/content-governance/v1/prompts.d.ts +5 -0
- package/dist/personas/content-governance/v1/prompts.js +87 -0
- package/dist/personas/content-governance/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-governance/v1/prompts.test.js +75 -0
- package/dist/personas/content-governance/v1/resources/playbooks/charts.md +29 -0
- package/dist/personas/content-governance/v1/resources/playbooks/core.md +52 -0
- package/dist/personas/content-governance/v1/resources/playbooks/dashboards.md +48 -0
- package/dist/personas/content-governance/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/content-governance/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-governance/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-reader/v1/index.d.ts +8 -0
- package/dist/personas/content-reader/v1/index.js +37 -0
- package/dist/personas/content-reader/v1/prompts.d.ts +5 -0
- package/dist/personas/content-reader/v1/prompts.js +128 -0
- package/dist/personas/content-reader/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-reader/v1/prompts.test.js +25 -0
- package/dist/personas/content-reader/v1/resources/playbooks/compare.md +21 -0
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +40 -0
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +13 -0
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +19 -0
- package/dist/personas/content-reader/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/content-reader/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-reader/v1/resources/playbooks.js +49 -0
- package/dist/personas/index.d.ts +22 -0
- package/dist/personas/index.js +73 -0
- package/dist/personas/index.test.d.ts +1 -0
- package/dist/personas/index.test.js +109 -0
- package/dist/personas/lib/playbook-resources.d.ts +79 -0
- package/dist/personas/lib/playbook-resources.js +165 -0
- package/dist/personas/organization-audit/v1/index.d.ts +8 -0
- package/dist/personas/organization-audit/v1/index.js +42 -0
- package/dist/personas/organization-audit/v1/prompts.d.ts +5 -0
- package/dist/personas/organization-audit/v1/prompts.js +92 -0
- package/dist/personas/organization-audit/v1/prompts.test.d.ts +4 -0
- package/dist/personas/organization-audit/v1/prompts.test.js +25 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +13 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +9 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/core.md +36 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +9 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.js +41 -0
- package/dist/personas/persona.parity.test.d.ts +1 -0
- package/dist/personas/persona.parity.test.js +26 -0
- package/dist/personas/semantic-layer/v1/index.d.ts +8 -0
- package/dist/personas/semantic-layer/v1/index.js +32 -0
- package/dist/personas/semantic-layer/v1/prompts.d.ts +5 -0
- package/dist/personas/semantic-layer/v1/prompts.js +85 -0
- package/dist/personas/semantic-layer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/semantic-layer/v1/prompts.test.js +19 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/compose-compile.md +55 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +39 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +76 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.d.ts +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.js +39 -0
- package/dist/personas/types.d.ts +19 -0
- package/dist/personas/types.js +5 -0
- package/dist/policy/content-developer.d.ts +35 -0
- package/dist/policy/content-developer.js +91 -0
- package/dist/policy/content-developer.test.d.ts +4 -0
- package/dist/policy/content-developer.test.js +48 -0
- package/dist/policy/content-reader.d.ts +24 -0
- package/dist/policy/content-reader.js +52 -0
- package/dist/policy/content-reader.test.d.ts +4 -0
- package/dist/policy/content-reader.test.js +22 -0
- package/dist/policy/envelope.d.ts +31 -0
- package/dist/policy/envelope.js +24 -0
- package/dist/policy/preview-ledger-fault.test.d.ts +1 -0
- package/dist/policy/preview-ledger-fault.test.js +527 -0
- package/dist/policy/preview-ledger.d.ts +118 -0
- package/dist/policy/preview-ledger.js +243 -0
- package/dist/policy/preview-ledger.test.d.ts +1 -0
- package/dist/policy/preview-ledger.test.js +267 -0
- package/dist/policy/result-limits.d.ts +27 -0
- package/dist/policy/result-limits.js +107 -0
- package/dist/policy/result-limits.test.d.ts +4 -0
- package/dist/policy/result-limits.test.js +28 -0
- package/dist/protocol-contract.test.d.ts +1 -0
- package/dist/protocol-contract.test.js +42 -0
- package/dist/server/capabilities.d.ts +15 -0
- package/dist/server/capabilities.js +19 -0
- package/dist/server/capabilities.test.d.ts +1 -0
- package/dist/server/capabilities.test.js +41 -0
- package/dist/server/errors.test.d.ts +1 -0
- package/dist/server/errors.test.js +53 -0
- package/dist/server/request-context.d.ts +13 -0
- package/dist/server/request-context.js +2 -0
- package/dist/server/server.d.ts +4 -0
- package/dist/server/server.js +28 -0
- package/dist/server/server.test.d.ts +1 -0
- package/dist/server/server.test.js +15 -0
- package/dist/server/version.d.ts +1 -0
- package/dist/server/version.js +7 -0
- package/dist/server/version.test.d.ts +1 -0
- package/dist/server/version.test.js +9 -0
- package/dist/stdio.process.test.d.ts +1 -0
- package/dist/stdio.process.test.js +274 -0
- package/dist/store/config.d.ts +11 -0
- package/dist/store/config.js +50 -0
- package/dist/store/config.test.d.ts +1 -0
- package/dist/store/config.test.js +56 -0
- package/dist/store/create-oauth-broker-store.d.ts +6 -0
- package/dist/store/create-oauth-broker-store.js +16 -0
- package/dist/store/create-preview-store.d.ts +10 -0
- package/dist/store/create-preview-store.js +30 -0
- package/dist/store/create-session-store.d.ts +19 -0
- package/dist/store/create-session-store.js +24 -0
- package/dist/store/in-memory-preview-store.d.ts +17 -0
- package/dist/store/in-memory-preview-store.js +72 -0
- package/dist/store/redis-client.d.ts +11 -0
- package/dist/store/redis-client.js +48 -0
- package/dist/store/redis-oauth-broker-store.d.ts +42 -0
- package/dist/store/redis-oauth-broker-store.js +167 -0
- package/dist/store/redis-oauth-broker-store.test.d.ts +1 -0
- package/dist/store/redis-oauth-broker-store.test.js +80 -0
- package/dist/store/redis-preview-store.d.ts +23 -0
- package/dist/store/redis-preview-store.js +94 -0
- package/dist/store/redis-preview-store.test.d.ts +1 -0
- package/dist/store/redis-preview-store.test.js +39 -0
- package/dist/store/redis-session-index.d.ts +33 -0
- package/dist/store/redis-session-index.js +49 -0
- package/dist/store/types.d.ts +13 -0
- package/dist/store/types.js +8 -0
- package/dist/tools/composition/explain-content.d.ts +6 -0
- package/dist/tools/composition/explain-content.js +108 -0
- package/dist/tools/index.d.ts +2 -4
- package/dist/tools/index.js +4 -30
- package/dist/tools/index.test.d.ts +1 -0
- package/dist/tools/index.test.js +72 -0
- package/dist/tools/lib/api-errors.d.ts +11 -0
- package/dist/tools/lib/api-errors.js +27 -0
- package/dist/tools/lib/api-shape.d.ts +16 -0
- package/dist/tools/lib/api-shape.js +47 -0
- package/dist/tools/lib/assert-safe.d.ts +13 -0
- package/dist/tools/lib/assert-safe.js +21 -0
- package/dist/tools/lib/assert-safe.test.d.ts +4 -0
- package/dist/tools/lib/assert-safe.test.js +32 -0
- package/dist/tools/lib/concurrency.d.ts +4 -0
- package/dist/tools/lib/concurrency.js +24 -0
- package/dist/tools/lib/contracts.d.ts +34 -0
- package/dist/tools/lib/contracts.js +30 -0
- package/dist/tools/lib/redaction.d.ts +107 -0
- package/dist/tools/lib/redaction.js +299 -0
- package/dist/tools/lib/redaction.test.d.ts +4 -0
- package/dist/tools/lib/redaction.test.js +216 -0
- package/dist/tools/lib/register-org-audit.d.ts +9 -0
- package/dist/tools/lib/register-org-audit.js +20 -0
- package/dist/tools/lib/schema-fields.d.ts +9 -0
- package/dist/tools/lib/schema-fields.js +19 -0
- package/dist/tools/lib/stable-stringify.d.ts +9 -0
- package/dist/tools/lib/stable-stringify.js +35 -0
- package/dist/tools/organization/binding.d.ts +14 -0
- package/dist/tools/organization/binding.js +31 -0
- package/dist/tools/organization/invariants.test.d.ts +4 -0
- package/dist/tools/organization/invariants.test.js +28 -0
- package/dist/tools/organization/inventory.d.ts +10 -0
- package/dist/tools/organization/inventory.js +189 -0
- package/dist/tools/organization/roles.d.ts +10 -0
- package/dist/tools/organization/roles.js +213 -0
- package/dist/tools/project/content.d.ts +9 -0
- package/dist/tools/project/content.js +192 -0
- package/dist/tools/project/delete-chart.d.ts +4 -0
- package/dist/tools/project/delete-chart.js +8 -0
- package/dist/tools/project/delete-dashboard.d.ts +4 -0
- package/dist/tools/project/delete-dashboard.js +8 -0
- package/dist/tools/project/developer-content-preview.d.ts +12 -0
- package/dist/tools/project/developer-content-preview.js +286 -0
- package/dist/tools/project/developer-content-shared.d.ts +18 -0
- package/dist/tools/project/developer-content-shared.js +46 -0
- package/dist/tools/project/developer-content-shared.test.d.ts +1 -0
- package/dist/tools/project/developer-content-shared.test.js +25 -0
- package/dist/tools/project/developer-content.d.ts +39 -0
- package/dist/tools/project/developer-content.js +584 -0
- package/dist/tools/project/developer-helpers.d.ts +180 -0
- package/dist/tools/project/developer-helpers.js +484 -0
- package/dist/tools/project/developer-helpers.test.d.ts +1 -0
- package/dist/tools/project/developer-helpers.test.js +509 -0
- package/dist/tools/project/get-dashboard-promote-diff.d.ts +6 -0
- package/dist/tools/project/get-dashboard-promote-diff.js +42 -0
- package/dist/tools/project/invariants.test.d.ts +4 -0
- package/dist/tools/project/invariants.test.js +42 -0
- package/dist/tools/project/parameters.d.ts +7 -0
- package/dist/tools/project/parameters.js +74 -0
- package/dist/tools/project/projects.d.ts +10 -0
- package/dist/tools/project/projects.js +102 -0
- package/dist/tools/project/projects.test.d.ts +1 -0
- package/dist/tools/project/projects.test.js +154 -0
- package/dist/tools/project/promote-dashboard.d.ts +4 -0
- package/dist/tools/project/promote-dashboard.js +8 -0
- package/dist/tools/project/reader-content.d.ts +9 -0
- package/dist/tools/project/reader-content.js +208 -0
- package/dist/tools/project/reader-execution.d.ts +7 -0
- package/dist/tools/project/reader-execution.js +214 -0
- package/dist/tools/project/schedulers.d.ts +7 -0
- package/dist/tools/project/schedulers.js +115 -0
- package/dist/tools/project/schemas/chart-upsert.d.ts +33 -0
- package/dist/tools/project/schemas/chart-upsert.js +66 -0
- package/dist/tools/project/schemas/dashboard-tile.d.ts +29 -0
- package/dist/tools/project/schemas/dashboard-tile.js +57 -0
- package/dist/tools/project/schemas/dashboard.d.ts +70 -0
- package/dist/tools/project/schemas/dashboard.js +101 -0
- package/dist/tools/project/schemas/duplicate.d.ts +30 -0
- package/dist/tools/project/schemas/duplicate.js +86 -0
- package/dist/tools/project/schemas/index.d.ts +7 -0
- package/dist/tools/project/schemas/index.js +26 -0
- package/dist/tools/project/schemas/parse-helpers.d.ts +14 -0
- package/dist/tools/project/schemas/parse-helpers.js +34 -0
- package/dist/tools/project/schemas/payload-schemas.test.d.ts +1 -0
- package/dist/tools/project/schemas/payload-schemas.test.js +204 -0
- package/dist/tools/project/spaces.d.ts +7 -0
- package/dist/tools/project/spaces.js +101 -0
- package/dist/tools/query/bounded-saved-query.d.ts +37 -0
- package/dist/tools/query/bounded-saved-query.js +80 -0
- package/dist/tools/query/bounded-saved-query.test.d.ts +4 -0
- package/dist/tools/query/bounded-saved-query.test.js +82 -0
- package/dist/tools/query/chart-source.d.ts +10 -0
- package/dist/tools/query/chart-source.js +36 -0
- package/dist/tools/query/chart-source.test.d.ts +1 -0
- package/dist/tools/query/chart-source.test.js +62 -0
- package/dist/tools/query/filter-overrides.d.ts +34 -0
- package/dist/tools/query/filter-overrides.js +75 -0
- package/dist/tools/query/filter-overrides.test.d.ts +1 -0
- package/dist/tools/query/filter-overrides.test.js +21 -0
- package/dist/tools/query/lifecycle.d.ts +7 -0
- package/dist/tools/query/lifecycle.js +112 -0
- package/dist/tools/query/query-ledger.d.ts +34 -0
- package/dist/tools/query/query-ledger.js +86 -0
- package/dist/tools/query/query-ledger.test.d.ts +1 -0
- package/dist/tools/query/query-ledger.test.js +73 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +12 -0
- package/dist/tools/query/reader-tool-helpers.js +59 -0
- package/dist/tools/query/reader-tool-helpers.test.d.ts +1 -0
- package/dist/tools/query/reader-tool-helpers.test.js +49 -0
- package/dist/tools/query/result-normalizer.d.ts +27 -0
- package/dist/tools/query/result-normalizer.js +133 -0
- package/dist/tools/query/result-normalizer.test.d.ts +1 -0
- package/dist/tools/query/result-normalizer.test.js +41 -0
- package/dist/tools/query/wait-for-async.d.ts +10 -0
- package/dist/tools/query/wait-for-async.js +46 -0
- package/dist/tools/query/wait-for-async.test.d.ts +1 -0
- package/dist/tools/query/wait-for-async.test.js +45 -0
- package/dist/tools/registry.d.ts +225 -0
- package/dist/tools/registry.js +115 -0
- package/dist/tools/semantic/explore-helpers.d.ts +56 -0
- package/dist/tools/semantic/explore-helpers.js +115 -0
- package/dist/tools/semantic/explore-helpers.test.d.ts +1 -0
- package/dist/tools/semantic/explore-helpers.test.js +170 -0
- package/dist/tools/semantic/explores.d.ts +9 -0
- package/dist/tools/semantic/explores.js +80 -0
- package/dist/tools/semantic/metrics.d.ts +7 -0
- package/dist/tools/semantic/metrics.js +53 -0
- package/dist/tools/semantic/query.d.ts +6 -0
- package/dist/tools/semantic/query.js +42 -0
- package/dist/tools/semantic/schema-fields.d.ts +3 -0
- package/dist/tools/semantic/schema-fields.js +7 -0
- package/dist/tools/shared.d.ts +51 -15
- package/dist/tools/shared.js +171 -163
- package/dist/tools/shared.test.js +137 -184
- package/dist/tools/space/access.d.ts +66 -0
- package/dist/tools/space/access.js +322 -0
- package/dist/tools/space/access.test.d.ts +4 -0
- package/dist/tools/space/access.test.js +90 -0
- package/dist/transports/http-body.d.ts +5 -0
- package/dist/transports/http-body.js +50 -0
- package/dist/transports/http-request-utils.d.ts +2 -0
- package/dist/transports/http-request-utils.js +13 -0
- package/dist/transports/http-response.d.ts +6 -0
- package/dist/transports/http-response.js +56 -0
- package/dist/transports/session-store.d.ts +72 -0
- package/dist/transports/session-store.js +143 -0
- package/dist/transports/session-store.test.d.ts +1 -0
- package/dist/transports/session-store.test.js +111 -0
- package/dist/transports/streamable-http.d.ts +9 -0
- package/dist/transports/streamable-http.js +461 -0
- package/dist/transports/streamable-http.test.d.ts +1 -0
- package/dist/transports/streamable-http.test.js +100 -0
- package/package.json +26 -10
- package/dist/audit.d.ts +0 -6
- package/dist/config.d.ts +0 -47
- package/dist/config.js +0 -82
- package/dist/tools/ai-agents.d.ts +0 -6
- package/dist/tools/ai-agents.js +0 -388
- package/dist/tools/charts.d.ts +0 -6
- package/dist/tools/charts.js +0 -55
- package/dist/tools/content.d.ts +0 -6
- package/dist/tools/content.js +0 -37
- package/dist/tools/dashboards.d.ts +0 -6
- package/dist/tools/dashboards.js +0 -28
- package/dist/tools/explores.d.ts +0 -6
- package/dist/tools/explores.js +0 -65
- package/dist/tools/groups.d.ts +0 -6
- package/dist/tools/groups.js +0 -121
- package/dist/tools/metrics.d.ts +0 -6
- package/dist/tools/metrics.js +0 -45
- package/dist/tools/projects.d.ts +0 -6
- package/dist/tools/projects.js +0 -58
- package/dist/tools/query.d.ts +0 -6
- package/dist/tools/query.js +0 -34
- package/dist/tools/schedulers.d.ts +0 -6
- package/dist/tools/schedulers.js +0 -45
- package/dist/tools/spaces.d.ts +0 -6
- package/dist/tools/spaces.js +0 -128
- package/dist/tools/tags.d.ts +0 -6
- package/dist/tools/tags.js +0 -28
- package/dist/tools/users.d.ts +0 -6
- package/dist/tools/users.js +0 -50
- package/src/audit.ts +0 -6
- package/src/bin.ts +0 -58
- package/src/config.ts +0 -83
- package/src/errors.ts +0 -27
- package/src/http.ts +0 -187
- package/src/index.integration.test.ts +0 -57
- package/src/index.test.ts +0 -8
- package/src/index.ts +0 -31
- package/src/tools/ai-agents.ts +0 -759
- package/src/tools/charts.ts +0 -85
- package/src/tools/content.ts +0 -44
- package/src/tools/dashboards.ts +0 -25
- package/src/tools/explores.ts +0 -98
- package/src/tools/groups.ts +0 -180
- package/src/tools/index.ts +0 -35
- package/src/tools/metrics.ts +0 -42
- package/src/tools/projects.ts +0 -74
- package/src/tools/query.ts +0 -47
- package/src/tools/schedulers.ts +0 -42
- package/src/tools/shared.test.ts +0 -365
- package/src/tools/shared.ts +0 -274
- package/src/tools/spaces.ts +0 -217
- package/src/tools/tags.ts +0 -25
- package/src/tools/users.ts +0 -64
- package/tsconfig.json +0 -13
- /package/dist/{errors.d.ts → server/errors.d.ts} +0 -0
- /package/dist/{errors.js → server/errors.js} +0 -0
package/dist/tools/shared.js
CHANGED
|
@@ -3,223 +3,231 @@
|
|
|
3
3
|
* Shared types and helpers for MCP tool registration.
|
|
4
4
|
*
|
|
5
5
|
* Guardrail layers applied by registerToolSafe (outer → inner):
|
|
6
|
-
* 1. Audit log wrapper
|
|
7
|
-
* 2.
|
|
8
|
-
* 3. Input validation
|
|
9
|
-
* 4.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* 1. Audit log wrapper — captures timing and outcome for every call.
|
|
7
|
+
* 2. HTTP project pin — rejects projectUuid(s) that do not match X-Lightdash-Project (ALS).
|
|
8
|
+
* 3. Input validation — rejects invalid resource IDs (control chars, ?, #, %, path traversal).
|
|
9
|
+
* 4. Raw handler — the actual tool implementation.
|
|
10
|
+
*
|
|
11
|
+
* Capability surface is the persona toolIds allowlist (ADR-0006), not process safety mode.
|
|
12
12
|
*/
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.
|
|
14
|
+
exports.READ_ONLY_DEFAULT = exports.TOOL_PREFIX = void 0;
|
|
15
|
+
exports.jsonToolResult = jsonToolResult;
|
|
16
|
+
exports.blockedToolContent = blockedToolContent;
|
|
17
|
+
exports.withLightdashBlockedMarker = withLightdashBlockedMarker;
|
|
18
|
+
exports.withAuditStatus = withAuditStatus;
|
|
24
19
|
exports.registerToolSafe = registerToolSafe;
|
|
20
|
+
exports.wrapToolContextual = wrapToolContextual;
|
|
25
21
|
exports.wrapTool = wrapTool;
|
|
26
22
|
const common_1 = require("@lightdash-tools/common");
|
|
27
|
-
const
|
|
28
|
-
const
|
|
23
|
+
const server_1 = require("@modelcontextprotocol/server");
|
|
24
|
+
const tool_audit_context_js_1 = require("../audit/tool-audit-context.js");
|
|
25
|
+
const mcp_client_session_js_1 = require("../governance/mcp-client-session.js");
|
|
26
|
+
const project_pin_js_1 = require("../governance/project-pin.js");
|
|
27
|
+
const errors_js_1 = require("../server/errors.js");
|
|
29
28
|
/** Prefix for all MCP tool names (disambiguation when multiple servers are connected). */
|
|
30
|
-
exports.TOOL_PREFIX = '
|
|
31
|
-
|
|
29
|
+
exports.TOOL_PREFIX = 'lightdash_';
|
|
30
|
+
/** MCP requires structuredContent to be a record; wrap arrays and primitives. */
|
|
31
|
+
function toStructuredContent(data) {
|
|
32
|
+
if (data !== null && typeof data === 'object' && !Array.isArray(data)) {
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
return { data };
|
|
36
|
+
}
|
|
37
|
+
/** Builds a tool result with JSON text and matching structuredContent. */
|
|
38
|
+
function jsonToolResult(data) {
|
|
39
|
+
return {
|
|
40
|
+
content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
|
|
41
|
+
structuredContent: toStructuredContent(data),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* When a handler returns JSON text only, attach structuredContent for MCP clients.
|
|
46
|
+
*/
|
|
47
|
+
function enrichStructuredContent(result) {
|
|
48
|
+
if (result.structuredContent !== undefined || result.isError) {
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
const first = result.content[0];
|
|
52
|
+
if (!first || first.type !== 'text') {
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(first.text);
|
|
57
|
+
if (parsed !== null && typeof parsed === 'object') {
|
|
58
|
+
return Object.assign(Object.assign({}, result), { structuredContent: toStructuredContent(parsed) });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (_a) {
|
|
62
|
+
// Plain-text tool responses intentionally omit structuredContent.
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
// Re-export presets used by tools and tests
|
|
32
67
|
var common_2 = require("@lightdash-tools/common");
|
|
33
68
|
Object.defineProperty(exports, "READ_ONLY_DEFAULT", { enumerable: true, get: function () { return common_2.READ_ONLY_DEFAULT; } });
|
|
34
|
-
Object.defineProperty(exports, "WRITE_IDEMPOTENT", { enumerable: true, get: function () { return common_2.WRITE_IDEMPOTENT; } });
|
|
35
|
-
Object.defineProperty(exports, "WRITE_DESTRUCTIVE", { enumerable: true, get: function () { return common_2.WRITE_DESTRUCTIVE; } });
|
|
36
69
|
/** Internal default for mergeAnnotations; READ_ONLY_DEFAULT is the exported preset. */
|
|
37
70
|
const DEFAULT_ANNOTATIONS = common_1.READ_ONLY_DEFAULT;
|
|
38
71
|
/** Merges per-tool annotations with defaults; per-tool values win. */
|
|
39
72
|
function mergeAnnotations(overrides) {
|
|
40
73
|
return Object.assign(Object.assign({}, DEFAULT_ANNOTATIONS), overrides);
|
|
41
74
|
}
|
|
75
|
+
function buildAuditFields(name, projectUuids, status, start, auth) {
|
|
76
|
+
return {
|
|
77
|
+
timestamp: new Date().toISOString(),
|
|
78
|
+
sessionId: (0, common_1.getSessionId)(),
|
|
79
|
+
tool: name,
|
|
80
|
+
projectUuids: projectUuids.length > 0 ? projectUuids : undefined,
|
|
81
|
+
tokenHash: auth === null || auth === void 0 ? void 0 : auth.tokenHash,
|
|
82
|
+
subject: auth === null || auth === void 0 ? void 0 : auth.subject,
|
|
83
|
+
status,
|
|
84
|
+
durationMs: Date.now() - start,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
42
87
|
function isGuardrailBlocked(result) {
|
|
43
88
|
return ('_lightdashBlocked' in result &&
|
|
44
89
|
result['_lightdashBlocked'] === true);
|
|
45
90
|
}
|
|
91
|
+
function resolveAuditStatus(result) {
|
|
92
|
+
if ((0, server_1.isInputRequiredResult)(result)) {
|
|
93
|
+
return 'confirmation_requested';
|
|
94
|
+
}
|
|
95
|
+
const audited = result;
|
|
96
|
+
if (typeof audited._lightdashAuditStatus === 'string') {
|
|
97
|
+
return audited._lightdashAuditStatus;
|
|
98
|
+
}
|
|
99
|
+
if (isGuardrailBlocked(result)) {
|
|
100
|
+
return 'blocked';
|
|
101
|
+
}
|
|
102
|
+
if (result.isError) {
|
|
103
|
+
return 'error';
|
|
104
|
+
}
|
|
105
|
+
return 'success';
|
|
106
|
+
}
|
|
107
|
+
/** Guardrail-blocked tool result; audit wrapper strips `_lightdashBlocked`. */
|
|
108
|
+
function blockedToolContent(message) {
|
|
109
|
+
return {
|
|
110
|
+
content: [{ type: 'text', text: message }],
|
|
111
|
+
isError: true,
|
|
112
|
+
_lightdashBlocked: true,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Attach `_lightdashBlocked` so audit status is `blocked` (stripped before MCP client).
|
|
117
|
+
* Prefer for policy denials that already have JSON content + structuredContent.
|
|
118
|
+
*/
|
|
119
|
+
function withLightdashBlockedMarker(result) {
|
|
120
|
+
return Object.assign(Object.assign({}, result), { _lightdashBlocked: true });
|
|
121
|
+
}
|
|
122
|
+
/** Attach a specific audit status (stripped before MCP client). */
|
|
123
|
+
function withAuditStatus(result, status) {
|
|
124
|
+
return Object.assign(Object.assign({}, result), { _lightdashAuditStatus: status });
|
|
125
|
+
}
|
|
46
126
|
/**
|
|
47
|
-
* Registers a tool with prefix and annotations, applying
|
|
127
|
+
* Registers a tool with prefix and annotations, applying pin / validation / audit guardrails.
|
|
48
128
|
* shortName is prefixed to become TOOL_PREFIX + shortName.
|
|
49
129
|
* Pass annotations explicitly (e.g. READ_ONLY_DEFAULT, WRITE_IDEMPOTENT, or WRITE_DESTRUCTIVE).
|
|
50
|
-
*
|
|
51
|
-
* CLI flag --allowed-projects always takes priority over LIGHTDASH_TOOLS_ALLOWED_PROJECTS.
|
|
130
|
+
* Handlers may return TextContent or InputRequiredResult (MRTR elicitation).
|
|
52
131
|
*/
|
|
53
132
|
function registerToolSafe(server, shortName, options, handler) {
|
|
54
133
|
var _a, _b;
|
|
55
134
|
const name = exports.TOOL_PREFIX + shortName;
|
|
56
135
|
const annotations = mergeAnnotations(options.annotations);
|
|
57
|
-
// ── Static Filtering ──────────────────────────────────────────────────────
|
|
58
|
-
// Skip registration entirely if the tool exceeds the static safety mode.
|
|
59
|
-
const staticMode = (0, config_js_1.getStaticSafetyMode)();
|
|
60
|
-
if (staticMode && !(0, common_1.isAllowed)(staticMode, annotations)) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
// ── Safety-mode wrapper ───────────────────────────────────────────────────
|
|
64
|
-
// Tool is registered but calls are rejected at runtime when the dynamic mode
|
|
65
|
-
// does not permit the operation.
|
|
66
|
-
const mode = (0, config_js_1.getSafetyMode)();
|
|
67
|
-
const isToolAllowed = (0, common_1.isAllowed)(mode, annotations);
|
|
68
|
-
const isReadOnly = !!annotations.readOnlyHint;
|
|
69
136
|
let finalHandler = handler;
|
|
70
|
-
let finalDescription = options.description;
|
|
71
|
-
if (!isToolAllowed) {
|
|
72
|
-
finalDescription = `[DISABLED in ${mode} mode] ${options.description}`;
|
|
73
|
-
finalHandler = () => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
return ({
|
|
75
|
-
content: [
|
|
76
|
-
{
|
|
77
|
-
type: 'text',
|
|
78
|
-
text: `Error: Tool '${name}' is disabled in ${mode} mode. To enable it, change LIGHTDASH_TOOLS_SAFETY_MODE.`,
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
isError: true,
|
|
82
|
-
_lightdashBlocked: true,
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
else if ((0, config_js_1.isDryRunMode)() && !isReadOnly) {
|
|
87
|
-
// ── Dry-run wrapper ─────────────────────────────────────────────────────
|
|
88
|
-
// Write operations are simulated; no API calls are made.
|
|
89
|
-
finalDescription = `[DRY-RUN] ${options.description}`;
|
|
90
|
-
finalHandler = (args) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
return ({
|
|
92
|
-
content: [
|
|
93
|
-
{
|
|
94
|
-
type: 'text',
|
|
95
|
-
text: `[DRY-RUN] Tool '${name}' would be called with: ${JSON.stringify(args, null, 2)}. No changes were made.`,
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
_lightdashBlocked: true,
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
137
|
// ── Input validation wrapper ─────────────────────────────────────────────
|
|
103
|
-
// Validate resource IDs (projectUuid, slug, etc.) before handler.
|
|
138
|
+
// Validate resource IDs (projectUuid, projectUuids, slug, etc.) before handler.
|
|
104
139
|
const validatedInner = finalHandler;
|
|
105
|
-
finalHandler = (args, extra) =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
(0, common_1.validateResourceId)(uuid);
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
return {
|
|
113
|
-
content: [
|
|
114
|
-
{
|
|
115
|
-
type: 'text',
|
|
116
|
-
text: `Error: Invalid resource ID: ${err instanceof Error ? err.message : String(err)}`,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
isError: true,
|
|
120
|
-
_lightdashBlocked: true,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
140
|
+
finalHandler = async (args, extra) => {
|
|
141
|
+
try {
|
|
142
|
+
(0, common_1.validateResourceIdsInObject)(args);
|
|
123
143
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
(0, common_1.validateResourceId)(a.slug);
|
|
128
|
-
}
|
|
129
|
-
catch (err) {
|
|
130
|
-
return {
|
|
131
|
-
content: [
|
|
132
|
-
{
|
|
133
|
-
type: 'text',
|
|
134
|
-
text: `Error: Invalid slug: ${err instanceof Error ? err.message : String(err)}`,
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
|
-
isError: true,
|
|
138
|
-
_lightdashBlocked: true,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
return blockedToolContent(`Error: Invalid resource ID: ${err instanceof Error ? err.message : String(err)}`);
|
|
141
146
|
}
|
|
142
147
|
return validatedInner(args, extra);
|
|
143
|
-
}
|
|
144
|
-
// ──
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const innerHandler = finalHandler;
|
|
151
|
-
finalHandler = (args, extra) => __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
};
|
|
149
|
+
// ── HTTP project pin wrapper ──────────────────────────────────────────────
|
|
150
|
+
// When X-Lightdash-Project is set (ALS), reject tools that target another project.
|
|
151
|
+
const pinInner = finalHandler;
|
|
152
|
+
finalHandler = async (args, extra) => {
|
|
153
|
+
const pinned = (0, project_pin_js_1.getPinnedProjectUuid)();
|
|
154
|
+
if (pinned) {
|
|
152
155
|
const projectUuids = (0, common_1.extractProjectUuids)(args);
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
return {
|
|
156
|
-
content: [
|
|
157
|
-
{
|
|
158
|
-
type: 'text',
|
|
159
|
-
text: `Error: Project(s) [${deniedUuids.join(', ')}] are not in the list of allowed projects. Allowed: [${allowedProjects.join(', ')}].`,
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
isError: true,
|
|
163
|
-
_lightdashBlocked: true,
|
|
164
|
-
};
|
|
156
|
+
const mismatched = projectUuids.filter((uuid) => uuid !== pinned);
|
|
157
|
+
if (mismatched.length > 0) {
|
|
158
|
+
return blockedToolContent(`Error: Project(s) [${mismatched.join(', ')}] do not match the pinned project ${pinned} (X-Lightdash-Project).`);
|
|
165
159
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
160
|
+
}
|
|
161
|
+
return pinInner(args, extra);
|
|
162
|
+
};
|
|
169
163
|
// ── Audit log wrapper ─────────────────────────────────────────────────────
|
|
170
164
|
// Outermost layer: records timing and outcome for every call.
|
|
171
165
|
const auditedInner = finalHandler;
|
|
172
|
-
finalHandler = (args, extra) =>
|
|
166
|
+
finalHandler = async (args, extra) => {
|
|
173
167
|
const start = Date.now();
|
|
174
168
|
const projectUuids = (0, common_1.extractProjectUuids)(args);
|
|
169
|
+
// Snapshot before await — wrapTool ALS may end when the handler returns.
|
|
170
|
+
const auth = (0, tool_audit_context_js_1.getToolAuditAuth)();
|
|
175
171
|
let status = 'success';
|
|
176
172
|
let result;
|
|
177
173
|
try {
|
|
178
|
-
result =
|
|
179
|
-
|
|
180
|
-
status = 'blocked';
|
|
181
|
-
}
|
|
182
|
-
else if (result.isError) {
|
|
183
|
-
status = 'error';
|
|
184
|
-
}
|
|
174
|
+
result = await auditedInner(args, extra);
|
|
175
|
+
status = resolveAuditStatus(result);
|
|
185
176
|
}
|
|
186
177
|
catch (err) {
|
|
187
178
|
status = 'error';
|
|
188
|
-
(0, common_1.logAuditEntry)(
|
|
189
|
-
timestamp: new Date().toISOString(),
|
|
190
|
-
sessionId: (0, common_1.getSessionId)(),
|
|
191
|
-
tool: name,
|
|
192
|
-
projectUuids: projectUuids.length > 0 ? projectUuids : undefined,
|
|
193
|
-
status,
|
|
194
|
-
durationMs: Date.now() - start,
|
|
195
|
-
});
|
|
179
|
+
(0, common_1.logAuditEntry)(buildAuditFields(name, projectUuids, status, start, auth));
|
|
196
180
|
throw err;
|
|
197
181
|
}
|
|
198
|
-
(0, common_1.logAuditEntry)(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
const mergedOptions = Object.assign(Object.assign({}, options), {
|
|
182
|
+
(0, common_1.logAuditEntry)(buildAuditFields(name, projectUuids, status, start, auth));
|
|
183
|
+
// Pass InputRequiredResult through unchanged (MRTR).
|
|
184
|
+
if ((0, server_1.isInputRequiredResult)(result)) {
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
// Strip internal markers before returning to the MCP client.
|
|
188
|
+
const enriched = enrichStructuredContent(result);
|
|
189
|
+
const { content, isError, structuredContent } = enriched;
|
|
190
|
+
return structuredContent !== undefined
|
|
191
|
+
? { content, isError, structuredContent }
|
|
192
|
+
: { content, isError };
|
|
193
|
+
};
|
|
194
|
+
const mergedOptions = Object.assign(Object.assign({}, options), { title: (_a = options.title) !== null && _a !== void 0 ? _a : (_b = options.annotations) === null || _b === void 0 ? void 0 : _b.title, annotations });
|
|
211
195
|
server.registerTool(name, mergedOptions, finalHandler);
|
|
212
196
|
}
|
|
213
|
-
function
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
197
|
+
function asServerContext(extra) {
|
|
198
|
+
if (extra !== null && typeof extra === 'object' && 'mcpReq' in extra) {
|
|
199
|
+
return extra;
|
|
200
|
+
}
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
/** Like wrapTool, but passes ServerContext / session / auth for elicitation-capable tools. */
|
|
204
|
+
function wrapToolContextual(contextProvider, fn) {
|
|
205
|
+
return async (args, extra) => {
|
|
206
|
+
const sessionId = (0, mcp_client_session_js_1.resolveMcpClientSessionId)(extra);
|
|
217
207
|
try {
|
|
218
|
-
return
|
|
208
|
+
return await (0, mcp_client_session_js_1.runWithMcpClientSessionAsync)(sessionId, async () => {
|
|
209
|
+
const context = await contextProvider.getContext(extra);
|
|
210
|
+
const auth = context.auth;
|
|
211
|
+
return await (0, tool_audit_context_js_1.runWithToolAuditAuthAsync)({ tokenHash: auth === null || auth === void 0 ? void 0 : auth.tokenHash, subject: auth === null || auth === void 0 ? void 0 : auth.subject }, async () => {
|
|
212
|
+
const execution = {
|
|
213
|
+
lightdashClient: context.lightdashClient,
|
|
214
|
+
serverContext: asServerContext(extra),
|
|
215
|
+
sessionId,
|
|
216
|
+
};
|
|
217
|
+
const handler = fn(execution);
|
|
218
|
+
return await handler(args);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
219
221
|
}
|
|
220
222
|
catch (err) {
|
|
221
223
|
const text = (0, errors_js_1.toMcpErrorMessage)(err);
|
|
222
224
|
return { content: [{ type: 'text', text }], isError: true };
|
|
223
225
|
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function wrapTool(contextProvider, fn) {
|
|
229
|
+
return wrapToolContextual(contextProvider, (ctx) => {
|
|
230
|
+
const inner = fn(ctx.lightdashClient);
|
|
231
|
+
return async (args) => inner(args);
|
|
224
232
|
});
|
|
225
233
|
}
|