@lightdash-tools/mcp 0.9.0 → 0.12.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 +27 -22
- 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.test.d.ts +1 -1
- package/dist/auth/oauth-broker/pending-store.test.js +1 -1
- package/dist/auth/request-state-key.d.ts +2 -2
- package/dist/auth/request-state-key.js +2 -2
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +1 -1
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +1 -1
- 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 -11
- package/dist/bin.js +54 -58
- package/dist/config/env.d.ts +3 -1
- package/dist/config/env.js +4 -2
- package/dist/config/load-mcp-config.js +8 -36
- 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 -16
- 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.js +1 -1
- package/dist/governance/available-projects.d.ts +1 -1
- package/dist/governance/available-projects.js +1 -1
- 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/http.integration.test.js +11 -15
- package/dist/index.d.ts +5 -1
- package/dist/index.js +29 -16
- package/dist/policy/content-reader.d.ts +10 -5
- package/dist/policy/content-reader.js +23 -9
- package/dist/policy/content-reader.test.js +4 -3
- package/dist/policy/envelope.d.ts +4 -2
- package/dist/policy/envelope.js +2 -2
- package/dist/policy/envelope.test.d.ts +1 -0
- package/dist/policy/envelope.test.js +28 -0
- 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/{personas → profiles}/ai-agent-ops/v1/prompts.js +2 -2
- package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/core.md +1 -1
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +1 -1
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/release-gate.md +1 -1
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks.js +4 -4
- 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.js +6 -6
- package/dist/{personas → profiles}/content-developer/v1/prompts.test.js +61 -6
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/chart-types.md +31 -16
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/core.md +9 -5
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/dashboard-design.md +3 -3
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/dashboards.md +12 -7
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks.js +4 -2
- 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 +2 -2
- 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/{personas → profiles}/content-reader/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/core.md +1 -1
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/discover.md +1 -1
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.js +2 -2
- 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.d.ts +1 -0
- package/dist/profiles/index.test.js +121 -0
- package/dist/{personas → profiles}/lib/playbook-resources.d.ts +8 -7
- package/dist/{personas → profiles}/lib/playbook-resources.js +15 -15
- package/dist/profiles/organization-audit/v1/index.d.ts +6 -0
- package/dist/profiles/organization-audit/v1/index.js +20 -0
- package/dist/{personas → profiles}/organization-audit/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.js +2 -2
- package/dist/profiles/profile.membership.test.d.ts +1 -0
- 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/{personas → profiles}/semantic-layer/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.js +2 -2
- package/dist/profiles/types.d.ts +18 -0
- 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 -10
- package/dist/server/capabilities.test.js +8 -9
- package/dist/server/server.js +7 -7
- package/dist/stdio.process.test.js +61 -7
- package/dist/tools/ai-agents/agents.d.ts +1 -1
- package/dist/tools/ai-agents/agents.js +1 -1
- package/dist/tools/ai-agents/evaluations.d.ts +1 -1
- package/dist/tools/ai-agents/evaluations.js +1 -1
- package/dist/tools/ai-agents/helpers.d.ts +2 -3
- package/dist/tools/ai-agents/helpers.js +2 -4
- package/dist/tools/ai-agents/threads.d.ts +1 -1
- package/dist/tools/ai-agents/threads.js +1 -1
- 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/project/developer-content-preview.d.ts +1 -1
- package/dist/tools/project/developer-content-preview.js +1 -1
- package/dist/tools/project/developer-content-shared.d.ts +1 -1
- package/dist/tools/project/developer-content-shared.js +1 -1
- package/dist/tools/project/developer-get-chart-as-code.test.js +1 -1
- package/dist/tools/project/invariants.test.d.ts +1 -1
- package/dist/tools/project/invariants.test.js +8 -8
- package/dist/tools/project/parameters.js +8 -3
- package/dist/tools/project/projects.d.ts +1 -4
- package/dist/tools/project/projects.js +32 -12
- package/dist/tools/project/projects.test.js +30 -7
- 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.js +1 -1
- package/dist/tools/project/reader-export-chart-image.test.js +2 -2
- 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 +3 -5
- package/dist/tools/query/lifecycle.js +10 -8
- package/dist/tools/query/query-ledger.d.ts +2 -1
- package/dist/tools/query/reader-tool-helpers.d.ts +4 -2
- package/dist/tools/query/reader-tool-helpers.js +7 -2
- 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 +8 -8
- package/dist/tools/registry.js +10 -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 +1 -1
- package/dist/tools/shared.js +5 -5
- package/dist/tools/shared.test.js +4 -4
- package/dist/transports/streamable-http.js +46 -36
- package/dist/transports/streamable-http.test.js +9 -9
- package/package.json +6 -6
- package/dist/audit/server-persona.d.ts +0 -10
- package/dist/audit/server-persona.js +0 -19
- package/dist/governance/client-capabilities-cache.d.ts +0 -44
- package/dist/governance/client-capabilities-cache.js +0 -142
- package/dist/governance/client-capabilities-cache.test.js +0 -148
- package/dist/personas/ai-agent-ops/v1/index.d.ts +0 -8
- package/dist/personas/ai-agent-ops/v1/index.js +0 -41
- package/dist/personas/content-developer/v1/index.d.ts +0 -10
- package/dist/personas/content-developer/v1/index.js +0 -52
- 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 -38
- package/dist/personas/index.d.ts +0 -23
- package/dist/personas/index.js +0 -78
- package/dist/personas/index.test.js +0 -124
- package/dist/personas/organization-audit/v1/index.d.ts +0 -8
- package/dist/personas/organization-audit/v1/index.js +0 -42
- package/dist/personas/persona.parity.test.js +0 -30
- package/dist/personas/semantic-layer/v1/index.d.ts +0 -8
- package/dist/personas/semantic-layer/v1/index.js +0 -32
- package/dist/personas/types.d.ts +0 -19
- /package/dist/{governance/client-capabilities-cache.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/{personas → profiles}/ai-agent-ops/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/evaluation.md +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/content-move.md +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/resources/playbooks.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/dashboards.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.js +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/compare.md +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/explain-run.md +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/access.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/content.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/core.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/deliveries.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/compose-compile.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/core.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/explore.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.d.ts +0 -0
package/dist/bin.js
CHANGED
|
@@ -33,17 +33,44 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const common_1 = require("@lightdash-tools/common");
|
|
36
37
|
const commander_1 = require("commander");
|
|
37
38
|
const program = new commander_1.Command();
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const DEFAULT_STDIO_PROFILE = 'semantic-layer';
|
|
40
|
+
const PROFILE_STDIO_DESCRIPTIONS = new Map([
|
|
41
|
+
['semantic-layer', 'Run semantic-layer profile on stdio'],
|
|
42
|
+
['organization-audit', 'Run organization-audit profile on stdio (read-only org governance)'],
|
|
43
|
+
[
|
|
44
|
+
'content-reader',
|
|
45
|
+
'Run content-reader profile on stdio (saved-content discovery and bounded execution)',
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
'content-developer',
|
|
49
|
+
'Run content-developer profile on stdio (chart/dashboard/space authoring behind preview -> validate -> apply)',
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
'content-governance',
|
|
53
|
+
'Run content-governance profile on stdio (elicitation-gated soft-delete of charts and dashboards)',
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
'ai-agent-ops',
|
|
57
|
+
'Run ai-agent-ops profile on stdio (thin AI-agent APIs and product evaluation runs)',
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
'data-analyst',
|
|
61
|
+
'Run data-analyst profile on stdio (explore discovery and bounded ad-hoc metric queries)',
|
|
62
|
+
],
|
|
63
|
+
]);
|
|
64
|
+
function profileStdioDescription(profileId) {
|
|
65
|
+
const description = PROFILE_STDIO_DESCRIPTIONS.get(profileId);
|
|
66
|
+
if (description === undefined) {
|
|
67
|
+
throw new Error(`Missing stdio description for profile '${profileId}'`);
|
|
68
|
+
}
|
|
69
|
+
return description;
|
|
70
|
+
}
|
|
71
|
+
function runStdio(profileId) {
|
|
72
|
+
if (profileId) {
|
|
73
|
+
process.env.LIGHTDASH_TOOLS_MCP_STDIO_PROFILE = profileId;
|
|
47
74
|
}
|
|
48
75
|
void Promise.resolve().then(() => __importStar(require('./index.js')));
|
|
49
76
|
}
|
|
@@ -52,64 +79,33 @@ function runHttp() {
|
|
|
52
79
|
}
|
|
53
80
|
program
|
|
54
81
|
.name('lightdash-mcp')
|
|
55
|
-
.description(
|
|
56
|
-
.version('0.
|
|
57
|
-
program
|
|
58
|
-
.command('stdio')
|
|
59
|
-
.description('Run MCP server on stdio with the default semantic-layer persona')
|
|
60
|
-
.action(() => {
|
|
61
|
-
runStdio(PERSONA_SEMANTIC_LAYER);
|
|
62
|
-
});
|
|
63
|
-
program
|
|
64
|
-
.command(PERSONA_SEMANTIC_LAYER)
|
|
65
|
-
.description('Run semantic-layer persona on stdio')
|
|
66
|
-
.action(() => {
|
|
67
|
-
runStdio(PERSONA_SEMANTIC_LAYER);
|
|
68
|
-
});
|
|
69
|
-
program
|
|
70
|
-
.command(PERSONA_ORGANIZATION_AUDIT)
|
|
71
|
-
.description('Run organization-audit persona on stdio (read-only org governance)')
|
|
72
|
-
.action(() => {
|
|
73
|
-
runStdio(PERSONA_ORGANIZATION_AUDIT);
|
|
74
|
-
});
|
|
82
|
+
.description(`MCP server for Lightdash (${common_1.PROFILE_IDS.join(', ')}). Default stdio profile is ${DEFAULT_STDIO_PROFILE}.`)
|
|
83
|
+
.version('0.12.0');
|
|
75
84
|
program
|
|
76
|
-
.command(
|
|
77
|
-
.description(
|
|
85
|
+
.command('stdio', { isDefault: true })
|
|
86
|
+
.description(`Run MCP server on stdio with the default ${DEFAULT_STDIO_PROFILE} profile`)
|
|
78
87
|
.action(() => {
|
|
79
|
-
runStdio(
|
|
80
|
-
});
|
|
81
|
-
program
|
|
82
|
-
.command(PERSONA_CONTENT_DEVELOPER)
|
|
83
|
-
.description('Run content-developer persona on stdio (chart/dashboard/space authoring behind preview -> validate -> apply)')
|
|
84
|
-
.action(() => {
|
|
85
|
-
runStdio(PERSONA_CONTENT_DEVELOPER);
|
|
86
|
-
});
|
|
87
|
-
program
|
|
88
|
-
.command(PERSONA_CONTENT_GOVERNANCE)
|
|
89
|
-
.description('Run content-governance persona on stdio (elicitation-gated soft-delete of charts and dashboards)')
|
|
90
|
-
.action(() => {
|
|
91
|
-
runStdio(PERSONA_CONTENT_GOVERNANCE);
|
|
88
|
+
runStdio(DEFAULT_STDIO_PROFILE);
|
|
92
89
|
});
|
|
90
|
+
for (const profileId of common_1.PROFILE_IDS) {
|
|
91
|
+
program
|
|
92
|
+
.command(profileId)
|
|
93
|
+
.description(profileStdioDescription(profileId))
|
|
94
|
+
.action(() => {
|
|
95
|
+
runStdio(profileId);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
93
98
|
program
|
|
94
|
-
.command(
|
|
95
|
-
.description('Run
|
|
99
|
+
.command('http')
|
|
100
|
+
.description('Run MCP server over Streamable HTTP (all fixed profile paths)')
|
|
96
101
|
.action(() => {
|
|
97
|
-
|
|
102
|
+
runHttp();
|
|
98
103
|
});
|
|
99
104
|
program
|
|
100
105
|
.command('serve-http')
|
|
101
|
-
.description('
|
|
106
|
+
.description('Deprecated alias for `http`')
|
|
102
107
|
.action(() => {
|
|
108
|
+
console.warn('Warning: `serve-http` is deprecated; use `lightdash-mcp http`.');
|
|
103
109
|
runHttp();
|
|
104
110
|
});
|
|
105
|
-
program
|
|
106
|
-
.option('--http', 'Run as HTTP server instead of Stdio (alias for serve-http)')
|
|
107
|
-
.action((options) => {
|
|
108
|
-
if (options.http) {
|
|
109
|
-
runHttp();
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
runStdio();
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
111
|
program.parse(process.argv);
|
package/dist/config/env.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
export declare const ENV_LIGHTDASH_TOOLS_MCP_HTTP_HOST = "LIGHTDASH_TOOLS_MCP_HTTP_HOST";
|
|
6
6
|
export declare const ENV_LIGHTDASH_TOOLS_MCP_HTTP_PORT = "LIGHTDASH_TOOLS_MCP_HTTP_PORT";
|
|
7
7
|
export declare const ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL = "LIGHTDASH_TOOLS_MCP_PUBLIC_URL";
|
|
8
|
-
/** Rejected at config load — MCP path is
|
|
8
|
+
/** Rejected at config load — MCP path is profile-owned (see profiles/). */
|
|
9
9
|
export declare const ENV_LIGHTDASH_TOOLS_MCP_PATH = "LIGHTDASH_TOOLS_MCP_PATH";
|
|
10
10
|
/** Rejected — auth mode is inferred from credentials (ADR-0007). */
|
|
11
11
|
export declare const ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = "LIGHTDASH_TOOLS_MCP_AUTH_MODE";
|
|
@@ -31,6 +31,8 @@ export declare const ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_UNAUTHENTICATED =
|
|
|
31
31
|
export declare const ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_ANY_ORIGIN = "LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_ANY_ORIGIN";
|
|
32
32
|
export declare const ENV_LIGHTDASH_TOOLS_MCP_EXPERIMENTAL_IDENTITY_OAUTH = "LIGHTDASH_TOOLS_MCP_EXPERIMENTAL_IDENTITY_OAUTH";
|
|
33
33
|
export declare const ENV_LIGHTDASH_TOOLS_MCP_ALLOW_INSECURE_PUBLIC_URL = "LIGHTDASH_TOOLS_MCP_ALLOW_INSECURE_PUBLIC_URL";
|
|
34
|
+
/** Obsolete stdio selector (renamed to LIGHTDASH_TOOLS_MCP_STDIO_PROFILE). */
|
|
35
|
+
export declare const ENV_LIGHTDASH_TOOLS_MCP_STDIO_PERSONA = "LIGHTDASH_TOOLS_MCP_STDIO_PERSONA";
|
|
34
36
|
/** Legacy aliases (deprecated). */
|
|
35
37
|
export declare const ENV_MCP_HTTP_PORT = "MCP_HTTP_PORT";
|
|
36
38
|
export declare const ENV_MCP_SERVER_PORT = "MCP_SERVER_PORT";
|
package/dist/config/env.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Legacy `MCP_*` aliases are resolved in load-mcp-config.ts.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.OAUTH_AUTHORIZATION_SERVER_METADATA_PATH = exports.OAUTH_REGISTER_PATH = exports.OAUTH_TOKEN_PATH = exports.OAUTH_AUTHORIZE_PATH = exports.OAUTH_CALLBACK_PATH = exports.ENV_MCP_MAX_BODY_BYTES = exports.ENV_MCP_ALLOWED_ORIGINS = exports.ENV_MCP_API_KEY = exports.ENV_MCP_AUTH_ENABLED = exports.ENV_MCP_PUBLIC_URL = exports.ENV_MCP_SERVER_PORT = exports.ENV_MCP_HTTP_PORT = exports.ENV_LIGHTDASH_TOOLS_MCP_ALLOW_INSECURE_PUBLIC_URL = exports.ENV_LIGHTDASH_TOOLS_MCP_EXPERIMENTAL_IDENTITY_OAUTH = exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_ANY_ORIGIN = exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_UNAUTHENTICATED = exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_GRANT_ALL_SCOPES = exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_SKIP_TOKEN_VALIDATION = exports.ENV_LIGHTDASH_TOOLS_MCP_INSECURE_DEV = exports.ENV_LIGHTDASH_TOOLS_MCP_REDIS_URL = exports.ENV_LIGHTDASH_TOOLS_MCP_STORE = exports.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET = exports.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_ID = exports.ENV_LIGHTDASH_TOOLS_MCP_TOKEN_VALIDATION_CACHE_TTL_MS = exports.ENV_LIGHTDASH_TOOLS_MCP_VALIDATE_TOKEN = exports.ENV_LIGHTDASH_TOOLS_MCP_SCOPES_SUPPORTED = exports.ENV_LIGHTDASH_TOOLS_MCP_REQUIRED_SCOPES = exports.ENV_LIGHTDASH_TOOLS_MCP_MAX_BODY_BYTES = exports.ENV_LIGHTDASH_TOOLS_MCP_ALLOWED_ORIGINS = exports.ENV_LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY = exports.ENV_LIGHTDASH_TOOLS_MCP_SHARED_KEY = exports.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = exports.ENV_LIGHTDASH_TOOLS_MCP_PATH = exports.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL = exports.ENV_LIGHTDASH_TOOLS_MCP_HTTP_PORT = exports.ENV_LIGHTDASH_TOOLS_MCP_HTTP_HOST = void 0;
|
|
7
|
+
exports.OAUTH_AUTHORIZATION_SERVER_METADATA_PATH = exports.OAUTH_REGISTER_PATH = exports.OAUTH_TOKEN_PATH = exports.OAUTH_AUTHORIZE_PATH = exports.OAUTH_CALLBACK_PATH = exports.ENV_MCP_MAX_BODY_BYTES = exports.ENV_MCP_ALLOWED_ORIGINS = exports.ENV_MCP_API_KEY = exports.ENV_MCP_AUTH_ENABLED = exports.ENV_MCP_PUBLIC_URL = exports.ENV_MCP_SERVER_PORT = exports.ENV_MCP_HTTP_PORT = exports.ENV_LIGHTDASH_TOOLS_MCP_STDIO_PERSONA = exports.ENV_LIGHTDASH_TOOLS_MCP_ALLOW_INSECURE_PUBLIC_URL = exports.ENV_LIGHTDASH_TOOLS_MCP_EXPERIMENTAL_IDENTITY_OAUTH = exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_ANY_ORIGIN = exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_UNAUTHENTICATED = exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_GRANT_ALL_SCOPES = exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_SKIP_TOKEN_VALIDATION = exports.ENV_LIGHTDASH_TOOLS_MCP_INSECURE_DEV = exports.ENV_LIGHTDASH_TOOLS_MCP_REDIS_URL = exports.ENV_LIGHTDASH_TOOLS_MCP_STORE = exports.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET = exports.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_ID = exports.ENV_LIGHTDASH_TOOLS_MCP_TOKEN_VALIDATION_CACHE_TTL_MS = exports.ENV_LIGHTDASH_TOOLS_MCP_VALIDATE_TOKEN = exports.ENV_LIGHTDASH_TOOLS_MCP_SCOPES_SUPPORTED = exports.ENV_LIGHTDASH_TOOLS_MCP_REQUIRED_SCOPES = exports.ENV_LIGHTDASH_TOOLS_MCP_MAX_BODY_BYTES = exports.ENV_LIGHTDASH_TOOLS_MCP_ALLOWED_ORIGINS = exports.ENV_LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY = exports.ENV_LIGHTDASH_TOOLS_MCP_SHARED_KEY = exports.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = exports.ENV_LIGHTDASH_TOOLS_MCP_PATH = exports.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL = exports.ENV_LIGHTDASH_TOOLS_MCP_HTTP_PORT = exports.ENV_LIGHTDASH_TOOLS_MCP_HTTP_HOST = void 0;
|
|
8
8
|
exports.ENV_LIGHTDASH_TOOLS_MCP_HTTP_HOST = 'LIGHTDASH_TOOLS_MCP_HTTP_HOST';
|
|
9
9
|
exports.ENV_LIGHTDASH_TOOLS_MCP_HTTP_PORT = 'LIGHTDASH_TOOLS_MCP_HTTP_PORT';
|
|
10
10
|
exports.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL = 'LIGHTDASH_TOOLS_MCP_PUBLIC_URL';
|
|
11
|
-
/** Rejected at config load — MCP path is
|
|
11
|
+
/** Rejected at config load — MCP path is profile-owned (see profiles/). */
|
|
12
12
|
exports.ENV_LIGHTDASH_TOOLS_MCP_PATH = 'LIGHTDASH_TOOLS_MCP_PATH';
|
|
13
13
|
/** Rejected — auth mode is inferred from credentials (ADR-0007). */
|
|
14
14
|
exports.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = 'LIGHTDASH_TOOLS_MCP_AUTH_MODE';
|
|
@@ -34,6 +34,8 @@ exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_UNAUTHENTICATED = 'LIGHTDASH_T
|
|
|
34
34
|
exports.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_ANY_ORIGIN = 'LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_ANY_ORIGIN';
|
|
35
35
|
exports.ENV_LIGHTDASH_TOOLS_MCP_EXPERIMENTAL_IDENTITY_OAUTH = 'LIGHTDASH_TOOLS_MCP_EXPERIMENTAL_IDENTITY_OAUTH';
|
|
36
36
|
exports.ENV_LIGHTDASH_TOOLS_MCP_ALLOW_INSECURE_PUBLIC_URL = 'LIGHTDASH_TOOLS_MCP_ALLOW_INSECURE_PUBLIC_URL';
|
|
37
|
+
/** Obsolete stdio selector (renamed to LIGHTDASH_TOOLS_MCP_STDIO_PROFILE). */
|
|
38
|
+
exports.ENV_LIGHTDASH_TOOLS_MCP_STDIO_PERSONA = 'LIGHTDASH_TOOLS_MCP_STDIO_PERSONA';
|
|
37
39
|
/** Legacy aliases (deprecated). */
|
|
38
40
|
exports.ENV_MCP_HTTP_PORT = 'MCP_HTTP_PORT';
|
|
39
41
|
exports.ENV_MCP_SERVER_PORT = 'MCP_SERVER_PORT';
|
|
@@ -6,23 +6,12 @@ exports.requiresLightdashApiKey = requiresLightdashApiKey;
|
|
|
6
6
|
exports.getOAuthCallbackUrl = getOAuthCallbackUrl;
|
|
7
7
|
const client_1 = require("@lightdash-tools/client");
|
|
8
8
|
const auth_mode_js_1 = require("../auth/auth-mode.js");
|
|
9
|
-
const index_js_1 = require("../
|
|
9
|
+
const index_js_1 = require("../profiles/index.js");
|
|
10
10
|
const env_js_1 = require("./env.js");
|
|
11
11
|
const normalize_url_js_1 = require("./normalize-url.js");
|
|
12
|
+
const obsolete_env_js_1 = require("./obsolete-env.js");
|
|
12
13
|
const public_url_js_1 = require("./public-url.js");
|
|
13
14
|
const DEFAULT_SCOPES_SUPPORTED = ['read', 'write', 'mcp:read', 'mcp:write'];
|
|
14
|
-
const OBSOLETE_ENV_VARS = [
|
|
15
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE,
|
|
16
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_EXPERIMENTAL_IDENTITY_OAUTH,
|
|
17
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_ANY_ORIGIN,
|
|
18
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_UNAUTHENTICATED,
|
|
19
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_GRANT_ALL_SCOPES,
|
|
20
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_SKIP_TOKEN_VALIDATION,
|
|
21
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_ALLOW_INSECURE_PUBLIC_URL,
|
|
22
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_INSECURE_DEV,
|
|
23
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_STORE,
|
|
24
|
-
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_REDIS_URL,
|
|
25
|
-
];
|
|
26
15
|
const warnedAliases = new Set();
|
|
27
16
|
function warnDeprecatedAlias(oldName, newName) {
|
|
28
17
|
if (warnedAliases.has(oldName))
|
|
@@ -88,23 +77,6 @@ function parseBooleanEnv(name, value, defaultValue) {
|
|
|
88
77
|
return false;
|
|
89
78
|
throw new Error(`Invalid ${name}: ${value}. Expected 1, true, yes, 0, false, or no.`);
|
|
90
79
|
}
|
|
91
|
-
function assertObsoleteEnvRejected(env) {
|
|
92
|
-
for (const name of OBSOLETE_ENV_VARS) {
|
|
93
|
-
if (readEnv(name, env) !== undefined) {
|
|
94
|
-
if (name === env_js_1.ENV_LIGHTDASH_TOOLS_MCP_STORE || name === env_js_1.ENV_LIGHTDASH_TOOLS_MCP_REDIS_URL) {
|
|
95
|
-
throw new Error(`${name} is removed (ADR-0019). ` +
|
|
96
|
-
`MCP HTTP is now stateless (sessionless) and has no Redis ephemeral store. ` +
|
|
97
|
-
`Remove this variable from your environment.`);
|
|
98
|
-
}
|
|
99
|
-
throw new Error(`${name} is removed. Auth is inferred from credentials: set ` +
|
|
100
|
-
`${env_js_1.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_ID}, ${env_js_1.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET}, ` +
|
|
101
|
-
`and ${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL} for hosted OAuth; ` +
|
|
102
|
-
`or ${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_SHARED_KEY} + LIGHTDASH_API_KEY for shared-key; ` +
|
|
103
|
-
`or NODE_ENV=development for local unauthenticated HTTP. ` +
|
|
104
|
-
`See docs/mcp-oauth-http.md and ADR-0007.`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
80
|
function inferAuthMode(params) {
|
|
109
81
|
const { env, oauthClientId, oauthClientSecret, publicUrlRaw, sharedKeyRaw } = params;
|
|
110
82
|
const hasOAuthId = Boolean(oauthClientId);
|
|
@@ -158,7 +130,7 @@ function assertLightdashOAuthScopePolicy(authMode, requiredScopes, scopesSupport
|
|
|
158
130
|
}
|
|
159
131
|
if (requiredScopes.length > 0) {
|
|
160
132
|
throw new Error(`${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_REQUIRED_SCOPES} cannot be set in OAuth broker mode. ` +
|
|
161
|
-
`Leave it unset and rely on Lightdash RBAC plus the
|
|
133
|
+
`Leave it unset and rely on Lightdash RBAC plus the profile tool surface (ADR-0006).`);
|
|
162
134
|
}
|
|
163
135
|
if (scopesSupportedEnvSet) {
|
|
164
136
|
throw new Error(`${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_SCOPES_SUPPORTED} cannot be set in OAuth broker mode. ` +
|
|
@@ -195,7 +167,7 @@ function emitCorsSecurityWarnings(config) {
|
|
|
195
167
|
if (config.allowedOrigins.length > 0) {
|
|
196
168
|
return;
|
|
197
169
|
}
|
|
198
|
-
console.warn(`Warning: ${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_ALLOWED_ORIGINS} is empty —
|
|
170
|
+
console.warn(`Warning: ${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_ALLOWED_ORIGINS} is empty — profile MCP routes do not reflect browser Origins. ` +
|
|
199
171
|
'OAuth broker/discovery routes still reflect Origin.');
|
|
200
172
|
}
|
|
201
173
|
function emitMcpHttpSecurityWarnings(config) {
|
|
@@ -249,9 +221,9 @@ function loadMcpHttpConfig(env = process.env) {
|
|
|
249
221
|
}
|
|
250
222
|
if (readEnv(env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PATH, env) !== undefined) {
|
|
251
223
|
throw new Error(`${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PATH} is unused and rejected. ` +
|
|
252
|
-
`The MCP endpoint path is
|
|
224
|
+
`The MCP endpoint path is profile-owned (${(0, index_js_1.getDefaultProfile)().path}); leave this variable unset.`);
|
|
253
225
|
}
|
|
254
|
-
assertObsoleteEnvRejected(env);
|
|
226
|
+
(0, obsolete_env_js_1.assertObsoleteEnvRejected)(env);
|
|
255
227
|
const { oauthClientId, oauthClientSecretRaw, publicUrlRaw, sharedKeyRaw, authMode } = readHttpAuthInputs(env);
|
|
256
228
|
if (authMode === auth_mode_js_1.MCP_AUTH_MODE_SHARED_KEY && !sharedKeyRaw) {
|
|
257
229
|
throw new Error(`${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_SHARED_KEY} is required for shared-key HTTP auth ` +
|
|
@@ -262,8 +234,8 @@ function loadMcpHttpConfig(env = process.env) {
|
|
|
262
234
|
]);
|
|
263
235
|
const allowedOrigins = parseCsv(allowedOriginsRaw);
|
|
264
236
|
const proxyAuth = readEnv(client_1.ENV_LIGHTDASH_PROXY_AUTHORIZATION, env);
|
|
265
|
-
const mcpPath = (0, index_js_1.
|
|
266
|
-
const publicUrl = publicUrlRaw ? (0, normalize_url_js_1.normalizePublicUrl)(publicUrlRaw, (0, index_js_1.
|
|
237
|
+
const mcpPath = (0, index_js_1.getDefaultProfile)().path;
|
|
238
|
+
const publicUrl = publicUrlRaw ? (0, normalize_url_js_1.normalizePublicUrl)(publicUrlRaw, (0, index_js_1.listProfilePaths)()) : undefined;
|
|
267
239
|
assertPublicUrlSecurity(authMode, publicUrl);
|
|
268
240
|
const validateToken = parseBooleanEnv(env_js_1.ENV_LIGHTDASH_TOOLS_MCP_VALIDATE_TOKEN, readEnv(env_js_1.ENV_LIGHTDASH_TOOLS_MCP_VALIDATE_TOKEN, env), authMode === auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH);
|
|
269
241
|
assertValidateTokenPolicy(authMode, validateToken, env);
|
|
@@ -51,14 +51,14 @@ function setOAuthCreds() {
|
|
|
51
51
|
(0, vitest_1.expect)((0, load_mcp_config_js_1.getOAuthCallbackUrl)(config)).toBe('https://mcp.example.com/oauth/callback');
|
|
52
52
|
(0, vitest_1.expect)(config.scopesSupported).toEqual([]);
|
|
53
53
|
});
|
|
54
|
-
(0, vitest_1.it)('strips organization-audit
|
|
54
|
+
(0, vitest_1.it)('strips organization-audit profile path from public URL', () => {
|
|
55
55
|
setOAuthCreds();
|
|
56
56
|
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL] =
|
|
57
57
|
'https://mcp.example.com/organization-audit/v1/mcp';
|
|
58
58
|
const config = (0, load_mcp_config_js_1.loadMcpHttpConfig)();
|
|
59
59
|
(0, vitest_1.expect)(config.publicUrl).toBe('https://mcp.example.com');
|
|
60
60
|
});
|
|
61
|
-
(0, vitest_1.it)('strips content-reader
|
|
61
|
+
(0, vitest_1.it)('strips content-reader profile path from public URL', () => {
|
|
62
62
|
setOAuthCreds();
|
|
63
63
|
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL] =
|
|
64
64
|
'https://mcp.example.com/content-reader/v1/mcp';
|
|
@@ -131,6 +131,12 @@ function setOAuthCreds() {
|
|
|
131
131
|
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_INSECURE_DEV] = '1';
|
|
132
132
|
(0, vitest_1.expect)(() => (0, load_mcp_config_js_1.loadMcpHttpConfig)()).toThrow(/is removed/);
|
|
133
133
|
});
|
|
134
|
+
(0, vitest_1.it)('rejects obsolete STDIO_PERSONA env', () => {
|
|
135
|
+
process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
|
|
136
|
+
process.env.NODE_ENV = 'development';
|
|
137
|
+
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_STDIO_PERSONA] = 'semantic-layer';
|
|
138
|
+
(0, vitest_1.expect)(() => (0, load_mcp_config_js_1.loadMcpHttpConfig)()).toThrow(/STDIO_PROFILE/);
|
|
139
|
+
});
|
|
134
140
|
(0, vitest_1.it)('rejects non-HTTPS public URL in OAuth mode', () => {
|
|
135
141
|
setOAuthCreds();
|
|
136
142
|
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL] = 'http://mcp.example.com';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Strips trailing slashes from a URL. */
|
|
2
2
|
export declare function stripTrailingSlash(url: string): string;
|
|
3
3
|
/**
|
|
4
|
-
* Normalizes a public MCP base URL: no trailing slash, no
|
|
4
|
+
* Normalizes a public MCP base URL: no trailing slash, no profile MCP path suffix.
|
|
5
5
|
* Longer suffixes are tried first so nested paths strip correctly.
|
|
6
6
|
*/
|
|
7
7
|
export declare function normalizePublicUrl(url: string, mcpPaths: readonly string[]): string;
|
|
@@ -10,7 +10,7 @@ function stripTrailingSlash(url) {
|
|
|
10
10
|
return url.replace(/\/+$/, '');
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* Normalizes a public MCP base URL: no trailing slash, no
|
|
13
|
+
* Normalizes a public MCP base URL: no trailing slash, no profile MCP path suffix.
|
|
14
14
|
* Longer suffixes are tried first so nested paths strip correctly.
|
|
15
15
|
*/
|
|
16
16
|
function normalizePublicUrl(url, mcpPaths) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const vitest_1 = require("vitest");
|
|
4
|
-
const index_js_1 = require("../
|
|
5
|
-
const index_js_2 = require("../
|
|
6
|
-
const index_js_3 = require("../
|
|
7
|
-
const index_js_4 = require("../
|
|
4
|
+
const index_js_1 = require("../profiles/ai-agent-ops/v1/index.js");
|
|
5
|
+
const index_js_2 = require("../profiles/content-reader/v1/index.js");
|
|
6
|
+
const index_js_3 = require("../profiles/organization-audit/v1/index.js");
|
|
7
|
+
const index_js_4 = require("../profiles/semantic-layer/v1/index.js");
|
|
8
8
|
const normalize_url_js_1 = require("./normalize-url.js");
|
|
9
9
|
(0, vitest_1.describe)('normalizeMcpPath', () => {
|
|
10
10
|
(0, vitest_1.it)('adds a leading slash when missing', () => {
|
|
@@ -30,21 +30,21 @@ const normalize_url_js_1 = require("./normalize-url.js");
|
|
|
30
30
|
(0, vitest_1.it)('leaves origin-only URLs unchanged', () => {
|
|
31
31
|
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)('https://mcp.example.com', ['/custom/mcp'])).toBe('https://mcp.example.com');
|
|
32
32
|
});
|
|
33
|
-
(0, vitest_1.it)('strips the semantic-layer
|
|
34
|
-
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_4.
|
|
35
|
-
index_js_4.
|
|
33
|
+
(0, vitest_1.it)('strips the semantic-layer profile path', () => {
|
|
34
|
+
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_4.SEMANTIC_LAYER_PROFILE_PATH}/`, [
|
|
35
|
+
index_js_4.SEMANTIC_LAYER_PROFILE_PATH,
|
|
36
36
|
])).toBe('https://mcp.example.com');
|
|
37
37
|
});
|
|
38
|
-
(0, vitest_1.it)('strips any known
|
|
38
|
+
(0, vitest_1.it)('strips any known profile path when given a path list', () => {
|
|
39
39
|
const paths = [
|
|
40
|
-
index_js_4.
|
|
41
|
-
index_js_3.
|
|
42
|
-
index_js_2.
|
|
43
|
-
index_js_1.
|
|
40
|
+
index_js_4.SEMANTIC_LAYER_PROFILE_PATH,
|
|
41
|
+
index_js_3.ORGANIZATION_AUDIT_PROFILE_PATH,
|
|
42
|
+
index_js_2.CONTENT_READER_PROFILE_PATH,
|
|
43
|
+
index_js_1.AI_AGENT_OPS_PROFILE_PATH,
|
|
44
44
|
];
|
|
45
|
-
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_3.
|
|
46
|
-
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_4.
|
|
47
|
-
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_2.
|
|
48
|
-
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_1.
|
|
45
|
+
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_3.ORGANIZATION_AUDIT_PROFILE_PATH}`, paths)).toBe('https://mcp.example.com');
|
|
46
|
+
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_4.SEMANTIC_LAYER_PROFILE_PATH}/`, paths)).toBe('https://mcp.example.com');
|
|
47
|
+
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_2.CONTENT_READER_PROFILE_PATH}`, paths)).toBe('https://mcp.example.com');
|
|
48
|
+
(0, vitest_1.expect)((0, normalize_url_js_1.normalizePublicUrl)(`https://mcp.example.com${index_js_1.AI_AGENT_OPS_PROFILE_PATH}`, paths)).toBe('https://mcp.example.com');
|
|
49
49
|
});
|
|
50
50
|
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Reject obsolete MCP env vars fail-closed (shared by stdio + HTTP startup).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.assertObsoleteEnvRejected = assertObsoleteEnvRejected;
|
|
7
|
+
const env_js_1 = require("./env.js");
|
|
8
|
+
const OBSOLETE_ENV_VARS = [
|
|
9
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE,
|
|
10
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_EXPERIMENTAL_IDENTITY_OAUTH,
|
|
11
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_ANY_ORIGIN,
|
|
12
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_ALLOW_UNAUTHENTICATED,
|
|
13
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_GRANT_ALL_SCOPES,
|
|
14
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_DANGEROUSLY_SKIP_TOKEN_VALIDATION,
|
|
15
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_ALLOW_INSECURE_PUBLIC_URL,
|
|
16
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_INSECURE_DEV,
|
|
17
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_STORE,
|
|
18
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_REDIS_URL,
|
|
19
|
+
env_js_1.ENV_LIGHTDASH_TOOLS_MCP_STDIO_PERSONA,
|
|
20
|
+
];
|
|
21
|
+
function readEnv(name, env) {
|
|
22
|
+
// eslint-disable-next-line security/detect-object-injection -- env var names are fixed constants
|
|
23
|
+
const value = env[name];
|
|
24
|
+
if (value === undefined || value === '')
|
|
25
|
+
return undefined;
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
/** Fail closed when operators still set removed MCP env vars. */
|
|
29
|
+
function assertObsoleteEnvRejected(env = process.env) {
|
|
30
|
+
for (const name of OBSOLETE_ENV_VARS) {
|
|
31
|
+
if (readEnv(name, env) !== undefined) {
|
|
32
|
+
if (name === env_js_1.ENV_LIGHTDASH_TOOLS_MCP_STORE || name === env_js_1.ENV_LIGHTDASH_TOOLS_MCP_REDIS_URL) {
|
|
33
|
+
throw new Error(`${name} is removed (ADR-0019). ` +
|
|
34
|
+
`MCP HTTP is now stateless (sessionless) and has no Redis ephemeral store. ` +
|
|
35
|
+
`Remove this variable from your environment.`);
|
|
36
|
+
}
|
|
37
|
+
if (name === env_js_1.ENV_LIGHTDASH_TOOLS_MCP_STDIO_PERSONA) {
|
|
38
|
+
throw new Error(`${name} is removed. Use LIGHTDASH_TOOLS_MCP_STDIO_PROFILE or a stdio subcommand (for example: lightdash-mcp semantic-layer).`);
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`${name} is removed. Auth is inferred from credentials: set ` +
|
|
41
|
+
`${env_js_1.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_ID}, ${env_js_1.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET}, ` +
|
|
42
|
+
`and ${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL} for hosted OAuth; ` +
|
|
43
|
+
`or ${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_SHARED_KEY} + LIGHTDASH_API_KEY for shared-key; ` +
|
|
44
|
+
`or NODE_ENV=development for local unauthenticated HTTP. ` +
|
|
45
|
+
`See docs/operators/mcp-oauth.md and ADR-0007.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const env_js_1 = require("./env.js");
|
|
5
|
+
const obsolete_env_js_1 = require("./obsolete-env.js");
|
|
6
|
+
(0, vitest_1.describe)('assertObsoleteEnvRejected', () => {
|
|
7
|
+
(0, vitest_1.afterEach)(() => {
|
|
8
|
+
delete process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE];
|
|
9
|
+
delete process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_STDIO_PERSONA];
|
|
10
|
+
});
|
|
11
|
+
(0, vitest_1.it)('rejects obsolete AUTH_MODE env', () => {
|
|
12
|
+
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE] = 'lightdash-oauth';
|
|
13
|
+
(0, vitest_1.expect)(() => (0, obsolete_env_js_1.assertObsoleteEnvRejected)()).toThrow(/is removed/);
|
|
14
|
+
});
|
|
15
|
+
(0, vitest_1.it)('allows unset obsolete vars', () => {
|
|
16
|
+
(0, vitest_1.expect)(() => (0, obsolete_env_js_1.assertObsoleteEnvRejected)({})).not.toThrow();
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.it)('rejects obsolete STDIO_PERSONA env', () => {
|
|
19
|
+
process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_STDIO_PERSONA] = 'semantic-layer';
|
|
20
|
+
(0, vitest_1.expect)(() => (0, obsolete_env_js_1.assertObsoleteEnvRejected)()).toThrow(/STDIO_PROFILE/);
|
|
21
|
+
});
|
|
22
|
+
});
|
package/dist/config/runtime.js
CHANGED
|
@@ -24,7 +24,7 @@ function warnIgnoredCliGuardrailEnvVars(env = process.env, warn = console.warn)
|
|
|
24
24
|
}
|
|
25
25
|
if (ignored.length > 0) {
|
|
26
26
|
warn(`Warning: ${ignored.join(', ')} ${ignored.length === 1 ? 'is' : 'are'} set but ignored by MCP. ` +
|
|
27
|
-
'Those variables apply to the CLI only. MCP uses
|
|
27
|
+
'Those variables apply to the CLI only. MCP uses catalog profile membership + auth/RBAC + optional ' +
|
|
28
28
|
`${common_1.ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS} + optional X-Lightdash-Project (ADR-0008).`);
|
|
29
29
|
}
|
|
30
30
|
const removedDefault = env.LIGHTDASH_TOOLS_PROJECT_UUID;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Shared project allowlist for MCP (ADR-0008).
|
|
3
3
|
*
|
|
4
4
|
* Canonical: `LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS` (same env as CLI).
|
|
5
|
-
* Unset/empty → unrestricted. Non-empty → hard ceiling for all
|
|
5
|
+
* Unset/empty → unrestricted. Non-empty → hard ceiling for all profiles.
|
|
6
6
|
* UUIDs normalized to lowercase; invalid / empty segments fail closed.
|
|
7
7
|
*
|
|
8
8
|
* Removed envs fail at startup if still set:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Shared project allowlist for MCP (ADR-0008).
|
|
4
4
|
*
|
|
5
5
|
* Canonical: `LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS` (same env as CLI).
|
|
6
|
-
* Unset/empty → unrestricted. Non-empty → hard ceiling for all
|
|
6
|
+
* Unset/empty → unrestricted. Non-empty → hard ceiling for all profiles.
|
|
7
7
|
* UUIDs normalized to lowercase; invalid / empty segments fail closed.
|
|
8
8
|
*
|
|
9
9
|
* Removed envs fail at startup if still set:
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-POST store for the process-lifetime `createMcpHandler` factory.
|
|
3
|
+
* Auth / Origin / pin stay outside the handler; the factory only needs
|
|
4
|
+
* contextProvider + profile (ADR-0019).
|
|
5
|
+
*/
|
|
6
|
+
import type { ProfileDefinition } from '../profiles/types.js';
|
|
7
|
+
import type { McpContextProvider } from '../server/request-context.js';
|
|
8
|
+
export type McpPostFactoryStore = {
|
|
9
|
+
contextProvider: McpContextProvider;
|
|
10
|
+
profile: ProfileDefinition;
|
|
11
|
+
};
|
|
12
|
+
export declare function getMcpPostFactoryStore(): McpPostFactoryStore | undefined;
|
|
13
|
+
export declare function runWithMcpPostFactoryAsync<T>(store: McpPostFactoryStore, fn: () => Promise<T>): Promise<T>;
|
|
14
|
+
/** Sync variant for adapters that invoke the factory synchronously. */
|
|
15
|
+
export declare function runWithMcpPostFactorySync<T>(store: McpPostFactoryStore, fn: () => T): T;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Per-POST store for the process-lifetime `createMcpHandler` factory.
|
|
4
|
+
* Auth / Origin / pin stay outside the handler; the factory only needs
|
|
5
|
+
* contextProvider + profile (ADR-0019).
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getMcpPostFactoryStore = getMcpPostFactoryStore;
|
|
9
|
+
exports.runWithMcpPostFactoryAsync = runWithMcpPostFactoryAsync;
|
|
10
|
+
exports.runWithMcpPostFactorySync = runWithMcpPostFactorySync;
|
|
11
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
12
|
+
const mcpPostFactoryAls = new node_async_hooks_1.AsyncLocalStorage();
|
|
13
|
+
function getMcpPostFactoryStore() {
|
|
14
|
+
return mcpPostFactoryAls.getStore();
|
|
15
|
+
}
|
|
16
|
+
function runWithMcpPostFactoryAsync(store, fn) {
|
|
17
|
+
return mcpPostFactoryAls.run(store, fn);
|
|
18
|
+
}
|
|
19
|
+
/** Sync variant for adapters that invoke the factory synchronously. */
|
|
20
|
+
function runWithMcpPostFactorySync(store, fn) {
|
|
21
|
+
return mcpPostFactoryAls.run(store, fn);
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const mcp_post_factory_context_js_1 = require("./mcp-post-factory-context.js");
|
|
5
|
+
function stubStore(id) {
|
|
6
|
+
return {
|
|
7
|
+
contextProvider: { getContext: async () => ({}) },
|
|
8
|
+
profile: { id },
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
(0, vitest_1.describe)('mcp-post-factory-context ALS', () => {
|
|
12
|
+
(0, vitest_1.it)('isolates overlapping async runs by profile id', async () => {
|
|
13
|
+
const seen = [];
|
|
14
|
+
await Promise.all([
|
|
15
|
+
(0, mcp_post_factory_context_js_1.runWithMcpPostFactoryAsync)(stubStore('a'), async () => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
await new Promise((r) => setTimeout(r, 20));
|
|
18
|
+
seen.push((_b = (_a = (0, mcp_post_factory_context_js_1.getMcpPostFactoryStore)()) === null || _a === void 0 ? void 0 : _a.profile.id) !== null && _b !== void 0 ? _b : 'missing');
|
|
19
|
+
}),
|
|
20
|
+
(0, mcp_post_factory_context_js_1.runWithMcpPostFactoryAsync)(stubStore('b'), async () => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
23
|
+
seen.push((_b = (_a = (0, mcp_post_factory_context_js_1.getMcpPostFactoryStore)()) === null || _a === void 0 ? void 0 : _a.profile.id) !== null && _b !== void 0 ? _b : 'missing');
|
|
24
|
+
}),
|
|
25
|
+
]);
|
|
26
|
+
(0, vitest_1.expect)(seen.sort()).toEqual(['a', 'b']);
|
|
27
|
+
});
|
|
28
|
+
(0, vitest_1.it)('exposes store inside sync factory callback', () => {
|
|
29
|
+
const store = stubStore('sync');
|
|
30
|
+
const got = (0, mcp_post_factory_context_js_1.runWithMcpPostFactorySync)(store, () => { var _a; return (_a = (0, mcp_post_factory_context_js_1.getMcpPostFactoryStore)()) === null || _a === void 0 ? void 0 : _a.profile.id; });
|
|
31
|
+
(0, vitest_1.expect)(got).toBe('sync');
|
|
32
|
+
(0, vitest_1.expect)((0, mcp_post_factory_context_js_1.getMcpPostFactoryStore)()).toBeUndefined();
|
|
33
|
+
});
|
|
34
|
+
});
|