@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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Unit tests for promote upstream allowlist (ADR-0008 / ADR-0017).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const common_1 = require("@lightdash-tools/common");
|
|
7
|
+
const vitest_1 = require("vitest");
|
|
8
|
+
const available_projects_js_1 = require("./available-projects.js");
|
|
9
|
+
const project_scope_js_1 = require("./project-scope.js");
|
|
10
|
+
const promote_allowlist_js_1 = require("./promote-allowlist.js");
|
|
11
|
+
const SOURCE = 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa';
|
|
12
|
+
const UPSTREAM = 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb';
|
|
13
|
+
const OTHER = 'cccccccc-cccc-4ccc-8ccc-cccccccccccc';
|
|
14
|
+
function emptyDiff() {
|
|
15
|
+
return { charts: [], dashboards: [], spaces: [] };
|
|
16
|
+
}
|
|
17
|
+
(0, vitest_1.describe)('promote-allowlist', () => {
|
|
18
|
+
(0, vitest_1.afterEach)(() => {
|
|
19
|
+
delete process.env[common_1.ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS];
|
|
20
|
+
(0, available_projects_js_1.resetAvailableProjectsCache)();
|
|
21
|
+
});
|
|
22
|
+
(0, vitest_1.describe)('extractPromoteDiffProjectUuids', () => {
|
|
23
|
+
(0, vitest_1.it)('collects unique projectUuid values from nested items', () => {
|
|
24
|
+
const diff = {
|
|
25
|
+
charts: [{ data: { projectUuid: UPSTREAM, name: 'c' }, action: 'create' }],
|
|
26
|
+
dashboards: [
|
|
27
|
+
{ data: { projectUuid: UPSTREAM, name: 'd' }, action: 'update' },
|
|
28
|
+
{ data: { projectUuid: OTHER, name: 'd2' }, action: 'create' },
|
|
29
|
+
],
|
|
30
|
+
spaces: [{ data: { projectUuid: SOURCE, name: 's' }, action: 'create' }],
|
|
31
|
+
sqlCharts: [{ data: { projectUuid: UPSTREAM, name: 'sql' }, action: 'create' }],
|
|
32
|
+
};
|
|
33
|
+
(0, vitest_1.expect)((0, promote_allowlist_js_1.extractPromoteDiffProjectUuids)(diff).sort()).toEqual([OTHER, SOURCE, UPSTREAM].sort());
|
|
34
|
+
});
|
|
35
|
+
(0, vitest_1.it)('ignores rows without projectUuid', () => {
|
|
36
|
+
(0, vitest_1.expect)((0, promote_allowlist_js_1.extractPromoteDiffProjectUuids)({
|
|
37
|
+
charts: [{ data: { name: 'c' }, action: 'create' }],
|
|
38
|
+
dashboards: [],
|
|
39
|
+
spaces: [],
|
|
40
|
+
})).toEqual([]);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
(0, vitest_1.describe)('assertPromoteTargetsAllowlisted', () => {
|
|
44
|
+
(0, vitest_1.it)('is a no-op when allowlist is unrestricted', () => {
|
|
45
|
+
(0, vitest_1.expect)(() => (0, promote_allowlist_js_1.assertPromoteTargetsAllowlisted)({
|
|
46
|
+
upstreamProjectUuid: UPSTREAM,
|
|
47
|
+
promoteDiff: emptyDiff(),
|
|
48
|
+
})).not.toThrow();
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.it)('allows upstream that is in the allowlist', () => {
|
|
51
|
+
process.env[common_1.ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS] = `${SOURCE},${UPSTREAM}`;
|
|
52
|
+
(0, vitest_1.expect)(() => (0, promote_allowlist_js_1.assertPromoteTargetsAllowlisted)({
|
|
53
|
+
upstreamProjectUuid: UPSTREAM,
|
|
54
|
+
promoteDiff: emptyDiff(),
|
|
55
|
+
})).not.toThrow();
|
|
56
|
+
});
|
|
57
|
+
(0, vitest_1.it)('rejects upstream outside the allowlist', () => {
|
|
58
|
+
process.env[common_1.ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS] = SOURCE;
|
|
59
|
+
(0, vitest_1.expect)(() => (0, promote_allowlist_js_1.assertPromoteTargetsAllowlisted)({
|
|
60
|
+
upstreamProjectUuid: UPSTREAM,
|
|
61
|
+
promoteDiff: emptyDiff(),
|
|
62
|
+
})).toThrow(project_scope_js_1.ProjectScopeError);
|
|
63
|
+
(0, vitest_1.expect)(() => (0, promote_allowlist_js_1.assertPromoteTargetsAllowlisted)({
|
|
64
|
+
upstreamProjectUuid: UPSTREAM,
|
|
65
|
+
promoteDiff: emptyDiff(),
|
|
66
|
+
})).toThrow(/PROJECT_NOT_AVAILABLE|not in LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS/);
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.it)('rejects promoteDiff projectUuid outside the allowlist', () => {
|
|
69
|
+
process.env[common_1.ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS] = SOURCE;
|
|
70
|
+
(0, vitest_1.expect)(() => (0, promote_allowlist_js_1.assertPromoteTargetsAllowlisted)({
|
|
71
|
+
upstreamProjectUuid: SOURCE,
|
|
72
|
+
promoteDiff: {
|
|
73
|
+
charts: [{ data: { projectUuid: OTHER, name: 'c' }, action: 'create' }],
|
|
74
|
+
dashboards: [],
|
|
75
|
+
spaces: [],
|
|
76
|
+
},
|
|
77
|
+
})).toThrow(/not in LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS/);
|
|
78
|
+
});
|
|
79
|
+
(0, vitest_1.it)('fails closed when restricted and no target UUID is known', () => {
|
|
80
|
+
process.env[common_1.ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS] = SOURCE;
|
|
81
|
+
(0, vitest_1.expect)(() => (0, promote_allowlist_js_1.assertPromoteTargetsAllowlisted)({
|
|
82
|
+
upstreamProjectUuid: undefined,
|
|
83
|
+
promoteDiff: emptyDiff(),
|
|
84
|
+
})).toThrow(/Cannot determine upstream project/);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -2,24 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const node_http_1 = require("node:http");
|
|
4
4
|
const client_1 = require("@lightdash-tools/client");
|
|
5
|
+
const server_1 = require("@modelcontextprotocol/server");
|
|
5
6
|
const vitest_1 = require("vitest");
|
|
6
7
|
const oauth_protected_resource_js_1 = require("./auth/resource-server/oauth-protected-resource.js");
|
|
7
8
|
const streamable_http_js_1 = require("./transports/streamable-http.js");
|
|
8
9
|
const TOKEN_A = scopedAccessToken('mcp:read mcp:write', 'token-a');
|
|
9
10
|
const TOKEN_B = scopedAccessToken('mcp:read mcp:write', 'token-b');
|
|
10
|
-
const TOKEN_A_REFRESHED = scopedAccessToken('mcp:read mcp:write', 'token-a-refreshed');
|
|
11
11
|
const TOKEN_READ_ONLY = scopedAccessToken('mcp:read', 'token-read-only');
|
|
12
12
|
const OPAQUE_TOKEN_A = 'opaque-token-user-a';
|
|
13
|
-
const OPAQUE_TOKEN_ORG_B = 'opaque-token-org-b';
|
|
14
|
-
const OPAQUE_TOKEN_A_NO_ORG = 'opaque-token-user-a-no-org';
|
|
15
13
|
const USER_A = { userUuid: 'user-a-uuid', email: 'a@example.com', organizationUuid: 'org-a-uuid' };
|
|
16
14
|
const USER_B = { userUuid: 'user-b-uuid', email: 'b@example.com', organizationUuid: 'org-b-uuid' };
|
|
17
|
-
const USER_A_ORG_B = {
|
|
18
|
-
userUuid: 'user-a-uuid',
|
|
19
|
-
email: 'a@example.com',
|
|
20
|
-
organizationUuid: 'org-b-uuid',
|
|
21
|
-
};
|
|
22
|
-
const USER_A_NO_ORG = { userUuid: 'user-a-uuid', email: 'a@example.com' };
|
|
23
15
|
function scopedAccessToken(scope, subject) {
|
|
24
16
|
const header = Buffer.from(JSON.stringify({ alg: 'none', typ: 'JWT' })).toString('base64url');
|
|
25
17
|
const payload = Buffer.from(JSON.stringify({ scope, sub: subject })).toString('base64url');
|
|
@@ -48,12 +40,9 @@ async function startMockLightdashServer() {
|
|
|
48
40
|
const authorizationHeaders = [];
|
|
49
41
|
const users = {
|
|
50
42
|
[TOKEN_A]: USER_A,
|
|
51
|
-
[TOKEN_A_REFRESHED]: USER_A,
|
|
52
43
|
[TOKEN_B]: USER_B,
|
|
53
44
|
[TOKEN_READ_ONLY]: USER_A,
|
|
54
45
|
[OPAQUE_TOKEN_A]: USER_A,
|
|
55
|
-
[OPAQUE_TOKEN_ORG_B]: USER_A_ORG_B,
|
|
56
|
-
[OPAQUE_TOKEN_A_NO_ORG]: USER_A_NO_ORG,
|
|
57
46
|
};
|
|
58
47
|
let issuerBaseUrl = '';
|
|
59
48
|
const server = (0, node_http_1.createServer)((req, res) => {
|
|
@@ -138,10 +127,6 @@ function baseOAuthConfig(lightdashUrl) {
|
|
|
138
127
|
oauthClientSecret: new client_1.SecretString('test-client-secret'),
|
|
139
128
|
allowedOrigins: [],
|
|
140
129
|
maxBodyBytes: 1024 * 1024,
|
|
141
|
-
sessionTtlMs: 60000,
|
|
142
|
-
maxSessions: 10,
|
|
143
|
-
maxSessionsPerSubject: 10,
|
|
144
|
-
sessionCleanupMs: 60000,
|
|
145
130
|
requiredScopes: [],
|
|
146
131
|
scopesSupported: [],
|
|
147
132
|
validateToken: true,
|
|
@@ -149,6 +134,7 @@ function baseOAuthConfig(lightdashUrl) {
|
|
|
149
134
|
};
|
|
150
135
|
}
|
|
151
136
|
async function postMcp(baseUrl, body, options) {
|
|
137
|
+
var _a;
|
|
152
138
|
const headers = {
|
|
153
139
|
'Content-Type': 'application/json',
|
|
154
140
|
Accept: 'application/json, text/event-stream',
|
|
@@ -156,27 +142,22 @@ async function postMcp(baseUrl, body, options) {
|
|
|
156
142
|
if (options === null || options === void 0 ? void 0 : options.token) {
|
|
157
143
|
headers.Authorization = `Bearer ${options.token}`;
|
|
158
144
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
return fetch(`${baseUrl}/semantic-layer/v1/mcp`, {
|
|
145
|
+
const path = (_a = options === null || options === void 0 ? void 0 : options.path) !== null && _a !== void 0 ? _a : '/semantic-layer/v1/mcp';
|
|
146
|
+
return fetch(`${baseUrl}${path}`, {
|
|
163
147
|
method: 'POST',
|
|
164
148
|
headers,
|
|
165
149
|
body: JSON.stringify(body),
|
|
166
150
|
});
|
|
167
151
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
152
|
+
function parseSseOrJsonToolText(raw) {
|
|
153
|
+
if (raw.includes('data:')) {
|
|
154
|
+
const lines = raw
|
|
155
|
+
.split('\n')
|
|
156
|
+
.filter((line) => line.startsWith('data:'))
|
|
157
|
+
.map((line) => line.slice('data:'.length).trim());
|
|
158
|
+
return lines.join('\n');
|
|
174
159
|
}
|
|
175
|
-
|
|
176
|
-
const last = dataLines.length > 0 ? dataLines[dataLines.length - 1] : undefined;
|
|
177
|
-
if (!last)
|
|
178
|
-
return text;
|
|
179
|
-
return JSON.parse(last.slice('data: '.length));
|
|
160
|
+
return raw;
|
|
180
161
|
}
|
|
181
162
|
(0, vitest_1.describe)('MCP HTTP OAuth integration (RFC §16.3 matrix)', () => {
|
|
182
163
|
let mockLightdash;
|
|
@@ -207,78 +188,13 @@ async function parseMcpResponse(response) {
|
|
|
207
188
|
(0, vitest_1.expect)(body).not.toContain(invalidToken);
|
|
208
189
|
(0, vitest_1.expect)(response.headers.get('www-authenticate')).toContain('invalid_token');
|
|
209
190
|
});
|
|
210
|
-
(0, vitest_1.it)('
|
|
191
|
+
(0, vitest_1.it)('handles initialize with valid OAuth bearer and validates upstream Authorization', async () => {
|
|
211
192
|
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
212
193
|
(0, vitest_1.expect)(response.status).toBe(200);
|
|
213
|
-
|
|
194
|
+
// Sessionless: no session-id header is set
|
|
195
|
+
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeFalsy();
|
|
214
196
|
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
|
|
215
197
|
});
|
|
216
|
-
(0, vitest_1.it)('returns 401 before 404 for unknown session without auth', async () => {
|
|
217
|
-
const response = await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { sessionId: 'unknown-session-id' });
|
|
218
|
-
(0, vitest_1.expect)(response.status).toBe(401);
|
|
219
|
-
(0, vitest_1.expect)(response.headers.get('www-authenticate')).toContain('resource_metadata=');
|
|
220
|
-
});
|
|
221
|
-
(0, vitest_1.it)('returns 401 Session subject mismatch when resuming with a different user bearer', async () => {
|
|
222
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
223
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
224
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
225
|
-
const resumeResponse = await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_B, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
226
|
-
(0, vitest_1.expect)(resumeResponse.status).toBe(401);
|
|
227
|
-
(0, vitest_1.expect)(await resumeResponse.json()).toEqual({
|
|
228
|
-
error: 'invalid_token',
|
|
229
|
-
error_description: 'Session subject mismatch',
|
|
230
|
-
});
|
|
231
|
-
(0, vitest_1.expect)(resumeResponse.headers.get('www-authenticate')).toContain('invalid_token');
|
|
232
|
-
});
|
|
233
|
-
(0, vitest_1.it)('returns 401 Session organization mismatch when resuming with a different org context', async () => {
|
|
234
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
235
|
-
token: OPAQUE_TOKEN_A,
|
|
236
|
-
});
|
|
237
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
238
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
239
|
-
const resumeResponse = await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: OPAQUE_TOKEN_ORG_B, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
240
|
-
(0, vitest_1.expect)(resumeResponse.status).toBe(401);
|
|
241
|
-
(0, vitest_1.expect)(await resumeResponse.json()).toEqual({
|
|
242
|
-
error: 'invalid_token',
|
|
243
|
-
error_description: 'Session organization mismatch',
|
|
244
|
-
});
|
|
245
|
-
(0, vitest_1.expect)(resumeResponse.headers.get('www-authenticate')).toContain('invalid_token');
|
|
246
|
-
});
|
|
247
|
-
(0, vitest_1.it)('returns 401 Session organization mismatch when org disappears on resume', async () => {
|
|
248
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
249
|
-
token: OPAQUE_TOKEN_A,
|
|
250
|
-
});
|
|
251
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
252
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
253
|
-
const resumeResponse = await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: OPAQUE_TOKEN_A_NO_ORG, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
254
|
-
(0, vitest_1.expect)(resumeResponse.status).toBe(401);
|
|
255
|
-
(0, vitest_1.expect)(await resumeResponse.json()).toEqual({
|
|
256
|
-
error: 'invalid_token',
|
|
257
|
-
error_description: 'Session organization mismatch',
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
(0, vitest_1.it)('protected-resource metadata authorization_servers points at MCP broker AS metadata', async () => {
|
|
261
|
-
const response = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource`);
|
|
262
|
-
(0, vitest_1.expect)(response.status).toBe(200);
|
|
263
|
-
const metadata = (await response.json());
|
|
264
|
-
(0, vitest_1.expect)(metadata.authorization_servers).toEqual([mcpServer.baseUrl]);
|
|
265
|
-
const asMetadataUrl = (0, oauth_protected_resource_js_1.getAuthorizationServerMetadataUrl)(metadata.authorization_servers[0]);
|
|
266
|
-
(0, vitest_1.expect)(asMetadataUrl).toBe(`${mcpServer.baseUrl}/.well-known/oauth-authorization-server`);
|
|
267
|
-
const asResponse = await fetch(asMetadataUrl);
|
|
268
|
-
(0, vitest_1.expect)(asResponse.status).toBe(200);
|
|
269
|
-
const asMetadata = (await asResponse.json());
|
|
270
|
-
(0, vitest_1.expect)(asMetadata.authorization_endpoint).toBe(`${mcpServer.baseUrl}/oauth/authorize`);
|
|
271
|
-
(0, vitest_1.expect)(asMetadata.token_endpoint).toBe(`${mcpServer.baseUrl}/oauth/token`);
|
|
272
|
-
(0, vitest_1.expect)(asMetadata.registration_endpoint).toBe(`${mcpServer.baseUrl}/oauth/register`);
|
|
273
|
-
});
|
|
274
|
-
(0, vitest_1.it)('allows token refresh for the same OAuth subject within a session', async () => {
|
|
275
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
276
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
277
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
278
|
-
const resumeResponse = await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_A_REFRESHED, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
279
|
-
(0, vitest_1.expect)([200, 202]).toContain(resumeResponse.status);
|
|
280
|
-
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A_REFRESHED}`);
|
|
281
|
-
});
|
|
282
198
|
(0, vitest_1.it)('returns 401 before parsing malformed JSON when OAuth token is missing', async () => {
|
|
283
199
|
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
284
200
|
method: 'POST',
|
|
@@ -346,7 +262,7 @@ async function parseMcpResponse(response) {
|
|
|
346
262
|
const metadata = await response.json();
|
|
347
263
|
(0, vitest_1.expect)(metadata.resource).toBe(`${mcpServer.baseUrl}/content-governance/v1/mcp`);
|
|
348
264
|
});
|
|
349
|
-
(0, vitest_1.it)('returns 401 with organization-audit resource_metadata on that
|
|
265
|
+
(0, vitest_1.it)('returns 401 with organization-audit resource_metadata on that profile path', async () => {
|
|
350
266
|
const response = await fetch(`${mcpServer.baseUrl}/organization-audit/v1/mcp`, {
|
|
351
267
|
method: 'POST',
|
|
352
268
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
@@ -357,7 +273,7 @@ async function parseMcpResponse(response) {
|
|
|
357
273
|
(0, vitest_1.expect)(wwwAuthenticate).toContain(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/organization-audit/v1/mcp`);
|
|
358
274
|
(0, vitest_1.expect)(wwwAuthenticate).not.toContain('semantic-layer/v1/mcp');
|
|
359
275
|
});
|
|
360
|
-
(0, vitest_1.it)('returns 401 with content-reader resource_metadata on that
|
|
276
|
+
(0, vitest_1.it)('returns 401 with content-reader resource_metadata on that profile path', async () => {
|
|
361
277
|
const response = await fetch(`${mcpServer.baseUrl}/content-reader/v1/mcp`, {
|
|
362
278
|
method: 'POST',
|
|
363
279
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
@@ -368,7 +284,7 @@ async function parseMcpResponse(response) {
|
|
|
368
284
|
(0, vitest_1.expect)(wwwAuthenticate).toContain(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/content-reader/v1/mcp`);
|
|
369
285
|
(0, vitest_1.expect)(wwwAuthenticate).not.toContain('semantic-layer/v1/mcp');
|
|
370
286
|
});
|
|
371
|
-
(0, vitest_1.it)('returns 401 with content-governance resource_metadata on that
|
|
287
|
+
(0, vitest_1.it)('returns 401 with content-governance resource_metadata on that profile path', async () => {
|
|
372
288
|
const response = await fetch(`${mcpServer.baseUrl}/content-governance/v1/mcp`, {
|
|
373
289
|
method: 'POST',
|
|
374
290
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
@@ -387,6 +303,29 @@ async function parseMcpResponse(response) {
|
|
|
387
303
|
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
|
|
388
304
|
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_B}`);
|
|
389
305
|
});
|
|
306
|
+
(0, vitest_1.it)('accepts form-elicitation caps from per-request _meta on content-governance tools/call', async () => {
|
|
307
|
+
const governancePath = '/content-governance/v1/mcp';
|
|
308
|
+
const call = await postMcp(mcpServer.baseUrl, {
|
|
309
|
+
jsonrpc: '2.0',
|
|
310
|
+
method: 'tools/call',
|
|
311
|
+
params: {
|
|
312
|
+
name: 'lightdash_delete_chart',
|
|
313
|
+
arguments: {
|
|
314
|
+
projectUuid: '11111111-1111-4111-8111-111111111111',
|
|
315
|
+
chartUuidOrSlug: '22222222-2222-4222-8222-222222222222',
|
|
316
|
+
},
|
|
317
|
+
_meta: {
|
|
318
|
+
[server_1.CLIENT_CAPABILITIES_META_KEY]: { elicitation: { form: {} } },
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
id: 2,
|
|
322
|
+
}, { token: TOKEN_A, path: governancePath });
|
|
323
|
+
(0, vitest_1.expect)(call.status).toBe(200);
|
|
324
|
+
const text = parseSseOrJsonToolText(await call.text());
|
|
325
|
+
// Per-request envelope caps: past ELICITATION_REQUIRED into chart resolve (mock has no chart).
|
|
326
|
+
(0, vitest_1.expect)(text).not.toContain('ELICITATION_REQUIRED');
|
|
327
|
+
(0, vitest_1.expect)(text).toContain('CONTENT_NOT_FOUND');
|
|
328
|
+
});
|
|
390
329
|
(0, vitest_1.it)('returns 503 when Lightdash user validation is unavailable', async () => {
|
|
391
330
|
const unavailableServer = (0, node_http_1.createServer)((_req, res) => {
|
|
392
331
|
res.writeHead(503, { 'Content-Type': 'application/json' }).end(JSON.stringify({
|
|
@@ -419,6 +358,63 @@ async function parseMcpResponse(response) {
|
|
|
419
358
|
}
|
|
420
359
|
});
|
|
421
360
|
});
|
|
361
|
+
(0, vitest_1.describe)('MCP HTTP OAuth integration (continued)', () => {
|
|
362
|
+
let mockLightdash;
|
|
363
|
+
let mcpServer;
|
|
364
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
365
|
+
vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
366
|
+
vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
367
|
+
mockLightdash = await startMockLightdashServer();
|
|
368
|
+
mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, baseOAuthConfig(mockLightdash.baseUrl)));
|
|
369
|
+
});
|
|
370
|
+
(0, vitest_1.afterEach)(async () => {
|
|
371
|
+
await mcpServer.close();
|
|
372
|
+
await mockLightdash.close();
|
|
373
|
+
vitest_1.vi.restoreAllMocks();
|
|
374
|
+
});
|
|
375
|
+
(0, vitest_1.it)('protected-resource metadata authorization_servers points at MCP broker AS metadata', async () => {
|
|
376
|
+
const response = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource`);
|
|
377
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
378
|
+
const metadata = (await response.json());
|
|
379
|
+
(0, vitest_1.expect)(metadata.authorization_servers).toEqual([mcpServer.baseUrl]);
|
|
380
|
+
const asMetadataUrl = (0, oauth_protected_resource_js_1.getAuthorizationServerMetadataUrl)(metadata.authorization_servers[0]);
|
|
381
|
+
(0, vitest_1.expect)(asMetadataUrl).toBe(`${mcpServer.baseUrl}/.well-known/oauth-authorization-server`);
|
|
382
|
+
const asResponse = await fetch(asMetadataUrl);
|
|
383
|
+
(0, vitest_1.expect)(asResponse.status).toBe(200);
|
|
384
|
+
const asMetadata = (await asResponse.json());
|
|
385
|
+
(0, vitest_1.expect)(asMetadata.authorization_endpoint).toBe(`${mcpServer.baseUrl}/oauth/authorize`);
|
|
386
|
+
(0, vitest_1.expect)(asMetadata.token_endpoint).toBe(`${mcpServer.baseUrl}/oauth/token`);
|
|
387
|
+
(0, vitest_1.expect)(asMetadata.registration_endpoint).toBe(`${mcpServer.baseUrl}/oauth/register`);
|
|
388
|
+
});
|
|
389
|
+
(0, vitest_1.it)('handles initialize with opaque OAuth bearer when endpoint scopes are unset', async () => {
|
|
390
|
+
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: OPAQUE_TOKEN_A });
|
|
391
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
392
|
+
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeFalsy();
|
|
393
|
+
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${OPAQUE_TOKEN_A}`);
|
|
394
|
+
});
|
|
395
|
+
(0, vitest_1.it)('accepts TOKEN_READ_ONLY (mcp:read scope) on initialize', async () => {
|
|
396
|
+
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
397
|
+
token: TOKEN_READ_ONLY,
|
|
398
|
+
});
|
|
399
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
400
|
+
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_READ_ONLY}`);
|
|
401
|
+
});
|
|
402
|
+
(0, vitest_1.it)('accepts TOKEN_A (mcp:read mcp:write scope) on initialize', async () => {
|
|
403
|
+
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
404
|
+
token: TOKEN_A,
|
|
405
|
+
});
|
|
406
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
407
|
+
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
|
|
408
|
+
});
|
|
409
|
+
(0, vitest_1.it)('forwards bearer token to Lightdash on initialize for opaque credentials', async () => {
|
|
410
|
+
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
411
|
+
token: OPAQUE_TOKEN_A,
|
|
412
|
+
});
|
|
413
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
414
|
+
const userHeaders = mockLightdash.authorizationHeaders.filter((h) => h === `Bearer ${OPAQUE_TOKEN_A}`);
|
|
415
|
+
(0, vitest_1.expect)(userHeaders.length).toBeGreaterThan(0);
|
|
416
|
+
});
|
|
417
|
+
});
|
|
422
418
|
(0, vitest_1.describe)('MCP HTTP CORS integration', () => {
|
|
423
419
|
let mockLightdash;
|
|
424
420
|
let mcpServer;
|
|
@@ -462,126 +458,7 @@ async function parseMcpResponse(response) {
|
|
|
462
458
|
(0, vitest_1.expect)(body.error).toContain('origin not allowed');
|
|
463
459
|
});
|
|
464
460
|
});
|
|
465
|
-
(0, vitest_1.describe)('MCP HTTP
|
|
466
|
-
let mockLightdash;
|
|
467
|
-
let mcpServer;
|
|
468
|
-
(0, vitest_1.beforeEach)(async () => {
|
|
469
|
-
vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
470
|
-
vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
471
|
-
mockLightdash = await startMockLightdashServer();
|
|
472
|
-
mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, baseOAuthConfig(mockLightdash.baseUrl)));
|
|
473
|
-
});
|
|
474
|
-
(0, vitest_1.afterEach)(async () => {
|
|
475
|
-
await mcpServer.close();
|
|
476
|
-
await mockLightdash.close();
|
|
477
|
-
vitest_1.vi.restoreAllMocks();
|
|
478
|
-
});
|
|
479
|
-
(0, vitest_1.it)('calls lightdash_list_projects over an OAuth HTTP session', async () => {
|
|
480
|
-
var _a, _b, _c, _d;
|
|
481
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
482
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
483
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
484
|
-
const userCallsBefore = mockLightdash.authorizationHeaders.length;
|
|
485
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
486
|
-
const callResponse = await postMcp(mcpServer.baseUrl, {
|
|
487
|
-
jsonrpc: '2.0',
|
|
488
|
-
method: 'tools/call',
|
|
489
|
-
params: { name: 'lightdash_list_projects', arguments: {} },
|
|
490
|
-
id: 2,
|
|
491
|
-
}, { token: TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
492
|
-
(0, vitest_1.expect)(callResponse.status).toBe(200);
|
|
493
|
-
const payload = (await parseMcpResponse(callResponse));
|
|
494
|
-
const text = (_d = (_c = (_b = (_a = payload.result) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : '';
|
|
495
|
-
(0, vitest_1.expect)(text).toContain('project-a-uuid');
|
|
496
|
-
(0, vitest_1.expect)(text).not.toContain(TOKEN_A);
|
|
497
|
-
(0, vitest_1.expect)(mockLightdash.authorizationHeaders.length).toBeGreaterThan(userCallsBefore);
|
|
498
|
-
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
|
|
499
|
-
});
|
|
500
|
-
(0, vitest_1.it)('forwards refreshed bearer token to Lightdash on tool calls after session resume', async () => {
|
|
501
|
-
var _a, _b, _c, _d;
|
|
502
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
503
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
504
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
505
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_A_REFRESHED, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
506
|
-
const headersBeforeTool = mockLightdash.authorizationHeaders.length;
|
|
507
|
-
const callResponse = await postMcp(mcpServer.baseUrl, {
|
|
508
|
-
jsonrpc: '2.0',
|
|
509
|
-
method: 'tools/call',
|
|
510
|
-
params: { name: 'lightdash_list_projects', arguments: {} },
|
|
511
|
-
id: 6,
|
|
512
|
-
}, { token: TOKEN_A_REFRESHED, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
513
|
-
(0, vitest_1.expect)(callResponse.status).toBe(200);
|
|
514
|
-
const payload = (await parseMcpResponse(callResponse));
|
|
515
|
-
(0, vitest_1.expect)((_d = (_c = (_b = (_a = payload.result) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : '').toContain('project-a-uuid');
|
|
516
|
-
const toolHeaders = mockLightdash.authorizationHeaders.slice(headersBeforeTool);
|
|
517
|
-
(0, vitest_1.expect)(toolHeaders).toContain(`Bearer ${TOKEN_A_REFRESHED}`);
|
|
518
|
-
(0, vitest_1.expect)(toolHeaders).not.toContain(`Bearer ${TOKEN_A}`);
|
|
519
|
-
});
|
|
520
|
-
(0, vitest_1.it)('initializes MCP session with opaque OAuth bearer when endpoint scopes are unset', async () => {
|
|
521
|
-
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: OPAQUE_TOKEN_A });
|
|
522
|
-
(0, vitest_1.expect)(response.status).toBe(200);
|
|
523
|
-
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeTruthy();
|
|
524
|
-
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${OPAQUE_TOKEN_A}`);
|
|
525
|
-
});
|
|
526
|
-
(0, vitest_1.it)('lists nine semantic-layer tools under mcp:read-only JWT scopes', async () => {
|
|
527
|
-
var _a, _b, _c;
|
|
528
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
529
|
-
token: TOKEN_READ_ONLY,
|
|
530
|
-
});
|
|
531
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
532
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
533
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_READ_ONLY, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
534
|
-
const listResponse = await postMcp(mcpServer.baseUrl, {
|
|
535
|
-
jsonrpc: '2.0',
|
|
536
|
-
method: 'tools/list',
|
|
537
|
-
id: 3,
|
|
538
|
-
}, { token: TOKEN_READ_ONLY, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
539
|
-
(0, vitest_1.expect)(listResponse.status).toBe(200);
|
|
540
|
-
const payload = (await parseMcpResponse(listResponse));
|
|
541
|
-
(0, vitest_1.expect)((_a = payload.result) === null || _a === void 0 ? void 0 : _a.tools).toHaveLength(9);
|
|
542
|
-
(0, vitest_1.expect)((_c = (_b = payload.result) === null || _b === void 0 ? void 0 : _b.tools) === null || _c === void 0 ? void 0 : _c.every((t) => t.name.startsWith('lightdash_'))).toBe(true);
|
|
543
|
-
});
|
|
544
|
-
(0, vitest_1.it)('allows read tools when JWT scopes include mcp:read only', async () => {
|
|
545
|
-
var _a, _b, _c, _d, _e;
|
|
546
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
547
|
-
token: TOKEN_READ_ONLY,
|
|
548
|
-
});
|
|
549
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
550
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
551
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_READ_ONLY, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
552
|
-
const callResponse = await postMcp(mcpServer.baseUrl, {
|
|
553
|
-
jsonrpc: '2.0',
|
|
554
|
-
method: 'tools/call',
|
|
555
|
-
params: { name: 'lightdash_list_projects', arguments: {} },
|
|
556
|
-
id: 4,
|
|
557
|
-
}, { token: TOKEN_READ_ONLY, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
558
|
-
(0, vitest_1.expect)(callResponse.status).toBe(200);
|
|
559
|
-
const payload = (await parseMcpResponse(callResponse));
|
|
560
|
-
(0, vitest_1.expect)((_a = payload.result) === null || _a === void 0 ? void 0 : _a.isError).not.toBe(true);
|
|
561
|
-
(0, vitest_1.expect)((_e = (_d = (_c = (_b = payload.result) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.text) !== null && _e !== void 0 ? _e : '').toContain('project-a-uuid');
|
|
562
|
-
});
|
|
563
|
-
(0, vitest_1.it)('does not block read tools for opaque OAuth credentials without local scope claims', async () => {
|
|
564
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
565
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
566
|
-
token: OPAQUE_TOKEN_A,
|
|
567
|
-
});
|
|
568
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
569
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
570
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: OPAQUE_TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
571
|
-
const callResponse = await postMcp(mcpServer.baseUrl, {
|
|
572
|
-
jsonrpc: '2.0',
|
|
573
|
-
method: 'tools/call',
|
|
574
|
-
params: { name: 'lightdash_list_projects', arguments: {} },
|
|
575
|
-
id: 5,
|
|
576
|
-
}, { token: OPAQUE_TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
577
|
-
(0, vitest_1.expect)(callResponse.status).toBe(200);
|
|
578
|
-
const payload = (await parseMcpResponse(callResponse));
|
|
579
|
-
(0, vitest_1.expect)((_a = payload.result) === null || _a === void 0 ? void 0 : _a.isError).not.toBe(true);
|
|
580
|
-
(0, vitest_1.expect)((_e = (_d = (_c = (_b = payload.result) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.text) !== null && _e !== void 0 ? _e : '').not.toContain('insufficient_scope');
|
|
581
|
-
(0, vitest_1.expect)((_j = (_h = (_g = (_f = payload.result) === null || _f === void 0 ? void 0 : _f.content) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.text) !== null && _j !== void 0 ? _j : '').toContain('project-a-uuid');
|
|
582
|
-
});
|
|
583
|
-
});
|
|
584
|
-
(0, vitest_1.describe)('MCP HTTP OAuth transport lifecycle', () => {
|
|
461
|
+
(0, vitest_1.describe)('MCP HTTP transport (sessionless)', () => {
|
|
585
462
|
let mockLightdash;
|
|
586
463
|
let mcpServer;
|
|
587
464
|
(0, vitest_1.beforeEach)(async () => {
|
|
@@ -595,61 +472,38 @@ async function parseMcpResponse(response) {
|
|
|
595
472
|
await mockLightdash.close();
|
|
596
473
|
vitest_1.vi.restoreAllMocks();
|
|
597
474
|
});
|
|
598
|
-
(0, vitest_1.it)('supports initialize → notification → GET on the same OAuth session', async () => {
|
|
599
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
600
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
601
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
602
|
-
const notifyResponse = await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
603
|
-
(0, vitest_1.expect)([200, 202]).toContain(notifyResponse.status);
|
|
604
|
-
const getResponse = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
605
|
-
method: 'GET',
|
|
606
|
-
headers: {
|
|
607
|
-
Accept: 'application/json, text/event-stream',
|
|
608
|
-
Authorization: `Bearer ${TOKEN_A}`,
|
|
609
|
-
'Mcp-Session-Id': sessionId !== null && sessionId !== void 0 ? sessionId : '',
|
|
610
|
-
},
|
|
611
|
-
});
|
|
612
|
-
(0, vitest_1.expect)(getResponse.status).not.toBe(401);
|
|
613
|
-
(0, vitest_1.expect)(getResponse.status).not.toBe(404);
|
|
614
|
-
});
|
|
615
475
|
(0, vitest_1.it)('returns 413 for oversized JSON body after OAuth authentication', async () => {
|
|
616
|
-
const
|
|
617
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
618
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
619
|
-
const hugeBody = JSON.stringify({
|
|
620
|
-
jsonrpc: '2.0',
|
|
621
|
-
method: 'notifications/initialized',
|
|
622
|
-
params: { padding: 'x'.repeat(1024) },
|
|
623
|
-
});
|
|
476
|
+
const hugeBody = JSON.stringify(Object.assign(Object.assign({}, INITIALIZE_BODY), { params: Object.assign(Object.assign({}, INITIALIZE_BODY.params), { padding: 'x'.repeat(1024) }) }));
|
|
624
477
|
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
625
478
|
method: 'POST',
|
|
626
479
|
headers: {
|
|
627
480
|
'Content-Type': 'application/json',
|
|
628
481
|
Accept: 'application/json, text/event-stream',
|
|
629
482
|
Authorization: `Bearer ${TOKEN_A}`,
|
|
630
|
-
'Mcp-Session-Id': sessionId !== null && sessionId !== void 0 ? sessionId : '',
|
|
631
483
|
},
|
|
632
484
|
body: hugeBody,
|
|
633
485
|
});
|
|
634
486
|
(0, vitest_1.expect)(response.status).toBe(413);
|
|
635
487
|
(0, vitest_1.expect)(await response.json()).toEqual({ error: 'Payload Too Large' });
|
|
636
488
|
});
|
|
637
|
-
(0, vitest_1.it)('
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
641
|
-
const deleteResponse = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
642
|
-
method: 'DELETE',
|
|
489
|
+
(0, vitest_1.it)('returns 405 for GET on profile endpoint (sessionless, no persistent streams)', async () => {
|
|
490
|
+
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
491
|
+
method: 'GET',
|
|
643
492
|
headers: {
|
|
644
493
|
Accept: 'application/json, text/event-stream',
|
|
645
494
|
Authorization: `Bearer ${TOKEN_A}`,
|
|
646
|
-
'Mcp-Session-Id': sessionId !== null && sessionId !== void 0 ? sessionId : '',
|
|
647
495
|
},
|
|
648
496
|
});
|
|
649
|
-
(0, vitest_1.expect)(
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
497
|
+
(0, vitest_1.expect)(response.status).toBe(405);
|
|
498
|
+
});
|
|
499
|
+
(0, vitest_1.it)('returns 405 for DELETE on profile endpoint (sessionless, no sessions to close)', async () => {
|
|
500
|
+
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
501
|
+
method: 'DELETE',
|
|
502
|
+
headers: {
|
|
503
|
+
Authorization: `Bearer ${TOKEN_A}`,
|
|
504
|
+
},
|
|
505
|
+
});
|
|
506
|
+
(0, vitest_1.expect)(response.status).toBe(405);
|
|
653
507
|
});
|
|
654
508
|
});
|
|
655
509
|
(0, vitest_1.describe)('MCP HTTP shared-key integration', () => {
|
|
@@ -669,10 +523,6 @@ async function parseMcpResponse(response) {
|
|
|
669
523
|
sharedKey: new client_1.SecretString('shared-secret'),
|
|
670
524
|
allowedOrigins: [],
|
|
671
525
|
maxBodyBytes: 1024 * 1024,
|
|
672
|
-
sessionTtlMs: 60000,
|
|
673
|
-
maxSessions: 10,
|
|
674
|
-
maxSessionsPerSubject: 10,
|
|
675
|
-
sessionCleanupMs: 60000,
|
|
676
526
|
requiredScopes: [],
|
|
677
527
|
scopesSupported: ['mcp:read'],
|
|
678
528
|
validateToken: false,
|
|
@@ -691,7 +541,8 @@ async function parseMcpResponse(response) {
|
|
|
691
541
|
token: 'shared-secret',
|
|
692
542
|
});
|
|
693
543
|
(0, vitest_1.expect)(authorized.status).toBe(200);
|
|
694
|
-
|
|
544
|
+
// Sessionless: no session-id
|
|
545
|
+
(0, vitest_1.expect)(authorized.headers.get('mcp-session-id')).toBeFalsy();
|
|
695
546
|
});
|
|
696
547
|
(0, vitest_1.it)('returns 401 before reading oversized bodies when shared key is missing', async () => {
|
|
697
548
|
const hugeBody = JSON.stringify(Object.assign(Object.assign({}, INITIALIZE_BODY), { params: Object.assign(Object.assign({}, INITIALIZE_BODY.params), { padding: 'x'.repeat(2048) }) }));
|
|
@@ -717,6 +568,6 @@ async function parseMcpResponse(response) {
|
|
|
717
568
|
body: JSON.stringify(INITIALIZE_BODY),
|
|
718
569
|
});
|
|
719
570
|
(0, vitest_1.expect)(response.status).toBe(200);
|
|
720
|
-
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).
|
|
571
|
+
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeFalsy();
|
|
721
572
|
});
|
|
722
573
|
});
|
package/dist/http.test.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_events_1 = require("node:events");
|
|
7
7
|
const vitest_1 = require("vitest");
|
|
8
8
|
const http_body_js_1 = require("./transports/http-body.js");
|
|
9
|
-
const http_request_utils_js_1 = require("./transports/http-request-utils.js");
|
|
10
9
|
const http_response_js_1 = require("./transports/http-response.js");
|
|
11
10
|
function createMockResponse() {
|
|
12
11
|
const res = {
|
|
@@ -117,15 +116,4 @@ function createMockResponse() {
|
|
|
117
116
|
(0, vitest_1.expect)((0, http_body_js_1.parseJsonBody)(Buffer.from(' '))).toBeUndefined();
|
|
118
117
|
});
|
|
119
118
|
});
|
|
120
|
-
(0, vitest_1.describe)('initialize detection', () => {
|
|
121
|
-
(0, vitest_1.it)('detects initialize POST body', () => {
|
|
122
|
-
(0, vitest_1.expect)((0, http_request_utils_js_1.isInitializeMessage)({ jsonrpc: '2.0', method: 'initialize', id: 1 })).toBe(true);
|
|
123
|
-
});
|
|
124
|
-
(0, vitest_1.it)('detects initialize in batch array', () => {
|
|
125
|
-
(0, vitest_1.expect)((0, http_request_utils_js_1.isInitializeMessage)([{ jsonrpc: '2.0', method: 'initialize', id: 1 }])).toBe(true);
|
|
126
|
-
});
|
|
127
|
-
(0, vitest_1.it)('returns false for non-initialize methods', () => {
|
|
128
|
-
(0, vitest_1.expect)((0, http_request_utils_js_1.isInitializeMessage)({ jsonrpc: '2.0', method: 'tools/list', id: 1 })).toBe(false);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
119
|
});
|