@lightdash-tools/mcp 0.8.0 → 0.11.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 +112 -236
- package/dist/audit/server-profile.d.ts +13 -0
- package/dist/audit/server-profile.js +28 -0
- package/dist/audit/server-profile.test.js +21 -0
- package/dist/auth/oauth-broker/pending-store.d.ts +6 -7
- package/dist/auth/oauth-broker/pending-store.js +3 -4
- package/dist/auth/oauth-broker/pending-store.test.d.ts +2 -3
- package/dist/auth/oauth-broker/pending-store.test.js +2 -39
- package/dist/auth/oauth-broker/routes.d.ts +1 -1
- package/dist/auth/oauth-broker/routes.js +3 -3
- package/dist/auth/oauth-broker/routes.test.js +1 -1
- package/dist/auth/request-state-key.d.ts +19 -0
- package/dist/auth/request-state-key.js +49 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +1 -3
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +1 -20
- package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +14 -14
- package/dist/auth/resource-server/oauth-protected-resource.d.ts +6 -6
- package/dist/auth/resource-server/oauth-protected-resource.js +8 -8
- package/dist/auth/resource-server/token-scopes.d.ts +1 -1
- package/dist/auth/resource-server/token-scopes.js +1 -1
- package/dist/auth/resource-server/www-authenticate.test.js +11 -13
- package/dist/bin.js +54 -51
- package/dist/config/env.d.ts +8 -16
- package/dist/config/env.js +9 -17
- package/dist/config/load-mcp-config.d.ts +0 -4
- package/dist/config/load-mcp-config.js +9 -38
- package/dist/config/load-mcp-config.test.js +8 -2
- package/dist/config/normalize-url.d.ts +1 -1
- package/dist/config/normalize-url.js +1 -1
- package/dist/config/normalize-url.test.js +16 -13
- package/dist/config/obsolete-env.d.ts +5 -0
- package/dist/config/obsolete-env.js +48 -0
- package/dist/config/obsolete-env.test.js +22 -0
- package/dist/config/runtime.d.ts +3 -3
- package/dist/config/runtime.js +19 -23
- package/dist/config/runtime.test.js +23 -9
- package/dist/config/test-mcp-http-config.js +1 -1
- package/dist/destructive/content-promote.js +7 -1
- package/dist/destructive/promote-contract.test.js +106 -47
- package/dist/destructive/register-destructive-tool.js +6 -24
- package/dist/destructive/request-state.d.ts +2 -6
- package/dist/destructive/request-state.js +3 -38
- package/dist/destructive/types.d.ts +2 -1
- package/dist/governance/available-projects.d.ts +37 -0
- package/dist/governance/available-projects.js +132 -0
- package/dist/governance/available-projects.test.d.ts +4 -0
- package/dist/governance/available-projects.test.js +107 -0
- package/dist/governance/mcp-client-session.d.ts +3 -2
- package/dist/governance/mcp-client-session.js +3 -2
- package/dist/governance/mcp-post-factory-context.d.ts +15 -0
- package/dist/governance/mcp-post-factory-context.js +22 -0
- package/dist/governance/mcp-post-factory-context.test.js +34 -0
- package/dist/governance/project-scope.d.ts +8 -22
- package/dist/governance/project-scope.js +36 -44
- package/dist/governance/project-scope.test.d.ts +1 -1
- package/dist/governance/project-scope.test.js +21 -44
- package/dist/governance/promote-allowlist.d.ts +18 -0
- package/dist/governance/promote-allowlist.js +66 -0
- package/dist/governance/promote-allowlist.test.d.ts +4 -0
- package/dist/governance/promote-allowlist.test.js +87 -0
- package/dist/http.integration.test.js +116 -265
- package/dist/http.test.js +0 -12
- package/dist/index.d.ts +5 -1
- package/dist/index.integration.test.js +0 -4
- package/dist/index.js +31 -16
- package/dist/policy/content-developer.d.ts +3 -3
- package/dist/policy/content-developer.js +3 -3
- package/dist/policy/content-developer.test.js +10 -4
- package/dist/policy/content-reader.d.ts +15 -6
- package/dist/policy/content-reader.js +39 -10
- package/dist/policy/content-reader.test.js +5 -3
- package/dist/policy/envelope.d.ts +4 -2
- package/dist/policy/envelope.js +2 -2
- package/dist/policy/envelope.test.js +28 -0
- package/dist/policy/preview-ledger-fault.test.js +101 -426
- package/dist/policy/preview-ledger.d.ts +38 -74
- package/dist/policy/preview-ledger.js +108 -186
- package/dist/policy/preview-ledger.test.js +237 -111
- package/dist/policy/result-limits.d.ts +6 -1
- package/dist/policy/result-limits.js +28 -29
- package/dist/policy/result-limits.test.js +10 -1
- package/dist/profiles/ai-agent-ops/v1/index.d.ts +6 -0
- package/dist/profiles/ai-agent-ops/v1/index.js +20 -0
- package/dist/profiles/ai-agent-ops/v1/prompts.d.ts +5 -0
- package/dist/profiles/ai-agent-ops/v1/prompts.js +141 -0
- package/dist/profiles/ai-agent-ops/v1/prompts.test.d.ts +4 -0
- package/dist/profiles/ai-agent-ops/v1/prompts.test.js +26 -0
- package/dist/profiles/ai-agent-ops/v1/resources/playbooks/core.md +39 -0
- package/dist/profiles/ai-agent-ops/v1/resources/playbooks/evaluation.md +25 -0
- package/dist/profiles/ai-agent-ops/v1/resources/playbooks/index.md +14 -0
- package/dist/profiles/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +28 -0
- package/dist/profiles/ai-agent-ops/v1/resources/playbooks/release-gate.md +22 -0
- package/dist/profiles/ai-agent-ops/v1/resources/playbooks.d.ts +10 -0
- package/dist/profiles/ai-agent-ops/v1/resources/playbooks.js +41 -0
- package/dist/profiles/content-developer/v1/index.d.ts +8 -0
- package/dist/profiles/content-developer/v1/index.js +22 -0
- package/dist/{personas → profiles}/content-developer/v1/prompts.d.ts +3 -0
- package/dist/profiles/content-developer/v1/prompts.js +157 -0
- package/dist/profiles/content-developer/v1/prompts.test.js +286 -0
- package/dist/profiles/content-developer/v1/resources/playbooks/chart-types.md +138 -0
- package/dist/profiles/content-developer/v1/resources/playbooks/content-move.md +22 -0
- package/dist/profiles/content-developer/v1/resources/playbooks/core.md +109 -0
- package/dist/profiles/content-developer/v1/resources/playbooks/dashboard-design.md +153 -0
- package/dist/profiles/content-developer/v1/resources/playbooks/dashboards.md +108 -0
- package/dist/profiles/content-developer/v1/resources/playbooks/index.md +15 -0
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks.d.ts +1 -1
- package/dist/profiles/content-developer/v1/resources/playbooks.js +65 -0
- package/dist/profiles/content-governance/v1/index.d.ts +7 -0
- package/dist/profiles/content-governance/v1/index.js +21 -0
- package/dist/{personas → profiles}/content-governance/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/core.md +3 -3
- package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/dashboards.md +1 -1
- package/dist/{personas → profiles}/content-governance/v1/resources/playbooks.js +4 -4
- package/dist/profiles/content-reader/v1/index.d.ts +6 -0
- package/dist/profiles/content-reader/v1/index.js +20 -0
- package/dist/profiles/content-reader/v1/prompts.js +162 -0
- package/dist/{personas → profiles}/content-reader/v1/prompts.test.js +2 -2
- package/dist/profiles/content-reader/v1/resources/playbooks/compare.md +36 -0
- package/dist/profiles/content-reader/v1/resources/playbooks/core.md +67 -0
- package/dist/profiles/content-reader/v1/resources/playbooks/discover.md +35 -0
- package/dist/profiles/content-reader/v1/resources/playbooks/explain-run.md +49 -0
- package/dist/profiles/content-reader/v1/resources/playbooks/index.md +14 -0
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.js +4 -4
- package/dist/profiles/data-analyst/v1/index.d.ts +6 -0
- package/dist/profiles/data-analyst/v1/index.js +20 -0
- package/dist/profiles/data-analyst/v1/prompts.d.ts +5 -0
- package/dist/profiles/data-analyst/v1/prompts.js +41 -0
- package/dist/profiles/data-analyst/v1/prompts.test.d.ts +4 -0
- package/dist/profiles/data-analyst/v1/prompts.test.js +26 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks/core.md +41 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks/explore.md +26 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks/index.md +8 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks.d.ts +10 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks.js +33 -0
- package/dist/profiles/index.d.ts +24 -0
- package/dist/profiles/index.js +73 -0
- package/dist/profiles/index.test.js +121 -0
- package/dist/{personas → profiles}/lib/playbook-resources.d.ts +12 -10
- package/dist/{personas → profiles}/lib/playbook-resources.js +28 -24
- package/dist/profiles/organization-audit/v1/index.d.ts +6 -0
- package/dist/profiles/organization-audit/v1/index.js +20 -0
- package/dist/profiles/organization-audit/v1/prompts.js +124 -0
- package/dist/{personas → profiles}/organization-audit/v1/prompts.test.js +2 -2
- package/dist/profiles/organization-audit/v1/resources/playbooks/access.md +21 -0
- package/dist/profiles/organization-audit/v1/resources/playbooks/content.md +19 -0
- package/dist/profiles/organization-audit/v1/resources/playbooks/core.md +69 -0
- package/dist/profiles/organization-audit/v1/resources/playbooks/deliveries.md +14 -0
- package/dist/profiles/organization-audit/v1/resources/playbooks/index.md +14 -0
- package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.js +3 -3
- package/dist/profiles/profile.membership.test.js +36 -0
- package/dist/profiles/semantic-layer/v1/index.d.ts +6 -0
- package/dist/profiles/semantic-layer/v1/index.js +19 -0
- package/dist/profiles/semantic-layer/v1/prompts.js +96 -0
- package/dist/{personas → profiles}/semantic-layer/v1/prompts.test.js +2 -2
- package/dist/profiles/semantic-layer/v1/resources/playbooks/compose-compile.md +60 -0
- package/dist/profiles/semantic-layer/v1/resources/playbooks/core.md +71 -0
- package/dist/profiles/semantic-layer/v1/resources/playbooks/explore.md +79 -0
- package/dist/profiles/semantic-layer/v1/resources/playbooks/index.md +13 -0
- package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.js +4 -4
- package/dist/{personas → profiles}/types.d.ts +6 -7
- package/dist/{personas → profiles}/types.js +1 -1
- package/dist/protocol-contract.test.js +48 -3
- package/dist/server/capabilities.d.ts +6 -6
- package/dist/server/capabilities.js +11 -8
- package/dist/server/capabilities.test.js +8 -7
- package/dist/server/server.js +17 -13
- package/dist/server/upstream-errors.d.ts +17 -0
- package/dist/server/upstream-errors.js +60 -0
- package/dist/server/upstream-errors.test.js +50 -0
- package/dist/stdio.process.test.js +65 -9
- package/dist/tools/ai-agents/agents.d.ts +7 -0
- package/dist/tools/ai-agents/agents.js +32 -0
- package/dist/tools/ai-agents/agents.test.d.ts +1 -0
- package/dist/tools/ai-agents/agents.test.js +176 -0
- package/dist/tools/ai-agents/discovery.d.ts +9 -0
- package/dist/tools/ai-agents/discovery.js +73 -0
- package/dist/tools/ai-agents/evaluations.d.ts +14 -0
- package/dist/tools/ai-agents/evaluations.js +177 -0
- package/dist/tools/ai-agents/helpers.d.ts +63 -0
- package/dist/tools/ai-agents/helpers.js +321 -0
- package/dist/tools/ai-agents/threads.d.ts +7 -0
- package/dist/tools/ai-agents/threads.js +40 -0
- package/dist/tools/composition/explain-content.js +3 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.test.js +16 -10
- package/dist/tools/lib/schema-fields.d.ts +2 -0
- package/dist/tools/lib/schema-fields.js +4 -1
- package/dist/tools/lib/stable-stringify.d.ts +1 -1
- package/dist/tools/lib/stable-stringify.js +1 -1
- package/dist/tools/organization/invariants.test.d.ts +1 -1
- package/dist/tools/organization/invariants.test.js +5 -5
- package/dist/tools/organization/inventory.js +2 -1
- package/dist/tools/project/content.js +5 -1
- package/dist/tools/project/developer-content-preview.d.ts +3 -2
- package/dist/tools/project/developer-content-preview.js +41 -36
- package/dist/tools/project/developer-content-shared.d.ts +9 -3
- package/dist/tools/project/developer-content-shared.js +8 -4
- package/dist/tools/project/developer-content.d.ts +7 -8
- package/dist/tools/project/developer-content.js +72 -67
- package/dist/tools/project/developer-get-chart-as-code.d.ts +9 -0
- package/dist/tools/project/developer-get-chart-as-code.js +39 -0
- package/dist/tools/project/developer-get-chart-as-code.test.d.ts +4 -0
- package/dist/tools/project/developer-get-chart-as-code.test.js +70 -0
- package/dist/tools/project/developer-helpers.d.ts +1 -1
- package/dist/tools/project/developer-helpers.js +1 -1
- package/dist/tools/project/get-dashboard-promote-diff.js +12 -2
- package/dist/tools/project/invariants.test.d.ts +1 -1
- package/dist/tools/project/invariants.test.js +12 -10
- package/dist/tools/project/parameters.js +8 -3
- package/dist/tools/project/projects.d.ts +1 -4
- package/dist/tools/project/projects.js +37 -15
- package/dist/tools/project/projects.test.js +70 -8
- package/dist/tools/project/reader-content.js +6 -3
- package/dist/tools/project/reader-execution.js +4 -2
- package/dist/tools/project/reader-export-chart-image.d.ts +6 -0
- package/dist/tools/project/reader-export-chart-image.js +78 -0
- package/dist/tools/project/reader-export-chart-image.test.d.ts +4 -0
- package/dist/tools/project/reader-export-chart-image.test.js +149 -0
- package/dist/tools/project/spaces.js +12 -4
- package/dist/tools/project/spaces.test.d.ts +1 -0
- package/dist/tools/project/spaces.test.js +47 -0
- package/dist/tools/query/bounded-saved-query.d.ts +4 -3
- package/dist/tools/query/bounded-saved-query.js +4 -6
- package/dist/tools/query/lifecycle.d.ts +1 -1
- package/dist/tools/query/lifecycle.js +25 -31
- package/dist/tools/query/query-ledger.d.ts +17 -9
- package/dist/tools/query/query-ledger.js +21 -15
- package/dist/tools/query/query-ledger.test.js +13 -11
- package/dist/tools/query/reader-tool-helpers.d.ts +4 -2
- package/dist/tools/query/reader-tool-helpers.js +11 -8
- package/dist/tools/query/reader-tool-helpers.test.js +8 -4
- package/dist/tools/query/run-metric-query.d.ts +6 -0
- package/dist/tools/query/run-metric-query.js +94 -0
- package/dist/tools/query/run-metric-query.test.d.ts +4 -0
- package/dist/tools/query/run-metric-query.test.js +116 -0
- package/dist/tools/registry.d.ts +71 -8
- package/dist/tools/registry.js +36 -6
- package/dist/tools/semantic/explores.js +43 -17
- package/dist/tools/semantic/metrics.js +22 -8
- package/dist/tools/semantic/query.js +25 -17
- package/dist/tools/shared.d.ts +28 -9
- package/dist/tools/shared.js +62 -29
- package/dist/tools/shared.test.js +100 -4
- package/dist/transports/streamable-http.js +75 -223
- package/dist/transports/streamable-http.test.js +19 -12
- package/package.json +5 -6
- package/dist/destructive/confirmation-claim.d.ts +0 -21
- package/dist/destructive/confirmation-claim.js +0 -87
- package/dist/destructive/confirmation-claim.test.js +0 -50
- package/dist/personas/content-developer/v1/index.d.ts +0 -10
- package/dist/personas/content-developer/v1/index.js +0 -51
- package/dist/personas/content-developer/v1/prompts.js +0 -138
- package/dist/personas/content-developer/v1/prompts.test.js +0 -75
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +0 -15
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +0 -63
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +0 -55
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +0 -13
- package/dist/personas/content-developer/v1/resources/playbooks.js +0 -44
- package/dist/personas/content-governance/v1/index.d.ts +0 -9
- package/dist/personas/content-governance/v1/index.js +0 -29
- package/dist/personas/content-reader/v1/index.d.ts +0 -8
- package/dist/personas/content-reader/v1/index.js +0 -37
- package/dist/personas/content-reader/v1/prompts.js +0 -128
- package/dist/personas/content-reader/v1/resources/playbooks/compare.md +0 -21
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +0 -40
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +0 -13
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +0 -19
- package/dist/personas/content-reader/v1/resources/playbooks/index.md +0 -14
- package/dist/personas/index.d.ts +0 -22
- package/dist/personas/index.js +0 -73
- package/dist/personas/index.test.js +0 -109
- package/dist/personas/organization-audit/v1/index.d.ts +0 -8
- package/dist/personas/organization-audit/v1/index.js +0 -42
- package/dist/personas/organization-audit/v1/prompts.js +0 -92
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +0 -13
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +0 -9
- package/dist/personas/organization-audit/v1/resources/playbooks/core.md +0 -36
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +0 -9
- package/dist/personas/organization-audit/v1/resources/playbooks/index.md +0 -14
- package/dist/personas/persona.parity.test.js +0 -26
- package/dist/personas/semantic-layer/v1/index.d.ts +0 -8
- package/dist/personas/semantic-layer/v1/index.js +0 -32
- package/dist/personas/semantic-layer/v1/prompts.js +0 -85
- package/dist/personas/semantic-layer/v1/resources/playbooks/compose-compile.md +0 -55
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +0 -39
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +0 -76
- package/dist/personas/semantic-layer/v1/resources/playbooks/index.md +0 -13
- package/dist/store/config.d.ts +0 -11
- package/dist/store/config.js +0 -50
- package/dist/store/config.test.js +0 -56
- package/dist/store/create-oauth-broker-store.d.ts +0 -6
- package/dist/store/create-oauth-broker-store.js +0 -16
- package/dist/store/create-preview-store.d.ts +0 -10
- package/dist/store/create-preview-store.js +0 -30
- package/dist/store/create-session-store.d.ts +0 -19
- package/dist/store/create-session-store.js +0 -24
- package/dist/store/in-memory-preview-store.d.ts +0 -17
- package/dist/store/in-memory-preview-store.js +0 -72
- package/dist/store/redis-client.d.ts +0 -11
- package/dist/store/redis-client.js +0 -48
- package/dist/store/redis-oauth-broker-store.d.ts +0 -42
- package/dist/store/redis-oauth-broker-store.js +0 -167
- package/dist/store/redis-oauth-broker-store.test.js +0 -80
- package/dist/store/redis-preview-store.d.ts +0 -23
- package/dist/store/redis-preview-store.js +0 -94
- package/dist/store/redis-preview-store.test.js +0 -39
- package/dist/store/redis-session-index.d.ts +0 -33
- package/dist/store/redis-session-index.js +0 -49
- package/dist/store/types.d.ts +0 -13
- package/dist/store/types.js +0 -8
- package/dist/transports/http-request-utils.d.ts +0 -2
- package/dist/transports/http-request-utils.js +0 -13
- package/dist/transports/session-store.d.ts +0 -72
- package/dist/transports/session-store.js +0 -143
- package/dist/transports/session-store.test.js +0 -111
- /package/dist/{destructive/confirmation-claim.test.d.ts → audit/server-profile.test.d.ts} +0 -0
- /package/dist/{personas/index.test.d.ts → config/obsolete-env.test.d.ts} +0 -0
- /package/dist/{personas/persona.parity.test.d.ts → governance/mcp-post-factory-context.test.d.ts} +0 -0
- /package/dist/{store/config.test.d.ts → policy/envelope.test.d.ts} +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/charts.md +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{store/redis-oauth-broker-store.test.d.ts → profiles/index.test.d.ts} +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{store/redis-preview-store.test.d.ts → profiles/profile.membership.test.d.ts} +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{transports/session-store.test.d.ts → server/upstream-errors.test.d.ts} +0 -0
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Protocol contract: legacy (InMemoryTransport / initialize) and modern
|
|
5
|
+
* (createMcpHandler + StreamableHTTPClientTransport with versionNegotiation).
|
|
5
6
|
* No Lightdash network calls — stub McpContextProvider only.
|
|
6
7
|
*/
|
|
8
|
+
const common_1 = require("@lightdash-tools/common");
|
|
7
9
|
const client_1 = require("@modelcontextprotocol/client");
|
|
8
10
|
const server_1 = require("@modelcontextprotocol/server");
|
|
9
11
|
const vitest_1 = require("vitest");
|
|
10
12
|
const server_js_1 = require("./server/server.js");
|
|
11
13
|
const shared_js_1 = require("./tools/shared.js");
|
|
14
|
+
const EXPECTED_TOOL_COUNT = (0, common_1.listMcpToolNamesByProfile)('semantic-layer').length;
|
|
12
15
|
function createStubContextProvider() {
|
|
13
16
|
return {
|
|
14
17
|
getContext: async () => ({
|
|
@@ -17,7 +20,13 @@ function createStubContextProvider() {
|
|
|
17
20
|
}),
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
async function connectViaHandlerFetch(handler, client) {
|
|
24
|
+
const transport = new client_1.StreamableHTTPClientTransport(new URL('http://test.local/mcp'), {
|
|
25
|
+
fetch: (url, init) => handler.fetch(new Request(url, init)),
|
|
26
|
+
});
|
|
27
|
+
await client.connect(transport);
|
|
28
|
+
}
|
|
29
|
+
(0, vitest_1.describe)('MCP protocol contract (legacy InMemoryTransport)', () => {
|
|
21
30
|
let server;
|
|
22
31
|
let mcpClient;
|
|
23
32
|
(0, vitest_1.afterEach)(async () => {
|
|
@@ -34,9 +43,45 @@ function createStubContextProvider() {
|
|
|
34
43
|
mcpClient = new client_1.Client({ name: 'protocol-contract-test', version: '0.0.0' });
|
|
35
44
|
await mcpClient.connect(clientTransport);
|
|
36
45
|
const { tools } = await mcpClient.listTools();
|
|
37
|
-
(0, vitest_1.expect)(tools).toHaveLength(
|
|
46
|
+
(0, vitest_1.expect)(tools).toHaveLength(EXPECTED_TOOL_COUNT);
|
|
38
47
|
(0, vitest_1.expect)(tools.every((t) => t.name.startsWith(shared_js_1.TOOL_PREFIX))).toBe(true);
|
|
39
48
|
(0, vitest_1.expect)(tools.some((t) => t.name === `${shared_js_1.TOOL_PREFIX}list_projects`)).toBe(true);
|
|
40
49
|
(0, vitest_1.expect)(tools.some((t) => t.name === `${shared_js_1.TOOL_PREFIX}compile_query`)).toBe(true);
|
|
41
50
|
});
|
|
42
51
|
});
|
|
52
|
+
(0, vitest_1.describe)('MCP protocol contract (modern createMcpHandler)', () => {
|
|
53
|
+
let handler;
|
|
54
|
+
let mcpClient;
|
|
55
|
+
(0, vitest_1.afterEach)(async () => {
|
|
56
|
+
await (mcpClient === null || mcpClient === void 0 ? void 0 : mcpClient.close().catch(() => undefined));
|
|
57
|
+
await (handler === null || handler === void 0 ? void 0 : handler.close().catch(() => undefined));
|
|
58
|
+
mcpClient = undefined;
|
|
59
|
+
handler = undefined;
|
|
60
|
+
});
|
|
61
|
+
(0, vitest_1.it)('discovers 2026-07-28 then tools/list via handler.fetch', async () => {
|
|
62
|
+
const contextProvider = createStubContextProvider();
|
|
63
|
+
handler = (0, server_1.createMcpHandler)(() => (0, server_js_1.createLightdashMcpServer)(contextProvider), {
|
|
64
|
+
legacy: 'stateless',
|
|
65
|
+
});
|
|
66
|
+
mcpClient = new client_1.Client({ name: 'protocol-contract-modern', version: '0.0.0' }, { versionNegotiation: { mode: { pin: '2026-07-28' } } });
|
|
67
|
+
await connectViaHandlerFetch(handler, mcpClient);
|
|
68
|
+
(0, vitest_1.expect)(mcpClient.getProtocolEra()).toBe('modern');
|
|
69
|
+
const { tools } = await mcpClient.listTools();
|
|
70
|
+
(0, vitest_1.expect)(tools).toHaveLength(EXPECTED_TOOL_COUNT);
|
|
71
|
+
(0, vitest_1.expect)(tools.every((t) => t.name.startsWith(shared_js_1.TOOL_PREFIX))).toBe(true);
|
|
72
|
+
(0, vitest_1.expect)(tools.some((t) => t.name === `${shared_js_1.TOOL_PREFIX}list_projects`)).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
(0, vitest_1.it)('legacy:stateless still serves initialize clients on the same factory', async () => {
|
|
75
|
+
const contextProvider = createStubContextProvider();
|
|
76
|
+
handler = (0, server_1.createMcpHandler)(() => (0, server_js_1.createLightdashMcpServer)(contextProvider), {
|
|
77
|
+
legacy: 'stateless',
|
|
78
|
+
});
|
|
79
|
+
// Default Client connects legacy (initialize handshake).
|
|
80
|
+
mcpClient = new client_1.Client({ name: 'protocol-contract-legacy-http', version: '0.0.0' });
|
|
81
|
+
await connectViaHandlerFetch(handler, mcpClient);
|
|
82
|
+
(0, vitest_1.expect)(mcpClient.getProtocolEra()).toBe('legacy');
|
|
83
|
+
const { tools } = await mcpClient.listTools();
|
|
84
|
+
(0, vitest_1.expect)(tools).toHaveLength(EXPECTED_TOOL_COUNT);
|
|
85
|
+
(0, vitest_1.expect)(tools.some((t) => t.name === `${shared_js_1.TOOL_PREFIX}list_projects`)).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Register tools / prompts / resources for a
|
|
2
|
+
* Register tools / prompts / resources for a profile.
|
|
3
3
|
*/
|
|
4
4
|
import type { McpContextProvider } from './request-context.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ProfileDefinition } from '../profiles/types.js';
|
|
6
6
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
7
7
|
export type RegisterCapabilitiesOptions = {
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/** Profile to register (defaults to {@link getDefaultProfile}). */
|
|
9
|
+
profile?: ProfileDefinition;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* Registers MCP capabilities for the given
|
|
13
|
-
* Tools come from the
|
|
12
|
+
* Registers MCP capabilities for the given profile.
|
|
13
|
+
* Tools come from the operation catalog via listMcpToolNamesByProfile (ADR-0006).
|
|
14
14
|
*/
|
|
15
15
|
export declare function registerCapabilities(server: McpServer, contextProvider: McpContextProvider, options?: RegisterCapabilitiesOptions): void;
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Register tools / prompts / resources for a
|
|
3
|
+
* Register tools / prompts / resources for a profile.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerCapabilities = registerCapabilities;
|
|
7
|
-
const
|
|
7
|
+
const common_1 = require("@lightdash-tools/common");
|
|
8
|
+
const server_profile_js_1 = require("../audit/server-profile.js");
|
|
9
|
+
const index_js_1 = require("../profiles/index.js");
|
|
8
10
|
const registry_js_1 = require("../tools/registry.js");
|
|
9
11
|
/**
|
|
10
|
-
* Registers MCP capabilities for the given
|
|
11
|
-
* Tools come from the
|
|
12
|
+
* Registers MCP capabilities for the given profile.
|
|
13
|
+
* Tools come from the operation catalog via listMcpToolNamesByProfile (ADR-0006).
|
|
12
14
|
*/
|
|
13
15
|
function registerCapabilities(server, contextProvider, options) {
|
|
14
16
|
var _a;
|
|
15
|
-
const
|
|
16
|
-
(0,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const profile = (_a = options === null || options === void 0 ? void 0 : options.profile) !== null && _a !== void 0 ? _a : (0, index_js_1.getDefaultProfile)();
|
|
18
|
+
(0, server_profile_js_1.bindServerProfile)(server, profile.id);
|
|
19
|
+
(0, registry_js_1.registerToolsByIds)(server, contextProvider, (0, common_1.listMcpToolNamesByProfile)(profile.id));
|
|
20
|
+
profile.registerPrompts(server);
|
|
21
|
+
profile.registerResources(server);
|
|
19
22
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_1 = require("@lightdash-tools/common");
|
|
3
4
|
const server_1 = require("@modelcontextprotocol/server");
|
|
4
5
|
const vitest_1 = require("vitest");
|
|
5
|
-
const
|
|
6
|
+
const server_profile_js_1 = require("../audit/server-profile.js");
|
|
7
|
+
const index_js_1 = require("../profiles/index.js");
|
|
6
8
|
const registry_js_1 = require("../tools/registry.js");
|
|
7
9
|
const capabilities_js_1 = require("./capabilities.js");
|
|
8
10
|
vitest_1.vi.mock('../tools/registry.js', async (importOriginal) => {
|
|
@@ -29,12 +31,11 @@ function createMockContextProvider(lightdashClient = {}) {
|
|
|
29
31
|
registerResourceSpy = vitest_1.vi.spyOn(server, 'registerResource');
|
|
30
32
|
vitest_1.vi.mocked(registry_js_1.registerToolsByIds).mockClear();
|
|
31
33
|
});
|
|
32
|
-
(0, vitest_1.it)('registers
|
|
33
|
-
const
|
|
34
|
-
(0, capabilities_js_1.registerCapabilities)(server, mockContextProvider, {
|
|
35
|
-
(0, vitest_1.expect)(
|
|
36
|
-
|
|
37
|
-
});
|
|
34
|
+
(0, vitest_1.it)('registers catalog tools and prompts/resources for the profile', () => {
|
|
35
|
+
const profile = (0, index_js_1.getDefaultProfile)();
|
|
36
|
+
(0, capabilities_js_1.registerCapabilities)(server, mockContextProvider, { profile });
|
|
37
|
+
(0, vitest_1.expect)((0, server_profile_js_1.getServerProfile)(server)).toBe(profile.id);
|
|
38
|
+
(0, vitest_1.expect)(registry_js_1.registerToolsByIds).toHaveBeenCalledWith(server, mockContextProvider, (0, common_1.listMcpToolNamesByProfile)(profile.id));
|
|
38
39
|
(0, vitest_1.expect)(registerPromptSpy).toHaveBeenCalled();
|
|
39
40
|
(0, vitest_1.expect)(registerResourceSpy).toHaveBeenCalled();
|
|
40
41
|
});
|
package/dist/server/server.js
CHANGED
|
@@ -2,27 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLightdashMcpServer = createLightdashMcpServer;
|
|
4
4
|
const server_1 = require("@modelcontextprotocol/server");
|
|
5
|
+
const request_state_key_js_1 = require("../auth/request-state-key.js");
|
|
5
6
|
const request_state_js_1 = require("../destructive/request-state.js");
|
|
6
|
-
const index_js_1 = require("../
|
|
7
|
+
const index_js_1 = require("../profiles/index.js");
|
|
7
8
|
const capabilities_js_1 = require("./capabilities.js");
|
|
8
9
|
const version_js_1 = require("./version.js");
|
|
9
10
|
function createLightdashMcpServer(contextProvider, options) {
|
|
10
11
|
var _a;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
const profile = (_a = options === null || options === void 0 ? void 0 : options.profile) !== null && _a !== void 0 ? _a : (0, index_js_1.getDefaultProfile)();
|
|
13
|
+
if (profile.id === 'content-governance') {
|
|
14
|
+
(0, request_state_key_js_1.assertRequestStateKeyConfigured)(request_state_key_js_1.DESTRUCTIVE_REQUEST_STATE_KEY_PURPOSE);
|
|
15
|
+
}
|
|
16
|
+
else if (profile.id === 'content-developer') {
|
|
17
|
+
(0, request_state_key_js_1.assertRequestStateKeyConfigured)(request_state_key_js_1.PREVIEW_TOKEN_KEY_PURPOSE);
|
|
18
|
+
}
|
|
19
|
+
const serverOptions = profile.id === 'content-governance'
|
|
20
|
+
? {
|
|
21
|
+
requestState: {
|
|
22
|
+
verify: (state, ctx) => (0, request_state_js_1.getDestructiveRequestStateCodec)().verify(state, ctx),
|
|
23
|
+
},
|
|
24
|
+
}
|
|
21
25
|
: undefined;
|
|
22
26
|
const server = new server_1.McpServer({
|
|
23
|
-
name: (0, index_js_1.
|
|
27
|
+
name: (0, index_js_1.getProfileServerName)(profile),
|
|
24
28
|
version: version_js_1.PACKAGE_VERSION,
|
|
25
29
|
}, serverOptions);
|
|
26
|
-
(0, capabilities_js_1.registerCapabilities)(server, contextProvider, Object.assign(Object.assign({}, options), {
|
|
30
|
+
(0, capabilities_js_1.registerCapabilities)(server, contextProvider, Object.assign(Object.assign({}, options), { profile }));
|
|
27
31
|
return server;
|
|
28
32
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map uncaught Lightdash client / runtime errors to stable MCP tool error codes.
|
|
3
|
+
* Used by wrapTool catch — tool execution errors (isError), not JSON-RPC protocol errors.
|
|
4
|
+
*
|
|
5
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling
|
|
6
|
+
*/
|
|
7
|
+
/** Stable codes for uncaught upstream failures (not policy-blocked). */
|
|
8
|
+
export type UpstreamErrorCode = 'IMAGE_TOO_LARGE' | 'RATE_LIMITED' | 'UPSTREAM_CLIENT_ERROR' | 'UPSTREAM_CONTRACT' | 'UPSTREAM_FORBIDDEN' | 'UPSTREAM_NOT_FOUND' | 'UPSTREAM_TRANSIENT' | 'UPSTREAM_UNKNOWN' | 'UPSTREAM_UNSUPPORTED' | 'UPSTREAM_VALIDATION';
|
|
9
|
+
export type ClassifiedUpstreamError = {
|
|
10
|
+
code: UpstreamErrorCode;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Classify an unknown throw into `{ code, message }` for MCP tool error results.
|
|
15
|
+
* Message text is sanitized via `toMcpErrorMessage` (no stacks/tokens).
|
|
16
|
+
*/
|
|
17
|
+
export declare function classifyUpstreamError(err: unknown): ClassifiedUpstreamError;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Map uncaught Lightdash client / runtime errors to stable MCP tool error codes.
|
|
4
|
+
* Used by wrapTool catch — tool execution errors (isError), not JSON-RPC protocol errors.
|
|
5
|
+
*
|
|
6
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.classifyUpstreamError = classifyUpstreamError;
|
|
10
|
+
const client_1 = require("@lightdash-tools/client");
|
|
11
|
+
const errors_js_1 = require("./errors.js");
|
|
12
|
+
function classifyLightdashApiError(err) {
|
|
13
|
+
var _a;
|
|
14
|
+
if (((_a = err.error) === null || _a === void 0 ? void 0 : _a.name) === client_1.CONTRACT_ERROR_NAME) {
|
|
15
|
+
return 'UPSTREAM_CONTRACT';
|
|
16
|
+
}
|
|
17
|
+
const status = err.statusCode;
|
|
18
|
+
if (status === 429) {
|
|
19
|
+
return 'RATE_LIMITED';
|
|
20
|
+
}
|
|
21
|
+
if (status === 501) {
|
|
22
|
+
return 'UPSTREAM_UNSUPPORTED';
|
|
23
|
+
}
|
|
24
|
+
if (status === 408 || status >= 500) {
|
|
25
|
+
return 'UPSTREAM_TRANSIENT';
|
|
26
|
+
}
|
|
27
|
+
if (status === 404) {
|
|
28
|
+
return 'UPSTREAM_NOT_FOUND';
|
|
29
|
+
}
|
|
30
|
+
if (status === 403) {
|
|
31
|
+
return 'UPSTREAM_FORBIDDEN';
|
|
32
|
+
}
|
|
33
|
+
if (status === 400 || status === 422) {
|
|
34
|
+
return 'UPSTREAM_VALIDATION';
|
|
35
|
+
}
|
|
36
|
+
if (status >= 400 && status < 500) {
|
|
37
|
+
return 'UPSTREAM_CLIENT_ERROR';
|
|
38
|
+
}
|
|
39
|
+
return 'UPSTREAM_UNKNOWN';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Classify an unknown throw into `{ code, message }` for MCP tool error results.
|
|
43
|
+
* Message text is sanitized via `toMcpErrorMessage` (no stacks/tokens).
|
|
44
|
+
*/
|
|
45
|
+
function classifyUpstreamError(err) {
|
|
46
|
+
const message = (0, errors_js_1.toMcpErrorMessage)(err);
|
|
47
|
+
if (err instanceof client_1.RateLimitError) {
|
|
48
|
+
return { code: 'RATE_LIMITED', message };
|
|
49
|
+
}
|
|
50
|
+
if (err instanceof client_1.NetworkError) {
|
|
51
|
+
return { code: 'UPSTREAM_TRANSIENT', message };
|
|
52
|
+
}
|
|
53
|
+
if (err instanceof client_1.ChartImageSizeError) {
|
|
54
|
+
return { code: 'IMAGE_TOO_LARGE', message };
|
|
55
|
+
}
|
|
56
|
+
if (err instanceof client_1.LightdashApiError) {
|
|
57
|
+
return { code: classifyLightdashApiError(err), message };
|
|
58
|
+
}
|
|
59
|
+
return { code: 'UPSTREAM_UNKNOWN', message };
|
|
60
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_1 = require("@lightdash-tools/client");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const upstream_errors_js_1 = require("./upstream-errors.js");
|
|
6
|
+
const emptyRequest = {};
|
|
7
|
+
function apiError(statusCode, message, name = 'ApiError') {
|
|
8
|
+
return new client_1.LightdashApiError(statusCode, { name, statusCode, message }, emptyRequest);
|
|
9
|
+
}
|
|
10
|
+
(0, vitest_1.describe)('classifyUpstreamError', () => {
|
|
11
|
+
(0, vitest_1.it)('maps 404 to UPSTREAM_NOT_FOUND', () => {
|
|
12
|
+
const result = (0, upstream_errors_js_1.classifyUpstreamError)(apiError(404, 'missing'));
|
|
13
|
+
(0, vitest_1.expect)(result.code).toBe('UPSTREAM_NOT_FOUND');
|
|
14
|
+
(0, vitest_1.expect)(result.message).toContain('missing');
|
|
15
|
+
});
|
|
16
|
+
(0, vitest_1.it)('maps 400 and 422 to UPSTREAM_VALIDATION', () => {
|
|
17
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(apiError(400, 'bad')).code).toBe('UPSTREAM_VALIDATION');
|
|
18
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(apiError(422, 'invalid')).code).toBe('UPSTREAM_VALIDATION');
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.it)('maps 503 and 408 to UPSTREAM_TRANSIENT', () => {
|
|
21
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(apiError(503, 'down')).code).toBe('UPSTREAM_TRANSIENT');
|
|
22
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(apiError(408, 'timeout')).code).toBe('UPSTREAM_TRANSIENT');
|
|
23
|
+
});
|
|
24
|
+
(0, vitest_1.it)('maps NetworkError to UPSTREAM_TRANSIENT', () => {
|
|
25
|
+
const result = (0, upstream_errors_js_1.classifyUpstreamError)(new client_1.NetworkError('ECONNRESET', new Error('reset')));
|
|
26
|
+
(0, vitest_1.expect)(result.code).toBe('UPSTREAM_TRANSIENT');
|
|
27
|
+
(0, vitest_1.expect)(result.message).toContain('ECONNRESET');
|
|
28
|
+
});
|
|
29
|
+
(0, vitest_1.it)('maps RateLimitError and 429 to RATE_LIMITED', () => {
|
|
30
|
+
const limited = new client_1.RateLimitError(429, { name: 'RateLimit', statusCode: 429, message: 'slow down' }, emptyRequest, undefined, 30);
|
|
31
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(limited).code).toBe('RATE_LIMITED');
|
|
32
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(apiError(429, 'too many')).code).toBe('RATE_LIMITED');
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.it)('maps 403 / 501 / other 4xx', () => {
|
|
35
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(apiError(403, 'no')).code).toBe('UPSTREAM_FORBIDDEN');
|
|
36
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(apiError(501, 'nope')).code).toBe('UPSTREAM_UNSUPPORTED');
|
|
37
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(apiError(409, 'conflict')).code).toBe('UPSTREAM_CLIENT_ERROR');
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.it)('maps ContractError name to UPSTREAM_CONTRACT', () => {
|
|
40
|
+
const result = (0, upstream_errors_js_1.classifyUpstreamError)(apiError(502, 'Unexpected Lightdash API response shape', client_1.CONTRACT_ERROR_NAME));
|
|
41
|
+
(0, vitest_1.expect)(result.code).toBe('UPSTREAM_CONTRACT');
|
|
42
|
+
});
|
|
43
|
+
(0, vitest_1.it)('maps ChartImageSizeError to IMAGE_TOO_LARGE', () => {
|
|
44
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(new client_1.ChartImageSizeError(50, 100)).code).toBe('IMAGE_TOO_LARGE');
|
|
45
|
+
});
|
|
46
|
+
(0, vitest_1.it)('maps unknown throws to UPSTREAM_UNKNOWN', () => {
|
|
47
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)(new Error('boom')).code).toBe('UPSTREAM_UNKNOWN');
|
|
48
|
+
(0, vitest_1.expect)((0, upstream_errors_js_1.classifyUpstreamError)('string-fail').code).toBe('UPSTREAM_UNKNOWN');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -9,11 +9,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
*/
|
|
10
10
|
const node_child_process_1 = require("node:child_process");
|
|
11
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const common_1 = require("@lightdash-tools/common");
|
|
13
|
+
const server_1 = require("@modelcontextprotocol/server");
|
|
12
14
|
const vitest_1 = require("vitest");
|
|
15
|
+
const shared_js_1 = require("./tools/shared.js");
|
|
13
16
|
/** Vitest runs from the monorepo root (`vitest.config.ts`). */
|
|
14
17
|
const repoRoot = process.cwd();
|
|
15
18
|
const binPath = node_path_1.default.join(repoRoot, 'packages/mcp/dist/bin.js');
|
|
16
19
|
const INIT_TIMEOUT_MS = 5000;
|
|
20
|
+
const SEMANTIC_LAYER_TOOL_COUNT = (0, common_1.listMcpToolNamesByProfile)('semantic-layer').length;
|
|
17
21
|
function writeLine(child, message) {
|
|
18
22
|
child.stdin.write(`${JSON.stringify(message)}\n`);
|
|
19
23
|
}
|
|
@@ -73,12 +77,62 @@ function killChild(child) {
|
|
|
73
77
|
killChild(child);
|
|
74
78
|
child = undefined;
|
|
75
79
|
});
|
|
80
|
+
(0, vitest_1.it)('server/discover then tools/list over stdio (modern era)', async () => {
|
|
81
|
+
var _a;
|
|
82
|
+
let stderr = '';
|
|
83
|
+
child = (0, node_child_process_1.spawn)(process.execPath, [binPath], {
|
|
84
|
+
cwd: repoRoot,
|
|
85
|
+
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'semantic-layer', LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
|
|
86
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
87
|
+
});
|
|
88
|
+
child.stderr.setEncoding('utf8');
|
|
89
|
+
child.stderr.on('data', (chunk) => {
|
|
90
|
+
stderr += chunk;
|
|
91
|
+
});
|
|
92
|
+
const modernMeta = {
|
|
93
|
+
[server_1.PROTOCOL_VERSION_META_KEY]: '2026-07-28',
|
|
94
|
+
[server_1.CLIENT_INFO_META_KEY]: {
|
|
95
|
+
name: 'stdio-process-smoke-modern',
|
|
96
|
+
version: '0.0.0',
|
|
97
|
+
},
|
|
98
|
+
[server_1.CLIENT_CAPABILITIES_META_KEY]: {},
|
|
99
|
+
};
|
|
100
|
+
writeLine(child, {
|
|
101
|
+
jsonrpc: '2.0',
|
|
102
|
+
id: 1,
|
|
103
|
+
method: 'server/discover',
|
|
104
|
+
params: { _meta: modernMeta },
|
|
105
|
+
});
|
|
106
|
+
const discoverResponse = await readJsonRpcResponse(child, 1, INIT_TIMEOUT_MS, () => stderr);
|
|
107
|
+
(0, vitest_1.expect)(discoverResponse.error).toBeUndefined();
|
|
108
|
+
(0, vitest_1.expect)(discoverResponse.result).toBeDefined();
|
|
109
|
+
const discoverResult = discoverResponse.result;
|
|
110
|
+
(0, vitest_1.expect)(discoverResult.supportedVersions).toContain('2026-07-28');
|
|
111
|
+
(0, vitest_1.expect)((_a = discoverResult.capabilities) === null || _a === void 0 ? void 0 : _a.tools).toBeDefined();
|
|
112
|
+
writeLine(child, {
|
|
113
|
+
jsonrpc: '2.0',
|
|
114
|
+
id: 2,
|
|
115
|
+
method: 'tools/list',
|
|
116
|
+
params: { _meta: modernMeta },
|
|
117
|
+
});
|
|
118
|
+
const listResponse = await readJsonRpcResponse(child, 2, INIT_TIMEOUT_MS, () => stderr);
|
|
119
|
+
(0, vitest_1.expect)(listResponse.error).toBeUndefined();
|
|
120
|
+
(0, vitest_1.expect)(listResponse.result).toMatchObject({
|
|
121
|
+
tools: vitest_1.expect.arrayContaining([
|
|
122
|
+
vitest_1.expect.objectContaining({ name: `${shared_js_1.TOOL_PREFIX}list_projects` }),
|
|
123
|
+
]),
|
|
124
|
+
});
|
|
125
|
+
const listResult = listResponse.result;
|
|
126
|
+
(0, vitest_1.expect)(listResult.tools).toHaveLength(SEMANTIC_LAYER_TOOL_COUNT);
|
|
127
|
+
killChild(child);
|
|
128
|
+
child = undefined;
|
|
129
|
+
});
|
|
76
130
|
(0, vitest_1.it)('initialize then tools/list over stdio', async () => {
|
|
77
131
|
var _a;
|
|
78
132
|
let stderr = '';
|
|
79
133
|
child = (0, node_child_process_1.spawn)(process.execPath, [binPath], {
|
|
80
134
|
cwd: repoRoot,
|
|
81
|
-
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke',
|
|
135
|
+
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'semantic-layer',
|
|
82
136
|
// Avoid inheriting real credentials or network-affecting settings.
|
|
83
137
|
LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
|
|
84
138
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
@@ -123,12 +177,12 @@ function killChild(child) {
|
|
|
123
177
|
killChild(child);
|
|
124
178
|
child = undefined;
|
|
125
179
|
});
|
|
126
|
-
(0, vitest_1.it)('initialize then tools/list for content-reader
|
|
180
|
+
(0, vitest_1.it)('initialize then tools/list for content-reader profile', async () => {
|
|
127
181
|
var _a;
|
|
128
182
|
let stderr = '';
|
|
129
183
|
child = (0, node_child_process_1.spawn)(process.execPath, [binPath, 'content-reader'], {
|
|
130
184
|
cwd: repoRoot,
|
|
131
|
-
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke',
|
|
185
|
+
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'content-reader', LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
|
|
132
186
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
133
187
|
});
|
|
134
188
|
child.stderr.setEncoding('utf8');
|
|
@@ -165,18 +219,19 @@ function killChild(child) {
|
|
|
165
219
|
(0, vitest_1.expect)(listResponse.error).toBeUndefined();
|
|
166
220
|
const listResult = listResponse.result;
|
|
167
221
|
(0, vitest_1.expect)(Array.isArray(listResult.tools)).toBe(true);
|
|
168
|
-
(0, vitest_1.expect)(listResult.tools).toHaveLength(
|
|
222
|
+
(0, vitest_1.expect)(listResult.tools).toHaveLength(14);
|
|
169
223
|
(0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_search_content')).toBe(true);
|
|
170
224
|
(0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_run_chart')).toBe(true);
|
|
225
|
+
(0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_export_chart_image')).toBe(true);
|
|
171
226
|
killChild(child);
|
|
172
227
|
child = undefined;
|
|
173
228
|
});
|
|
174
|
-
(0, vitest_1.it)('initialize then tools/list for content-governance
|
|
229
|
+
(0, vitest_1.it)('initialize then tools/list for content-governance profile', async () => {
|
|
175
230
|
var _a;
|
|
176
231
|
let stderr = '';
|
|
177
232
|
child = (0, node_child_process_1.spawn)(process.execPath, [binPath, 'content-governance'], {
|
|
178
233
|
cwd: repoRoot,
|
|
179
|
-
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke',
|
|
234
|
+
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'content-governance', LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
|
|
180
235
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
181
236
|
});
|
|
182
237
|
child.stderr.setEncoding('utf8');
|
|
@@ -223,12 +278,12 @@ function killChild(child) {
|
|
|
223
278
|
killChild(child);
|
|
224
279
|
child = undefined;
|
|
225
280
|
});
|
|
226
|
-
(0, vitest_1.it)('initialize then tools/list for content-developer
|
|
281
|
+
(0, vitest_1.it)('initialize then tools/list for content-developer profile', async () => {
|
|
227
282
|
var _a;
|
|
228
283
|
let stderr = '';
|
|
229
284
|
child = (0, node_child_process_1.spawn)(process.execPath, [binPath, 'content-developer'], {
|
|
230
285
|
cwd: repoRoot,
|
|
231
|
-
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke',
|
|
286
|
+
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'content-developer', LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
|
|
232
287
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
233
288
|
});
|
|
234
289
|
child.stderr.setEncoding('utf8');
|
|
@@ -265,7 +320,8 @@ function killChild(child) {
|
|
|
265
320
|
(0, vitest_1.expect)(listResponse.error).toBeUndefined();
|
|
266
321
|
const listResult = listResponse.result;
|
|
267
322
|
(0, vitest_1.expect)(Array.isArray(listResult.tools)).toBe(true);
|
|
268
|
-
(0, vitest_1.expect)(listResult.tools).toHaveLength(
|
|
323
|
+
(0, vitest_1.expect)(listResult.tools).toHaveLength(26);
|
|
324
|
+
(0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_get_chart_as_code')).toBe(true);
|
|
269
325
|
(0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_preview_dashboard_changes')).toBe(true);
|
|
270
326
|
(0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_move_content')).toBe(true);
|
|
271
327
|
killChild(child);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project AI agent inventory tools (ai-agent-ops profile).
|
|
3
|
+
*/
|
|
4
|
+
import type { McpContextProvider } from '../../server/request-context.js';
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
|
+
export declare function registerListProjectAgents(server: McpServer, contextProvider: McpContextProvider): void;
|
|
7
|
+
export declare function registerGetProjectAgent(server: McpServer, contextProvider: McpContextProvider): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Project AI agent inventory tools (ai-agent-ops profile).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerListProjectAgents = registerListProjectAgents;
|
|
7
|
+
exports.registerGetProjectAgent = registerGetProjectAgent;
|
|
8
|
+
const shared_js_1 = require("../shared.js");
|
|
9
|
+
const helpers_js_1 = require("./helpers.js");
|
|
10
|
+
function registerListProjectAgents(server, contextProvider) {
|
|
11
|
+
(0, shared_js_1.registerToolSafe)(server, 'list_project_agents', {
|
|
12
|
+
title: 'List project AI agents',
|
|
13
|
+
description: 'List AI agents in the resolved project (project-scoped API).',
|
|
14
|
+
inputSchema: { projectUuid: (0, helpers_js_1.optionalProjectUuidField)() },
|
|
15
|
+
annotations: shared_js_1.READ_ONLY_DEFAULT,
|
|
16
|
+
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async ({ projectUuid }) => (0, helpers_js_1.withAgentOpsScope)(projectUuid, async (scope) => ({
|
|
17
|
+
data: await c.v1.aiAgents.listAgents(scope.projectUuid),
|
|
18
|
+
}))));
|
|
19
|
+
}
|
|
20
|
+
function registerGetProjectAgent(server, contextProvider) {
|
|
21
|
+
(0, shared_js_1.registerToolSafe)(server, 'get_project_agent', {
|
|
22
|
+
title: 'Get project AI agent',
|
|
23
|
+
description: 'Get a single AI agent configuration in the resolved project.',
|
|
24
|
+
inputSchema: {
|
|
25
|
+
projectUuid: (0, helpers_js_1.optionalProjectUuidField)(),
|
|
26
|
+
agentUuid: (0, helpers_js_1.agentUuidField)(),
|
|
27
|
+
},
|
|
28
|
+
annotations: shared_js_1.READ_ONLY_DEFAULT,
|
|
29
|
+
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async ({ projectUuid, agentUuid }) => (0, helpers_js_1.withAgentOpsScope)(projectUuid, async (scope) => ({
|
|
30
|
+
data: await c.v1.aiAgents.getAgent(scope.projectUuid, agentUuid),
|
|
31
|
+
}))));
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|