@lightdash-tools/mcp 0.7.0 → 0.9.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 +113 -170
- package/dist/audit/server-persona.d.ts +10 -0
- package/dist/audit/server-persona.js +19 -0
- package/dist/auth/oauth-broker/pending-store.d.ts +69 -19
- package/dist/auth/oauth-broker/pending-store.js +52 -26
- package/dist/auth/oauth-broker/pending-store.test.d.ts +5 -0
- package/dist/auth/oauth-broker/pending-store.test.js +109 -0
- package/dist/auth/oauth-broker/routes.d.ts +6 -2
- package/dist/auth/oauth-broker/routes.js +25 -20
- package/dist/auth/oauth-broker/routes.test.js +33 -28
- 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 +0 -2
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +0 -19
- package/dist/auth/resource-server/www-authenticate.test.js +12 -8
- package/dist/bin.js +30 -2
- package/dist/config/env.d.ts +5 -8
- package/dist/config/env.js +6 -9
- package/dist/config/load-mcp-config.d.ts +0 -4
- package/dist/config/load-mcp-config.js +8 -5
- package/dist/config/load-mcp-config.test.js +7 -0
- package/dist/config/normalize-url.test.js +16 -7
- 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/capability.d.ts +13 -0
- package/dist/destructive/capability.js +37 -0
- package/dist/destructive/capability.test.js +46 -0
- package/dist/destructive/confirmation.d.ts +58 -0
- package/dist/destructive/confirmation.js +99 -0
- package/dist/destructive/confirmation.test.d.ts +1 -0
- package/dist/destructive/confirmation.test.js +75 -0
- package/dist/destructive/content-promote.d.ts +8 -0
- package/dist/destructive/content-promote.js +150 -0
- package/dist/destructive/content-soft-delete.d.ts +7 -0
- package/dist/destructive/content-soft-delete.js +106 -0
- package/dist/destructive/destructive-contract.test.d.ts +1 -0
- package/dist/destructive/destructive-contract.test.js +269 -0
- package/dist/destructive/precondition.d.ts +14 -0
- package/dist/destructive/precondition.js +31 -0
- package/dist/destructive/precondition.test.d.ts +1 -0
- package/dist/destructive/precondition.test.js +72 -0
- package/dist/destructive/promote-contract.test.d.ts +1 -0
- package/dist/destructive/promote-contract.test.js +398 -0
- package/dist/destructive/register-destructive-tool.d.ts +54 -0
- package/dist/destructive/register-destructive-tool.js +283 -0
- package/dist/destructive/request-state.d.ts +12 -0
- package/dist/destructive/request-state.js +41 -0
- package/dist/destructive/types.d.ts +65 -0
- package/dist/destructive/types.js +10 -0
- 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/client-capabilities-cache.d.ts +44 -0
- package/dist/governance/client-capabilities-cache.js +142 -0
- package/dist/governance/client-capabilities-cache.test.d.ts +1 -0
- package/dist/governance/client-capabilities-cache.test.js +148 -0
- package/dist/governance/mcp-client-session.d.ts +10 -0
- package/dist/governance/mcp-client-session.js +31 -0
- package/dist/governance/mcp-client-session.test.d.ts +1 -0
- package/dist/governance/mcp-client-session.test.js +31 -0
- package/dist/governance/project-scope.d.ts +24 -0
- package/dist/governance/project-scope.js +71 -0
- package/dist/governance/project-scope.test.d.ts +4 -0
- package/dist/governance/project-scope.test.js +80 -0
- 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 +151 -262
- package/dist/http.test.js +0 -12
- package/dist/index.integration.test.js +0 -4
- package/dist/index.js +3 -1
- package/dist/personas/ai-agent-ops/v1/index.d.ts +8 -0
- package/dist/personas/ai-agent-ops/v1/index.js +41 -0
- package/dist/personas/ai-agent-ops/v1/prompts.d.ts +5 -0
- package/dist/personas/ai-agent-ops/v1/prompts.js +141 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.d.ts +4 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.js +26 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/core.md +39 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/evaluation.md +25 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +28 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/release-gate.md +22 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-developer/v1/index.d.ts +10 -0
- package/dist/personas/content-developer/v1/index.js +52 -0
- package/dist/personas/content-developer/v1/prompts.d.ts +8 -0
- package/dist/personas/content-developer/v1/prompts.js +157 -0
- package/dist/personas/content-developer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-developer/v1/prompts.test.js +231 -0
- package/dist/personas/content-developer/v1/resources/playbooks/chart-types.md +123 -0
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +22 -0
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +105 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboard-design.md +153 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +103 -0
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +15 -0
- package/dist/personas/content-developer/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-developer/v1/resources/playbooks.js +63 -0
- package/dist/personas/content-governance/v1/index.d.ts +9 -0
- package/dist/personas/content-governance/v1/index.js +29 -0
- package/dist/personas/content-governance/v1/prompts.d.ts +5 -0
- package/dist/personas/content-governance/v1/prompts.js +87 -0
- package/dist/personas/content-governance/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-governance/v1/prompts.test.js +75 -0
- package/dist/personas/content-governance/v1/resources/playbooks/charts.md +29 -0
- package/dist/personas/content-governance/v1/resources/playbooks/core.md +52 -0
- package/dist/personas/content-governance/v1/resources/playbooks/dashboards.md +48 -0
- package/dist/personas/content-governance/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/content-governance/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-governance/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-reader/v1/index.d.ts +8 -0
- package/dist/personas/content-reader/v1/index.js +38 -0
- package/dist/personas/content-reader/v1/prompts.d.ts +5 -0
- package/dist/personas/content-reader/v1/prompts.js +162 -0
- package/dist/personas/content-reader/v1/prompts.test.d.ts +4 -0
- package/dist/personas/content-reader/v1/prompts.test.js +25 -0
- package/dist/personas/content-reader/v1/resources/playbooks/compare.md +36 -0
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +67 -0
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +35 -0
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +49 -0
- package/dist/personas/content-reader/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/content-reader/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/content-reader/v1/resources/playbooks.js +49 -0
- package/dist/personas/index.d.ts +4 -0
- package/dist/personas/index.js +31 -10
- package/dist/personas/index.test.js +92 -26
- package/dist/personas/lib/playbook-resources.d.ts +80 -0
- package/dist/personas/lib/playbook-resources.js +169 -0
- package/dist/personas/organization-audit/v1/index.js +2 -2
- package/dist/personas/organization-audit/v1/prompts.js +79 -66
- package/dist/personas/organization-audit/v1/prompts.test.js +4 -4
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +21 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +19 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/core.md +69 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +14 -0
- package/dist/personas/organization-audit/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/organization-audit/v1/resources/playbooks.js +41 -0
- package/dist/personas/persona.parity.test.d.ts +1 -0
- package/dist/personas/persona.parity.test.js +30 -0
- package/dist/personas/semantic-layer/v1/index.js +2 -2
- package/dist/personas/semantic-layer/v1/prompts.js +56 -67
- package/dist/personas/semantic-layer/v1/prompts.test.d.ts +4 -0
- package/dist/personas/semantic-layer/v1/prompts.test.js +19 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/compose-compile.md +60 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +71 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +79 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks/index.md +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.d.ts +13 -0
- package/dist/personas/semantic-layer/v1/resources/playbooks.js +39 -0
- package/dist/personas/types.d.ts +1 -1
- package/dist/policy/content-developer.d.ts +35 -0
- package/dist/policy/content-developer.js +91 -0
- package/dist/policy/content-developer.test.d.ts +4 -0
- package/dist/policy/content-developer.test.js +54 -0
- package/dist/policy/content-reader.d.ts +28 -0
- package/dist/policy/content-reader.js +67 -0
- package/dist/policy/content-reader.test.d.ts +4 -0
- package/dist/policy/content-reader.test.js +23 -0
- package/dist/policy/envelope.d.ts +31 -0
- package/dist/policy/envelope.js +24 -0
- package/dist/policy/preview-ledger-fault.test.d.ts +1 -0
- package/dist/policy/preview-ledger-fault.test.js +202 -0
- package/dist/policy/preview-ledger.d.ts +82 -0
- package/dist/policy/preview-ledger.js +165 -0
- package/dist/policy/preview-ledger.test.d.ts +1 -0
- package/dist/policy/preview-ledger.test.js +393 -0
- package/dist/policy/result-limits.d.ts +32 -0
- package/dist/policy/result-limits.js +106 -0
- package/dist/policy/result-limits.test.d.ts +4 -0
- package/dist/policy/result-limits.test.js +37 -0
- package/dist/server/capabilities.js +3 -1
- package/dist/server/capabilities.test.js +5 -1
- package/dist/server/server.js +16 -1
- package/dist/server/upstream-errors.d.ts +17 -0
- package/dist/server/upstream-errors.js +60 -0
- package/dist/server/upstream-errors.test.d.ts +1 -0
- package/dist/server/upstream-errors.test.js +50 -0
- package/dist/stdio.process.test.js +150 -0
- 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 +64 -0
- package/dist/tools/ai-agents/helpers.js +323 -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.d.ts +6 -0
- package/dist/tools/composition/explain-content.js +108 -0
- package/dist/tools/lib/api-errors.d.ts +2 -0
- package/dist/tools/lib/api-errors.js +5 -0
- package/dist/tools/lib/stable-stringify.d.ts +9 -0
- package/dist/tools/lib/stable-stringify.js +35 -0
- package/dist/tools/organization/inventory.js +2 -1
- package/dist/tools/project/content.js +5 -1
- package/dist/tools/project/delete-chart.d.ts +4 -0
- package/dist/tools/project/delete-chart.js +8 -0
- package/dist/tools/project/delete-dashboard.d.ts +4 -0
- package/dist/tools/project/delete-dashboard.js +8 -0
- package/dist/tools/project/developer-content-preview.d.ts +13 -0
- package/dist/tools/project/developer-content-preview.js +291 -0
- package/dist/tools/project/developer-content-shared.d.ts +24 -0
- package/dist/tools/project/developer-content-shared.js +50 -0
- package/dist/tools/project/developer-content-shared.test.d.ts +1 -0
- package/dist/tools/project/developer-content-shared.test.js +25 -0
- package/dist/tools/project/developer-content.d.ts +38 -0
- package/dist/tools/project/developer-content.js +589 -0
- 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 +180 -0
- package/dist/tools/project/developer-helpers.js +484 -0
- package/dist/tools/project/developer-helpers.test.d.ts +1 -0
- package/dist/tools/project/developer-helpers.test.js +509 -0
- package/dist/tools/project/get-dashboard-promote-diff.d.ts +6 -0
- package/dist/tools/project/get-dashboard-promote-diff.js +52 -0
- package/dist/tools/project/invariants.test.d.ts +4 -0
- package/dist/tools/project/invariants.test.js +44 -0
- package/dist/tools/project/parameters.d.ts +7 -0
- package/dist/tools/project/parameters.js +74 -0
- package/dist/tools/project/projects.d.ts +4 -1
- package/dist/tools/project/projects.js +68 -6
- package/dist/tools/project/projects.test.js +77 -1
- package/dist/tools/project/promote-dashboard.d.ts +4 -0
- package/dist/tools/project/promote-dashboard.js +8 -0
- package/dist/tools/project/reader-content.d.ts +9 -0
- package/dist/tools/project/reader-content.js +208 -0
- package/dist/tools/project/reader-execution.d.ts +7 -0
- package/dist/tools/project/reader-execution.js +214 -0
- package/dist/tools/project/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/schemas/chart-upsert.d.ts +33 -0
- package/dist/tools/project/schemas/chart-upsert.js +66 -0
- package/dist/tools/project/schemas/dashboard-tile.d.ts +29 -0
- package/dist/tools/project/schemas/dashboard-tile.js +57 -0
- package/dist/tools/project/schemas/dashboard.d.ts +70 -0
- package/dist/tools/project/schemas/dashboard.js +101 -0
- package/dist/tools/project/schemas/duplicate.d.ts +30 -0
- package/dist/tools/project/schemas/duplicate.js +86 -0
- package/dist/tools/project/schemas/index.d.ts +7 -0
- package/dist/tools/project/schemas/index.js +26 -0
- package/dist/tools/project/schemas/parse-helpers.d.ts +14 -0
- package/dist/tools/project/schemas/parse-helpers.js +34 -0
- package/dist/tools/project/schemas/payload-schemas.test.d.ts +1 -0
- package/dist/tools/project/schemas/payload-schemas.test.js +204 -0
- package/dist/tools/project/spaces.d.ts +7 -0
- package/dist/tools/project/spaces.js +101 -0
- package/dist/tools/query/bounded-saved-query.d.ts +37 -0
- package/dist/tools/query/bounded-saved-query.js +80 -0
- package/dist/tools/query/bounded-saved-query.test.d.ts +4 -0
- package/dist/tools/query/bounded-saved-query.test.js +82 -0
- package/dist/tools/query/chart-source.d.ts +10 -0
- package/dist/tools/query/chart-source.js +36 -0
- package/dist/tools/query/chart-source.test.d.ts +1 -0
- package/dist/tools/query/chart-source.test.js +62 -0
- package/dist/tools/query/filter-overrides.d.ts +34 -0
- package/dist/tools/query/filter-overrides.js +75 -0
- package/dist/tools/query/filter-overrides.test.d.ts +1 -0
- package/dist/tools/query/filter-overrides.test.js +21 -0
- package/dist/tools/query/lifecycle.d.ts +7 -0
- package/dist/tools/query/lifecycle.js +104 -0
- package/dist/tools/query/query-ledger.d.ts +41 -0
- package/dist/tools/query/query-ledger.js +92 -0
- package/dist/tools/query/query-ledger.test.d.ts +1 -0
- package/dist/tools/query/query-ledger.test.js +75 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +12 -0
- package/dist/tools/query/reader-tool-helpers.js +57 -0
- package/dist/tools/query/reader-tool-helpers.test.d.ts +1 -0
- package/dist/tools/query/reader-tool-helpers.test.js +53 -0
- package/dist/tools/query/result-normalizer.d.ts +27 -0
- package/dist/tools/query/result-normalizer.js +133 -0
- package/dist/tools/query/result-normalizer.test.d.ts +1 -0
- package/dist/tools/query/result-normalizer.test.js +41 -0
- package/dist/tools/query/wait-for-async.d.ts +10 -0
- package/dist/tools/query/wait-for-async.js +46 -0
- package/dist/tools/query/wait-for-async.test.d.ts +1 -0
- package/dist/tools/query/wait-for-async.test.js +45 -0
- package/dist/tools/registry.d.ts +187 -3
- package/dist/tools/registry.js +89 -7
- package/dist/tools/shared.d.ts +52 -10
- package/dist/tools/shared.js +127 -41
- package/dist/tools/shared.test.js +103 -3
- package/dist/transports/streamable-http.js +47 -198
- package/dist/transports/streamable-http.test.js +21 -9
- package/package.json +5 -5
- package/dist/personas/organization-audit/v1/resources/playbook.d.ts +0 -11
- package/dist/personas/organization-audit/v1/resources/playbook.js +0 -40
- package/dist/personas/organization-audit/v1/resources/playbook.md +0 -52
- package/dist/personas/semantic-layer/v1/resources/playbook.d.ts +0 -12
- package/dist/personas/semantic-layer/v1/resources/playbook.js +0 -42
- package/dist/personas/semantic-layer/v1/resources/playbook.md +0 -153
- 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 -40
- package/dist/transports/session-store.js +0 -88
- package/dist/transports/session-store.test.js +0 -111
- /package/dist/{transports/session-store.test.d.ts → destructive/capability.test.d.ts} +0 -0
|
@@ -4,22 +4,14 @@ const node_http_1 = require("node:http");
|
|
|
4
4
|
const client_1 = require("@lightdash-tools/client");
|
|
5
5
|
const vitest_1 = require("vitest");
|
|
6
6
|
const oauth_protected_resource_js_1 = require("./auth/resource-server/oauth-protected-resource.js");
|
|
7
|
+
const client_capabilities_cache_js_1 = require("./governance/client-capabilities-cache.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;
|
|
@@ -190,6 +171,7 @@ async function parseMcpResponse(response) {
|
|
|
190
171
|
(0, vitest_1.afterEach)(async () => {
|
|
191
172
|
await mcpServer.close();
|
|
192
173
|
await mockLightdash.close();
|
|
174
|
+
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
193
175
|
vitest_1.vi.restoreAllMocks();
|
|
194
176
|
});
|
|
195
177
|
(0, vitest_1.it)('returns 401 with WWW-Authenticate resource_metadata when OAuth token is missing', async () => {
|
|
@@ -207,78 +189,13 @@ async function parseMcpResponse(response) {
|
|
|
207
189
|
(0, vitest_1.expect)(body).not.toContain(invalidToken);
|
|
208
190
|
(0, vitest_1.expect)(response.headers.get('www-authenticate')).toContain('invalid_token');
|
|
209
191
|
});
|
|
210
|
-
(0, vitest_1.it)('
|
|
192
|
+
(0, vitest_1.it)('handles initialize with valid OAuth bearer and validates upstream Authorization', async () => {
|
|
211
193
|
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
212
194
|
(0, vitest_1.expect)(response.status).toBe(200);
|
|
213
|
-
|
|
195
|
+
// Sessionless: no session-id header is set
|
|
196
|
+
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeFalsy();
|
|
214
197
|
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
|
|
215
198
|
});
|
|
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
199
|
(0, vitest_1.it)('returns 401 before parsing malformed JSON when OAuth token is missing', async () => {
|
|
283
200
|
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
284
201
|
method: 'POST',
|
|
@@ -334,6 +251,18 @@ async function parseMcpResponse(response) {
|
|
|
334
251
|
const metadata = await response.json();
|
|
335
252
|
(0, vitest_1.expect)(metadata.resource).toBe(`${mcpServer.baseUrl}/organization-audit/v1/mcp`);
|
|
336
253
|
});
|
|
254
|
+
(0, vitest_1.it)('serves content-reader path-specific OAuth protected resource metadata', async () => {
|
|
255
|
+
const response = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/content-reader/v1/mcp`);
|
|
256
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
257
|
+
const metadata = await response.json();
|
|
258
|
+
(0, vitest_1.expect)(metadata.resource).toBe(`${mcpServer.baseUrl}/content-reader/v1/mcp`);
|
|
259
|
+
});
|
|
260
|
+
(0, vitest_1.it)('serves content-governance path-specific OAuth protected resource metadata', async () => {
|
|
261
|
+
const response = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/content-governance/v1/mcp`);
|
|
262
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
263
|
+
const metadata = await response.json();
|
|
264
|
+
(0, vitest_1.expect)(metadata.resource).toBe(`${mcpServer.baseUrl}/content-governance/v1/mcp`);
|
|
265
|
+
});
|
|
337
266
|
(0, vitest_1.it)('returns 401 with organization-audit resource_metadata on that persona path', async () => {
|
|
338
267
|
const response = await fetch(`${mcpServer.baseUrl}/organization-audit/v1/mcp`, {
|
|
339
268
|
method: 'POST',
|
|
@@ -345,6 +274,28 @@ async function parseMcpResponse(response) {
|
|
|
345
274
|
(0, vitest_1.expect)(wwwAuthenticate).toContain(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/organization-audit/v1/mcp`);
|
|
346
275
|
(0, vitest_1.expect)(wwwAuthenticate).not.toContain('semantic-layer/v1/mcp');
|
|
347
276
|
});
|
|
277
|
+
(0, vitest_1.it)('returns 401 with content-reader resource_metadata on that persona path', async () => {
|
|
278
|
+
const response = await fetch(`${mcpServer.baseUrl}/content-reader/v1/mcp`, {
|
|
279
|
+
method: 'POST',
|
|
280
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
281
|
+
body: JSON.stringify(INITIALIZE_BODY),
|
|
282
|
+
});
|
|
283
|
+
(0, vitest_1.expect)(response.status).toBe(401);
|
|
284
|
+
const wwwAuthenticate = response.headers.get('www-authenticate');
|
|
285
|
+
(0, vitest_1.expect)(wwwAuthenticate).toContain(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/content-reader/v1/mcp`);
|
|
286
|
+
(0, vitest_1.expect)(wwwAuthenticate).not.toContain('semantic-layer/v1/mcp');
|
|
287
|
+
});
|
|
288
|
+
(0, vitest_1.it)('returns 401 with content-governance resource_metadata on that persona path', async () => {
|
|
289
|
+
const response = await fetch(`${mcpServer.baseUrl}/content-governance/v1/mcp`, {
|
|
290
|
+
method: 'POST',
|
|
291
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
292
|
+
body: JSON.stringify(INITIALIZE_BODY),
|
|
293
|
+
});
|
|
294
|
+
(0, vitest_1.expect)(response.status).toBe(401);
|
|
295
|
+
const wwwAuthenticate = response.headers.get('www-authenticate');
|
|
296
|
+
(0, vitest_1.expect)(wwwAuthenticate).toContain(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/content-governance/v1/mcp`);
|
|
297
|
+
(0, vitest_1.expect)(wwwAuthenticate).not.toContain('semantic-layer/v1/mcp');
|
|
298
|
+
});
|
|
348
299
|
(0, vitest_1.it)('maps token-a and token-b to distinct authenticated users upstream', async () => {
|
|
349
300
|
const responseA = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
350
301
|
const responseB = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_B });
|
|
@@ -353,6 +304,28 @@ async function parseMcpResponse(response) {
|
|
|
353
304
|
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
|
|
354
305
|
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_B}`);
|
|
355
306
|
});
|
|
307
|
+
(0, vitest_1.it)('bridges initialize form-elicitation caps to a later content-governance tools/call', async () => {
|
|
308
|
+
const governancePath = '/content-governance/v1/mcp';
|
|
309
|
+
const init = await postMcp(mcpServer.baseUrl, Object.assign(Object.assign({}, INITIALIZE_BODY), { params: Object.assign(Object.assign({}, INITIALIZE_BODY.params), { capabilities: { elicitation: { form: {} } } }) }), { token: TOKEN_A, path: governancePath });
|
|
310
|
+
(0, vitest_1.expect)(init.status).toBe(200);
|
|
311
|
+
const call = await postMcp(mcpServer.baseUrl, {
|
|
312
|
+
jsonrpc: '2.0',
|
|
313
|
+
method: 'tools/call',
|
|
314
|
+
params: {
|
|
315
|
+
name: 'lightdash_delete_chart',
|
|
316
|
+
arguments: {
|
|
317
|
+
projectUuid: '11111111-1111-4111-8111-111111111111',
|
|
318
|
+
chartUuidOrSlug: '22222222-2222-4222-8222-222222222222',
|
|
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
|
+
// Caps bridge worked: 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
|
+
});
|
|
356
329
|
(0, vitest_1.it)('returns 503 when Lightdash user validation is unavailable', async () => {
|
|
357
330
|
const unavailableServer = (0, node_http_1.createServer)((_req, res) => {
|
|
358
331
|
res.writeHead(503, { 'Content-Type': 'application/json' }).end(JSON.stringify({
|
|
@@ -385,6 +358,64 @@ async function parseMcpResponse(response) {
|
|
|
385
358
|
}
|
|
386
359
|
});
|
|
387
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
|
+
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
374
|
+
vitest_1.vi.restoreAllMocks();
|
|
375
|
+
});
|
|
376
|
+
(0, vitest_1.it)('protected-resource metadata authorization_servers points at MCP broker AS metadata', async () => {
|
|
377
|
+
const response = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource`);
|
|
378
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
379
|
+
const metadata = (await response.json());
|
|
380
|
+
(0, vitest_1.expect)(metadata.authorization_servers).toEqual([mcpServer.baseUrl]);
|
|
381
|
+
const asMetadataUrl = (0, oauth_protected_resource_js_1.getAuthorizationServerMetadataUrl)(metadata.authorization_servers[0]);
|
|
382
|
+
(0, vitest_1.expect)(asMetadataUrl).toBe(`${mcpServer.baseUrl}/.well-known/oauth-authorization-server`);
|
|
383
|
+
const asResponse = await fetch(asMetadataUrl);
|
|
384
|
+
(0, vitest_1.expect)(asResponse.status).toBe(200);
|
|
385
|
+
const asMetadata = (await asResponse.json());
|
|
386
|
+
(0, vitest_1.expect)(asMetadata.authorization_endpoint).toBe(`${mcpServer.baseUrl}/oauth/authorize`);
|
|
387
|
+
(0, vitest_1.expect)(asMetadata.token_endpoint).toBe(`${mcpServer.baseUrl}/oauth/token`);
|
|
388
|
+
(0, vitest_1.expect)(asMetadata.registration_endpoint).toBe(`${mcpServer.baseUrl}/oauth/register`);
|
|
389
|
+
});
|
|
390
|
+
(0, vitest_1.it)('handles initialize with opaque OAuth bearer when endpoint scopes are unset', async () => {
|
|
391
|
+
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: OPAQUE_TOKEN_A });
|
|
392
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
393
|
+
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeFalsy();
|
|
394
|
+
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${OPAQUE_TOKEN_A}`);
|
|
395
|
+
});
|
|
396
|
+
(0, vitest_1.it)('accepts TOKEN_READ_ONLY (mcp:read scope) on initialize', async () => {
|
|
397
|
+
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
398
|
+
token: TOKEN_READ_ONLY,
|
|
399
|
+
});
|
|
400
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
401
|
+
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_READ_ONLY}`);
|
|
402
|
+
});
|
|
403
|
+
(0, vitest_1.it)('accepts TOKEN_A (mcp:read mcp:write scope) on initialize', async () => {
|
|
404
|
+
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
405
|
+
token: TOKEN_A,
|
|
406
|
+
});
|
|
407
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
408
|
+
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
|
|
409
|
+
});
|
|
410
|
+
(0, vitest_1.it)('forwards bearer token to Lightdash on initialize for opaque credentials', async () => {
|
|
411
|
+
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
412
|
+
token: OPAQUE_TOKEN_A,
|
|
413
|
+
});
|
|
414
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
415
|
+
const userHeaders = mockLightdash.authorizationHeaders.filter((h) => h === `Bearer ${OPAQUE_TOKEN_A}`);
|
|
416
|
+
(0, vitest_1.expect)(userHeaders.length).toBeGreaterThan(0);
|
|
417
|
+
});
|
|
418
|
+
});
|
|
388
419
|
(0, vitest_1.describe)('MCP HTTP CORS integration', () => {
|
|
389
420
|
let mockLightdash;
|
|
390
421
|
let mcpServer;
|
|
@@ -397,6 +428,7 @@ async function parseMcpResponse(response) {
|
|
|
397
428
|
(0, vitest_1.afterEach)(async () => {
|
|
398
429
|
await mcpServer.close();
|
|
399
430
|
await mockLightdash.close();
|
|
431
|
+
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
400
432
|
vitest_1.vi.restoreAllMocks();
|
|
401
433
|
});
|
|
402
434
|
(0, vitest_1.it)('sets CORS headers for allowed origins on metadata', async () => {
|
|
@@ -428,126 +460,7 @@ async function parseMcpResponse(response) {
|
|
|
428
460
|
(0, vitest_1.expect)(body.error).toContain('origin not allowed');
|
|
429
461
|
});
|
|
430
462
|
});
|
|
431
|
-
(0, vitest_1.describe)('MCP HTTP
|
|
432
|
-
let mockLightdash;
|
|
433
|
-
let mcpServer;
|
|
434
|
-
(0, vitest_1.beforeEach)(async () => {
|
|
435
|
-
vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
436
|
-
vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
437
|
-
mockLightdash = await startMockLightdashServer();
|
|
438
|
-
mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, baseOAuthConfig(mockLightdash.baseUrl)));
|
|
439
|
-
});
|
|
440
|
-
(0, vitest_1.afterEach)(async () => {
|
|
441
|
-
await mcpServer.close();
|
|
442
|
-
await mockLightdash.close();
|
|
443
|
-
vitest_1.vi.restoreAllMocks();
|
|
444
|
-
});
|
|
445
|
-
(0, vitest_1.it)('calls lightdash_list_projects over an OAuth HTTP session', async () => {
|
|
446
|
-
var _a, _b, _c, _d;
|
|
447
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
448
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
449
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
450
|
-
const userCallsBefore = mockLightdash.authorizationHeaders.length;
|
|
451
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
452
|
-
const callResponse = await postMcp(mcpServer.baseUrl, {
|
|
453
|
-
jsonrpc: '2.0',
|
|
454
|
-
method: 'tools/call',
|
|
455
|
-
params: { name: 'lightdash_list_projects', arguments: {} },
|
|
456
|
-
id: 2,
|
|
457
|
-
}, { token: TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
458
|
-
(0, vitest_1.expect)(callResponse.status).toBe(200);
|
|
459
|
-
const payload = (await parseMcpResponse(callResponse));
|
|
460
|
-
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 : '';
|
|
461
|
-
(0, vitest_1.expect)(text).toContain('project-a-uuid');
|
|
462
|
-
(0, vitest_1.expect)(text).not.toContain(TOKEN_A);
|
|
463
|
-
(0, vitest_1.expect)(mockLightdash.authorizationHeaders.length).toBeGreaterThan(userCallsBefore);
|
|
464
|
-
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
|
|
465
|
-
});
|
|
466
|
-
(0, vitest_1.it)('forwards refreshed bearer token to Lightdash on tool calls after session resume', async () => {
|
|
467
|
-
var _a, _b, _c, _d;
|
|
468
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
469
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
470
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
471
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_A_REFRESHED, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
472
|
-
const headersBeforeTool = mockLightdash.authorizationHeaders.length;
|
|
473
|
-
const callResponse = await postMcp(mcpServer.baseUrl, {
|
|
474
|
-
jsonrpc: '2.0',
|
|
475
|
-
method: 'tools/call',
|
|
476
|
-
params: { name: 'lightdash_list_projects', arguments: {} },
|
|
477
|
-
id: 6,
|
|
478
|
-
}, { token: TOKEN_A_REFRESHED, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
479
|
-
(0, vitest_1.expect)(callResponse.status).toBe(200);
|
|
480
|
-
const payload = (await parseMcpResponse(callResponse));
|
|
481
|
-
(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');
|
|
482
|
-
const toolHeaders = mockLightdash.authorizationHeaders.slice(headersBeforeTool);
|
|
483
|
-
(0, vitest_1.expect)(toolHeaders).toContain(`Bearer ${TOKEN_A_REFRESHED}`);
|
|
484
|
-
(0, vitest_1.expect)(toolHeaders).not.toContain(`Bearer ${TOKEN_A}`);
|
|
485
|
-
});
|
|
486
|
-
(0, vitest_1.it)('initializes MCP session with opaque OAuth bearer when endpoint scopes are unset', async () => {
|
|
487
|
-
const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: OPAQUE_TOKEN_A });
|
|
488
|
-
(0, vitest_1.expect)(response.status).toBe(200);
|
|
489
|
-
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeTruthy();
|
|
490
|
-
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${OPAQUE_TOKEN_A}`);
|
|
491
|
-
});
|
|
492
|
-
(0, vitest_1.it)('lists nine semantic-layer tools under mcp:read-only JWT scopes', async () => {
|
|
493
|
-
var _a, _b, _c;
|
|
494
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
495
|
-
token: TOKEN_READ_ONLY,
|
|
496
|
-
});
|
|
497
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
498
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
499
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_READ_ONLY, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
500
|
-
const listResponse = await postMcp(mcpServer.baseUrl, {
|
|
501
|
-
jsonrpc: '2.0',
|
|
502
|
-
method: 'tools/list',
|
|
503
|
-
id: 3,
|
|
504
|
-
}, { token: TOKEN_READ_ONLY, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
505
|
-
(0, vitest_1.expect)(listResponse.status).toBe(200);
|
|
506
|
-
const payload = (await parseMcpResponse(listResponse));
|
|
507
|
-
(0, vitest_1.expect)((_a = payload.result) === null || _a === void 0 ? void 0 : _a.tools).toHaveLength(9);
|
|
508
|
-
(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);
|
|
509
|
-
});
|
|
510
|
-
(0, vitest_1.it)('allows read tools when JWT scopes include mcp:read only', async () => {
|
|
511
|
-
var _a, _b, _c, _d, _e;
|
|
512
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
513
|
-
token: TOKEN_READ_ONLY,
|
|
514
|
-
});
|
|
515
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
516
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
517
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_READ_ONLY, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
518
|
-
const callResponse = await postMcp(mcpServer.baseUrl, {
|
|
519
|
-
jsonrpc: '2.0',
|
|
520
|
-
method: 'tools/call',
|
|
521
|
-
params: { name: 'lightdash_list_projects', arguments: {} },
|
|
522
|
-
id: 4,
|
|
523
|
-
}, { token: TOKEN_READ_ONLY, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
524
|
-
(0, vitest_1.expect)(callResponse.status).toBe(200);
|
|
525
|
-
const payload = (await parseMcpResponse(callResponse));
|
|
526
|
-
(0, vitest_1.expect)((_a = payload.result) === null || _a === void 0 ? void 0 : _a.isError).not.toBe(true);
|
|
527
|
-
(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');
|
|
528
|
-
});
|
|
529
|
-
(0, vitest_1.it)('does not block read tools for opaque OAuth credentials without local scope claims', async () => {
|
|
530
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
531
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
|
|
532
|
-
token: OPAQUE_TOKEN_A,
|
|
533
|
-
});
|
|
534
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
535
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
536
|
-
await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: OPAQUE_TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
537
|
-
const callResponse = await postMcp(mcpServer.baseUrl, {
|
|
538
|
-
jsonrpc: '2.0',
|
|
539
|
-
method: 'tools/call',
|
|
540
|
-
params: { name: 'lightdash_list_projects', arguments: {} },
|
|
541
|
-
id: 5,
|
|
542
|
-
}, { token: OPAQUE_TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
543
|
-
(0, vitest_1.expect)(callResponse.status).toBe(200);
|
|
544
|
-
const payload = (await parseMcpResponse(callResponse));
|
|
545
|
-
(0, vitest_1.expect)((_a = payload.result) === null || _a === void 0 ? void 0 : _a.isError).not.toBe(true);
|
|
546
|
-
(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');
|
|
547
|
-
(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');
|
|
548
|
-
});
|
|
549
|
-
});
|
|
550
|
-
(0, vitest_1.describe)('MCP HTTP OAuth transport lifecycle', () => {
|
|
463
|
+
(0, vitest_1.describe)('MCP HTTP transport (sessionless)', () => {
|
|
551
464
|
let mockLightdash;
|
|
552
465
|
let mcpServer;
|
|
553
466
|
(0, vitest_1.beforeEach)(async () => {
|
|
@@ -559,63 +472,41 @@ async function parseMcpResponse(response) {
|
|
|
559
472
|
(0, vitest_1.afterEach)(async () => {
|
|
560
473
|
await mcpServer.close();
|
|
561
474
|
await mockLightdash.close();
|
|
475
|
+
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
562
476
|
vitest_1.vi.restoreAllMocks();
|
|
563
477
|
});
|
|
564
|
-
(0, vitest_1.it)('supports initialize → notification → GET on the same OAuth session', async () => {
|
|
565
|
-
const initResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
|
|
566
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
567
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
568
|
-
const notifyResponse = await postMcp(mcpServer.baseUrl, { jsonrpc: '2.0', method: 'notifications/initialized' }, { token: TOKEN_A, sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : undefined });
|
|
569
|
-
(0, vitest_1.expect)([200, 202]).toContain(notifyResponse.status);
|
|
570
|
-
const getResponse = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
571
|
-
method: 'GET',
|
|
572
|
-
headers: {
|
|
573
|
-
Accept: 'application/json, text/event-stream',
|
|
574
|
-
Authorization: `Bearer ${TOKEN_A}`,
|
|
575
|
-
'Mcp-Session-Id': sessionId !== null && sessionId !== void 0 ? sessionId : '',
|
|
576
|
-
},
|
|
577
|
-
});
|
|
578
|
-
(0, vitest_1.expect)(getResponse.status).not.toBe(401);
|
|
579
|
-
(0, vitest_1.expect)(getResponse.status).not.toBe(404);
|
|
580
|
-
});
|
|
581
478
|
(0, vitest_1.it)('returns 413 for oversized JSON body after OAuth authentication', async () => {
|
|
582
|
-
const
|
|
583
|
-
const sessionId = initResponse.headers.get('mcp-session-id');
|
|
584
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
585
|
-
const hugeBody = JSON.stringify({
|
|
586
|
-
jsonrpc: '2.0',
|
|
587
|
-
method: 'notifications/initialized',
|
|
588
|
-
params: { padding: 'x'.repeat(1024) },
|
|
589
|
-
});
|
|
479
|
+
const hugeBody = JSON.stringify(Object.assign(Object.assign({}, INITIALIZE_BODY), { params: Object.assign(Object.assign({}, INITIALIZE_BODY.params), { padding: 'x'.repeat(1024) }) }));
|
|
590
480
|
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
591
481
|
method: 'POST',
|
|
592
482
|
headers: {
|
|
593
483
|
'Content-Type': 'application/json',
|
|
594
484
|
Accept: 'application/json, text/event-stream',
|
|
595
485
|
Authorization: `Bearer ${TOKEN_A}`,
|
|
596
|
-
'Mcp-Session-Id': sessionId !== null && sessionId !== void 0 ? sessionId : '',
|
|
597
486
|
},
|
|
598
487
|
body: hugeBody,
|
|
599
488
|
});
|
|
600
489
|
(0, vitest_1.expect)(response.status).toBe(413);
|
|
601
490
|
(0, vitest_1.expect)(await response.json()).toEqual({ error: 'Payload Too Large' });
|
|
602
491
|
});
|
|
603
|
-
(0, vitest_1.it)('
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
(0, vitest_1.expect)(sessionId).toBeTruthy();
|
|
607
|
-
const deleteResponse = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
608
|
-
method: 'DELETE',
|
|
492
|
+
(0, vitest_1.it)('returns 405 for GET on persona endpoint (sessionless, no persistent streams)', async () => {
|
|
493
|
+
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
494
|
+
method: 'GET',
|
|
609
495
|
headers: {
|
|
610
496
|
Accept: 'application/json, text/event-stream',
|
|
611
497
|
Authorization: `Bearer ${TOKEN_A}`,
|
|
612
|
-
'Mcp-Session-Id': sessionId !== null && sessionId !== void 0 ? sessionId : '',
|
|
613
498
|
},
|
|
614
499
|
});
|
|
615
|
-
(0, vitest_1.expect)(
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
500
|
+
(0, vitest_1.expect)(response.status).toBe(405);
|
|
501
|
+
});
|
|
502
|
+
(0, vitest_1.it)('returns 405 for DELETE on persona endpoint (sessionless, no sessions to close)', async () => {
|
|
503
|
+
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
504
|
+
method: 'DELETE',
|
|
505
|
+
headers: {
|
|
506
|
+
Authorization: `Bearer ${TOKEN_A}`,
|
|
507
|
+
},
|
|
508
|
+
});
|
|
509
|
+
(0, vitest_1.expect)(response.status).toBe(405);
|
|
619
510
|
});
|
|
620
511
|
});
|
|
621
512
|
(0, vitest_1.describe)('MCP HTTP shared-key integration', () => {
|
|
@@ -635,10 +526,6 @@ async function parseMcpResponse(response) {
|
|
|
635
526
|
sharedKey: new client_1.SecretString('shared-secret'),
|
|
636
527
|
allowedOrigins: [],
|
|
637
528
|
maxBodyBytes: 1024 * 1024,
|
|
638
|
-
sessionTtlMs: 60000,
|
|
639
|
-
maxSessions: 10,
|
|
640
|
-
maxSessionsPerSubject: 10,
|
|
641
|
-
sessionCleanupMs: 60000,
|
|
642
529
|
requiredScopes: [],
|
|
643
530
|
scopesSupported: ['mcp:read'],
|
|
644
531
|
validateToken: false,
|
|
@@ -648,6 +535,7 @@ async function parseMcpResponse(response) {
|
|
|
648
535
|
(0, vitest_1.afterEach)(async () => {
|
|
649
536
|
await mcpServer.close();
|
|
650
537
|
process.env = Object.assign({}, originalEnv);
|
|
538
|
+
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
651
539
|
vitest_1.vi.restoreAllMocks();
|
|
652
540
|
});
|
|
653
541
|
(0, vitest_1.it)('requires shared key on MCP endpoint', async () => {
|
|
@@ -657,7 +545,8 @@ async function parseMcpResponse(response) {
|
|
|
657
545
|
token: 'shared-secret',
|
|
658
546
|
});
|
|
659
547
|
(0, vitest_1.expect)(authorized.status).toBe(200);
|
|
660
|
-
|
|
548
|
+
// Sessionless: no session-id
|
|
549
|
+
(0, vitest_1.expect)(authorized.headers.get('mcp-session-id')).toBeFalsy();
|
|
661
550
|
});
|
|
662
551
|
(0, vitest_1.it)('returns 401 before reading oversized bodies when shared key is missing', async () => {
|
|
663
552
|
const hugeBody = JSON.stringify(Object.assign(Object.assign({}, INITIALIZE_BODY), { params: Object.assign(Object.assign({}, INITIALIZE_BODY.params), { padding: 'x'.repeat(2048) }) }));
|
|
@@ -683,6 +572,6 @@ async function parseMcpResponse(response) {
|
|
|
683
572
|
body: JSON.stringify(INITIALIZE_BODY),
|
|
684
573
|
});
|
|
685
574
|
(0, vitest_1.expect)(response.status).toBe(200);
|
|
686
|
-
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).
|
|
575
|
+
(0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeFalsy();
|
|
687
576
|
});
|
|
688
577
|
});
|
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
|
});
|
|
@@ -64,10 +64,6 @@ vitest_1.describe.runIf(hasOAuthToken)('MCP Integration (OAuth access token)', (
|
|
|
64
64
|
authMode: 'lightdash-oauth',
|
|
65
65
|
allowedOrigins: [],
|
|
66
66
|
maxBodyBytes: 1024 * 1024,
|
|
67
|
-
sessionTtlMs: 60000,
|
|
68
|
-
maxSessions: 10,
|
|
69
|
-
maxSessionsPerSubject: 10,
|
|
70
|
-
sessionCleanupMs: 60000,
|
|
71
67
|
requiredScopes: ['mcp:read'],
|
|
72
68
|
scopesSupported: ['mcp:read', 'mcp:write'],
|
|
73
69
|
validateToken: true,
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const stdio_1 = require("@modelcontextprotocol/server/stdio");
|
|
|
10
10
|
const audit_js_1 = require("./audit/audit.js");
|
|
11
11
|
const env_context_provider_js_1 = require("./auth/providers/env-context-provider.js");
|
|
12
12
|
const runtime_js_1 = require("./config/runtime.js");
|
|
13
|
+
const available_projects_js_1 = require("./governance/available-projects.js");
|
|
13
14
|
const index_js_1 = require("./personas/index.js");
|
|
14
15
|
const server_js_1 = require("./server/server.js");
|
|
15
16
|
function resolveStdioPersona() {
|
|
@@ -19,12 +20,13 @@ function resolveStdioPersona() {
|
|
|
19
20
|
}
|
|
20
21
|
const id = (0, index_js_1.parsePersonaId)(raw);
|
|
21
22
|
if (!id) {
|
|
22
|
-
throw new Error(`Invalid LIGHTDASH_TOOLS_MCP_STDIO_PERSONA='${raw}'. Expected semantic-layer or
|
|
23
|
+
throw new Error(`Invalid LIGHTDASH_TOOLS_MCP_STDIO_PERSONA='${raw}'. Expected semantic-layer, organization-audit, content-reader, content-developer, content-governance, or ai-agent-ops.`);
|
|
23
24
|
}
|
|
24
25
|
return (0, index_js_1.getPersona)(id);
|
|
25
26
|
}
|
|
26
27
|
async function main() {
|
|
27
28
|
(0, runtime_js_1.warnIgnoredCliGuardrailEnvVars)();
|
|
29
|
+
(0, available_projects_js_1.validateAvailableProjectsConfig)();
|
|
28
30
|
(0, audit_js_1.initAuditLog)((0, runtime_js_1.getAuditLogPath)());
|
|
29
31
|
const persona = resolveStdioPersona();
|
|
30
32
|
const contextProvider = new env_context_provider_js_1.EnvContextProvider();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI agent-ops persona: thin Lightdash AI-agent API surface (ADR-0018).
|
|
3
|
+
*/
|
|
4
|
+
import type { PersonaDefinition } from '../../types.js';
|
|
5
|
+
export declare const AI_AGENT_OPS_PERSONA_PATH: "/ai-agent-ops/v1/mcp";
|
|
6
|
+
/** Explicit allowlist — Lightdash API primitives only; no offline eval mega-tools. */
|
|
7
|
+
export declare const AI_AGENT_OPS_TOOL_IDS: readonly ["list_project_agents", "get_project_agent", "evaluate_agent_readiness", "get_agent_suggestions", "get_agent_models", "get_explore_access_summary", "list_agent_threads", "get_agent_thread", "list_agent_evaluations", "get_agent_evaluation", "create_agent_evaluation", "update_agent_evaluation", "append_agent_evaluation_prompts", "delete_agent_evaluation", "run_agent_evaluation", "list_agent_evaluation_runs", "get_agent_eval_run_results"];
|
|
8
|
+
export declare const aiAgentOpsPersona: PersonaDefinition;
|