@lightdash-tools/mcp 0.13.2 → 0.14.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.
Files changed (39) hide show
  1. package/README.md +24 -7
  2. package/dist/auth/request-state-key.d.ts +1 -1
  3. package/dist/auth/request-state-key.js +1 -1
  4. package/dist/auth/resource-server/oauth-protected-resource.d.ts +2 -2
  5. package/dist/auth/resource-server/oauth-protected-resource.js +8 -7
  6. package/dist/bin.js +1 -1
  7. package/dist/config/enabled-profiles.d.ts +23 -0
  8. package/dist/config/enabled-profiles.js +57 -0
  9. package/dist/config/enabled-profiles.test.d.ts +1 -0
  10. package/dist/config/enabled-profiles.test.js +62 -0
  11. package/dist/config/env.d.ts +2 -0
  12. package/dist/config/env.js +3 -1
  13. package/dist/config/load-mcp-config.d.ts +3 -0
  14. package/dist/config/load-mcp-config.js +4 -1
  15. package/dist/config/load-mcp-config.test.js +41 -0
  16. package/dist/config/test-mcp-http-config.js +4 -1
  17. package/dist/http.integration.test.js +47 -24
  18. package/dist/index.integration.test.js +3 -12
  19. package/dist/profiles/content-developer/v1/resources/playbooks/chart-types.md +2 -1
  20. package/dist/profiles/content-developer/v1/resources/playbooks/core.md +2 -1
  21. package/dist/profiles/content-developer/v1/resources/playbooks/dashboard-design.md +11 -1
  22. package/dist/profiles/content-developer/v1/resources/playbooks/dashboards.md +1 -1
  23. package/dist/profiles/content-developer/v1/resources/playbooks/table-calculations.md +15 -3
  24. package/dist/profiles/content-developer/v1/resources/playbooks.js +1 -0
  25. package/dist/profiles/content-reader/v1/index.js +1 -0
  26. package/dist/profiles/content-reader/v1/prompts.js +10 -9
  27. package/dist/profiles/content-reader/v1/resources/playbooks/compare.md +1 -1
  28. package/dist/profiles/content-reader/v1/resources/playbooks/core.md +1 -0
  29. package/dist/profiles/content-reader/v1/resources/playbooks/discover.md +12 -3
  30. package/dist/profiles/content-reader/v1/resources/playbooks/explain-run.md +2 -1
  31. package/dist/profiles/index.d.ts +2 -1
  32. package/dist/profiles/index.js +2 -1
  33. package/dist/profiles/index.test.js +2 -1
  34. package/dist/stdio.process.test.js +2 -1
  35. package/dist/tools/project/reader-content.d.ts +2 -0
  36. package/dist/tools/project/reader-content.js +28 -1
  37. package/dist/transports/streamable-http.js +6 -3
  38. package/dist/transports/streamable-http.test.js +16 -0
  39. package/package.json +3 -3
package/README.md CHANGED
@@ -55,7 +55,7 @@ Or install globally: `npm install -g @lightdash-tools/mcp`, then `lightdash-mcp
55
55
 
56
56
  ### Streamable HTTP (remote)
57
57
 
58
- `http` mounts **every** fixed path from the profile table (no `--profile`); clients pick the path in the URL.
58
+ `http` mounts every fixed path from the profile table by default (no `--profile`); clients pick the path in the URL. Optionally restrict mounts with `LIGHTDASH_TOOLS_MCP_PROFILES` (comma-separated profile ids; unset or empty → all).
59
59
 
60
60
  ```bash
61
61
  export LIGHTDASH_URL="https://app.lightdash.cloud"
@@ -87,9 +87,9 @@ Do **not** set OAuth client secrets for stdio. MCP ignores CLI `SAFETY_MODE` / `
87
87
 
88
88
  ### HTTP OAuth (primary)
89
89
 
90
- | Required | Common optional |
91
- | :-------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------ |
92
- | `LIGHTDASH_URL`, `LIGHTDASH_TOOLS_MCP_PUBLIC_URL`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_ID`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET` | port, `ALLOWED_ORIGINS`, [`LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS`](#project-allowlist), token cache TTL |
90
+ | Required | Common optional |
91
+ | :-------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------ |
92
+ | `LIGHTDASH_URL`, `LIGHTDASH_TOOLS_MCP_PUBLIC_URL`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_ID`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET` | port, `ALLOWED_ORIGINS`, [`LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS`](#project-allowlist), [`LIGHTDASH_TOOLS_MCP_PROFILES`](#profile-allowlist), token cache TTL |
93
93
 
94
94
  On Cloud Run / hosted HTTP, leave `LIGHTDASH_TOOLS_AUDIT_LOG` unset — tool audits are stderr JSON (`channel: "audit"`) → Cloud Logging. See [cloud-run.md](../../docs/operators/cloud-run.md).
95
95
 
@@ -97,9 +97,9 @@ Register Lightdash redirect URI: `{PUBLIC_URL}/oauth/callback`. Clients connect
97
97
 
98
98
  ### Content-developer / content-governance signing
99
99
 
100
- | Required (non-test) | Notes |
101
- | :-------------------------------------- | :---------------------------------------------------------------------------------------------- |
102
- | `LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY` | ≥32-byte secret for HMAC `previewToken` / `requestState` (fail closed if unset; not encryption) |
100
+ | Required (non-test) | Notes |
101
+ | :-------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
102
+ | `LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY` | ≥32-byte secret for HMAC `previewToken` / `requestState` (fail closed if unset; not encryption). Required only when `content-developer` or `content-governance` is mounted (including unrestricted HTTP). |
103
103
 
104
104
  Governance soft-delete needs client form elicitation; missing capability → `ELICITATION_REQUIRED`.
105
105
 
@@ -110,6 +110,23 @@ Governance soft-delete needs client form elicitation; missing capability → `EL
110
110
  | Shared-key | `LIGHTDASH_API_KEY` + `LIGHTDASH_TOOLS_MCP_SHARED_KEY` |
111
111
  | Local none | `NODE_ENV=development` (not `production`) |
112
112
 
113
+ ### Profile allowlist
114
+
115
+ Optional HTTP-only mount ceiling. Unset or empty → all seven shipped profile paths. Non-empty → only listed profile ids are mounted; other paths (and their path-specific OAuth PRM) 404. Stdio ignores this variable (`stdio --profile` still required).
116
+
117
+ **Format**
118
+
119
+ - Comma-separated profile ids from the table above (`semantic-layer`, `content-reader`, …)
120
+ - Whitespace around commas is ignored
121
+ - No empty segments (double commas are rejected)
122
+ - Unknown ids fail at process startup
123
+
124
+ ```bash
125
+ export LIGHTDASH_TOOLS_MCP_PROFILES="content-reader,content-developer"
126
+ ```
127
+
128
+ Architecture: [ADR-0024](../../docs/adr/0024-mcp-http-profile-mount-allowlist-via-env.md).
129
+
113
130
  ### Project allowlist
114
131
 
115
132
  Optional deployment ceiling shared with the CLI. Unset or empty → unrestricted beyond RBAC, HTTP pin, and tool `projectUuid`. Non-empty → hard allowlist for all profiles.
@@ -5,7 +5,7 @@
5
5
  import { ENV_LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY } from '../config/env.js';
6
6
  export declare const PREVIEW_TOKEN_KEY_PURPOSE = "content-developer preview tokens are enabled";
7
7
  export declare const DESTRUCTIVE_REQUEST_STATE_KEY_PURPOSE = "content-governance destructive tools are enabled";
8
- /** HTTP ships all profiles; preview + destructive elicitation share one signing key. */
8
+ /** Preview + destructive elicitation share one signing key when write profiles are mounted. */
9
9
  export declare const HTTP_SIGNED_STATE_KEY_PURPOSE = "HTTP MCP exposes content-developer preview tokens and content-governance destructive tools";
10
10
  /** Resolve the HMAC signing key (configured env or test fallback). */
11
11
  export declare function resolveRequestStateKey(purpose: string): string;
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "ENV_LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY", { en
13
13
  const TEST_FALLBACK_KEY = 'lightdash-tools-dev-request-state-key!!';
14
14
  exports.PREVIEW_TOKEN_KEY_PURPOSE = 'content-developer preview tokens are enabled';
15
15
  exports.DESTRUCTIVE_REQUEST_STATE_KEY_PURPOSE = 'content-governance destructive tools are enabled';
16
- /** HTTP ships all profiles; preview + destructive elicitation share one signing key. */
16
+ /** Preview + destructive elicitation share one signing key when write profiles are mounted. */
17
17
  exports.HTTP_SIGNED_STATE_KEY_PURPOSE = 'HTTP MCP exposes content-developer preview tokens and content-governance destructive tools';
18
18
  function isTestRuntime() {
19
19
  return process.env.VITEST === 'true' || process.env.NODE_ENV === 'test';
@@ -17,8 +17,8 @@ export declare function getProtectedResourceMetadataUrl(config: McpHttpConfig):
17
17
  export declare function getProtectedResourceMetadataPathUrl(config: McpHttpConfig, mcpPath: string): string;
18
18
  /**
19
19
  * Resolves the profile MCP path for a PRM well-known request.
20
- * Root PRM maps to the default profile (`config.mcpPath`); path-specific PRM
21
- * is served only for shipped profile paths.
20
+ * Root PRM maps to `config.mcpPath`; path-specific PRM is served only for
21
+ * enabled shipped profile paths (ADR-0024).
22
22
  */
23
23
  export declare function resolveProtectedResourceMcpPath(path: string, config: McpHttpConfig): string | undefined;
24
24
  /** Well-known OAuth Authorization Server Metadata URL for an AS origin. */
@@ -6,6 +6,7 @@ exports.getProtectedResourceMetadataUrl = getProtectedResourceMetadataUrl;
6
6
  exports.getProtectedResourceMetadataPathUrl = getProtectedResourceMetadataPathUrl;
7
7
  exports.resolveProtectedResourceMcpPath = resolveProtectedResourceMcpPath;
8
8
  exports.getAuthorizationServerMetadataUrl = getAuthorizationServerMetadataUrl;
9
+ const enabled_profiles_js_1 = require("../../config/enabled-profiles.js");
9
10
  const env_js_1 = require("../../config/env.js");
10
11
  const normalize_url_js_1 = require("../../config/normalize-url.js");
11
12
  const public_url_js_1 = require("../../config/public-url.js");
@@ -42,14 +43,10 @@ function getProtectedResourceMetadataPathUrl(config, mcpPath) {
42
43
  }
43
44
  /**
44
45
  * Resolves the profile MCP path for a PRM well-known request.
45
- * Root PRM maps to the default profile (`config.mcpPath`); path-specific PRM
46
- * is served only for shipped profile paths.
46
+ * Root PRM maps to `config.mcpPath`; path-specific PRM is served only for
47
+ * enabled shipped profile paths (ADR-0024).
47
48
  */
48
49
  function resolveProtectedResourceMcpPath(path, config) {
49
- var _a;
50
- if (!path.startsWith(exports.OAUTH_PROTECTED_RESOURCE_ROOT)) {
51
- return undefined;
52
- }
53
50
  if (path === exports.OAUTH_PROTECTED_RESOURCE_ROOT) {
54
51
  return config.mcpPath;
55
52
  }
@@ -58,7 +55,11 @@ function resolveProtectedResourceMcpPath(path, config) {
58
55
  return undefined;
59
56
  }
60
57
  const resourcePath = `/${path.slice(prefix.length)}`;
61
- return (_a = (0, index_js_1.getProfileByPath)(resourcePath)) === null || _a === void 0 ? void 0 : _a.path;
58
+ const profile = (0, index_js_1.getProfileByPath)(resourcePath);
59
+ if (!profile || !(0, enabled_profiles_js_1.isProfileEnabled)(config.enabledProfiles, profile.id)) {
60
+ return undefined;
61
+ }
62
+ return profile.path;
62
63
  }
63
64
  /** Well-known OAuth Authorization Server Metadata URL for an AS origin. */
64
65
  function getAuthorizationServerMetadataUrl(authorizationServerOrigin) {
package/dist/bin.js CHANGED
@@ -77,7 +77,7 @@ program
77
77
  });
78
78
  program
79
79
  .command('http')
80
- .description('Run MCP server over Streamable HTTP (all fixed profile paths)')
80
+ .description('Run MCP server over Streamable HTTP (fixed profile paths)')
81
81
  .addHelpText('after', cli_help_js_1.formatProfilesHelp)
82
82
  .action(() => {
83
83
  runHttp();
@@ -0,0 +1,23 @@
1
+ /**
2
+ * HTTP mount allowlist for shipped MCP profiles (ADR-0024).
3
+ *
4
+ * Canonical: `LIGHTDASH_TOOLS_MCP_PROFILES`.
5
+ * Unset/empty → unrestricted (all shipped paths). Non-empty → hard ceiling.
6
+ * Unknown ids / empty CSV segments fail closed. Stdio ignores this env.
7
+ */
8
+ import { type ProfileId } from '@lightdash-tools/common';
9
+ export type EnabledProfilesPolicy = {
10
+ restricted: false;
11
+ } | {
12
+ restricted: true;
13
+ ids: ReadonlySet<ProfileId>;
14
+ };
15
+ export declare const UNRESTRICTED_ENABLED_PROFILES: EnabledProfilesPolicy;
16
+ export declare function parseEnabledProfiles(raw: string | undefined): EnabledProfilesPolicy;
17
+ export declare function isProfileEnabled(policy: EnabledProfilesPolicy, id: ProfileId): boolean;
18
+ /** Preview/destructive HMAC key is required when write profiles are mounted. */
19
+ export declare function requiresSignedStateKey(policy: EnabledProfilesPolicy): boolean;
20
+ /** Enabled HTTP mount paths in `PROFILE_IDS` order. */
21
+ export declare function listEnabledProfilePaths(policy: EnabledProfilesPolicy): string[];
22
+ /** Root PRM / `config.mcpPath` anchor: default profile, else first enabled `PROFILE_IDS` id. */
23
+ export declare function resolveRootMcpPath(policy: EnabledProfilesPolicy): string;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * HTTP mount allowlist for shipped MCP profiles (ADR-0024).
4
+ *
5
+ * Canonical: `LIGHTDASH_TOOLS_MCP_PROFILES`.
6
+ * Unset/empty → unrestricted (all shipped paths). Non-empty → hard ceiling.
7
+ * Unknown ids / empty CSV segments fail closed. Stdio ignores this env.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.UNRESTRICTED_ENABLED_PROFILES = void 0;
11
+ exports.parseEnabledProfiles = parseEnabledProfiles;
12
+ exports.isProfileEnabled = isProfileEnabled;
13
+ exports.requiresSignedStateKey = requiresSignedStateKey;
14
+ exports.listEnabledProfilePaths = listEnabledProfilePaths;
15
+ exports.resolveRootMcpPath = resolveRootMcpPath;
16
+ const common_1 = require("@lightdash-tools/common");
17
+ const index_js_1 = require("../profiles/index.js");
18
+ const env_js_1 = require("./env.js");
19
+ exports.UNRESTRICTED_ENABLED_PROFILES = { restricted: false };
20
+ function parseEnabledProfiles(raw) {
21
+ if (raw === undefined || raw.trim() === '') {
22
+ return exports.UNRESTRICTED_ENABLED_PROFILES;
23
+ }
24
+ const parts = raw.split(',').map((s) => s.trim());
25
+ if (parts.some((part) => part === '')) {
26
+ throw new Error(`${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES} must be a non-empty comma-separated list of profile ids (empty segments are not allowed)`);
27
+ }
28
+ const ids = new Set();
29
+ for (const part of parts) {
30
+ const id = (0, index_js_1.parseProfileId)(part);
31
+ if (!id) {
32
+ throw new Error(`${env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES} contains unknown profile '${part}'. Expected one of: ${common_1.PROFILE_IDS.join(', ')}`);
33
+ }
34
+ ids.add(id);
35
+ }
36
+ return { restricted: true, ids };
37
+ }
38
+ function isProfileEnabled(policy, id) {
39
+ return !policy.restricted || policy.ids.has(id);
40
+ }
41
+ /** Preview/destructive HMAC key is required when write profiles are mounted. */
42
+ function requiresSignedStateKey(policy) {
43
+ return (!policy.restricted ||
44
+ policy.ids.has('content-developer') ||
45
+ policy.ids.has('content-governance'));
46
+ }
47
+ /** Enabled HTTP mount paths in `PROFILE_IDS` order. */
48
+ function listEnabledProfilePaths(policy) {
49
+ return common_1.PROFILE_IDS.filter((id) => isProfileEnabled(policy, id)).map((id) => (0, index_js_1.getProfile)(id).path);
50
+ }
51
+ /** Root PRM / `config.mcpPath` anchor: default profile, else first enabled `PROFILE_IDS` id. */
52
+ function resolveRootMcpPath(policy) {
53
+ if (!policy.restricted || policy.ids.has(index_js_1.DEFAULT_PROFILE_ID)) {
54
+ return (0, index_js_1.getDefaultProfile)().path;
55
+ }
56
+ return listEnabledProfilePaths(policy)[0];
57
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const common_1 = require("@lightdash-tools/common");
4
+ const vitest_1 = require("vitest");
5
+ const index_js_1 = require("../profiles/index.js");
6
+ const enabled_profiles_js_1 = require("./enabled-profiles.js");
7
+ const env_js_1 = require("./env.js");
8
+ (0, vitest_1.describe)('parseEnabledProfiles', () => {
9
+ (0, vitest_1.it)('returns unrestricted when unset or empty', () => {
10
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.parseEnabledProfiles)(undefined)).toEqual(enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES);
11
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.parseEnabledProfiles)('')).toEqual(enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES);
12
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.parseEnabledProfiles)(' ')).toEqual(enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES);
13
+ });
14
+ (0, vitest_1.it)('parses comma-separated ids with trim and dedupe', () => {
15
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.parseEnabledProfiles)(' content-reader , content-developer, content-reader ')).toEqual({
16
+ restricted: true,
17
+ ids: new Set(['content-reader', 'content-developer']),
18
+ });
19
+ });
20
+ (0, vitest_1.it)('rejects empty CSV segments', () => {
21
+ (0, vitest_1.expect)(() => (0, enabled_profiles_js_1.parseEnabledProfiles)(',,,')).toThrow(/empty segments/);
22
+ (0, vitest_1.expect)(() => (0, enabled_profiles_js_1.parseEnabledProfiles)('content-reader,')).toThrow(/empty segments/);
23
+ });
24
+ (0, vitest_1.it)('rejects unknown ids and free-form paths', () => {
25
+ (0, vitest_1.expect)(() => (0, enabled_profiles_js_1.parseEnabledProfiles)('not-a-profile')).toThrow(/unknown profile/);
26
+ (0, vitest_1.expect)(() => (0, enabled_profiles_js_1.parseEnabledProfiles)('/content-reader/v1/mcp')).toThrow(/unknown profile/);
27
+ (0, vitest_1.expect)(() => (0, enabled_profiles_js_1.parseEnabledProfiles)('not-a-profile')).toThrow(env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES);
28
+ });
29
+ });
30
+ (0, vitest_1.describe)('isProfileEnabled / requiresSignedStateKey / resolveRootMcpPath', () => {
31
+ (0, vitest_1.it)('treats unrestricted as all profiles enabled', () => {
32
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.isProfileEnabled)(enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES, 'content-governance')).toBe(true);
33
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.isProfileEnabled)(enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES, 'data-analyst')).toBe(true);
34
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.requiresSignedStateKey)(enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES)).toBe(true);
35
+ });
36
+ (0, vitest_1.it)('restricts to listed ids', () => {
37
+ const policy = (0, enabled_profiles_js_1.parseEnabledProfiles)('content-reader');
38
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.isProfileEnabled)(policy, 'content-reader')).toBe(true);
39
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.isProfileEnabled)(policy, 'semantic-layer')).toBe(false);
40
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.requiresSignedStateKey)(policy)).toBe(false);
41
+ });
42
+ (0, vitest_1.it)('requires signing key when developer or governance is enabled', () => {
43
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.requiresSignedStateKey)((0, enabled_profiles_js_1.parseEnabledProfiles)('content-developer'))).toBe(true);
44
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.requiresSignedStateKey)((0, enabled_profiles_js_1.parseEnabledProfiles)('content-governance'))).toBe(true);
45
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.requiresSignedStateKey)((0, enabled_profiles_js_1.parseEnabledProfiles)('content-reader,content-developer'))).toBe(true);
46
+ });
47
+ (0, vitest_1.it)('uses semantic-layer mcpPath when unrestricted or when that id is listed', () => {
48
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.resolveRootMcpPath)(enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES)).toBe(index_js_1.SEMANTIC_LAYER_PROFILE_PATH);
49
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.resolveRootMcpPath)((0, enabled_profiles_js_1.parseEnabledProfiles)('semantic-layer,content-reader'))).toBe(index_js_1.SEMANTIC_LAYER_PROFILE_PATH);
50
+ });
51
+ (0, vitest_1.it)('uses first PROFILE_IDS-enabled path when semantic-layer is omitted', () => {
52
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.resolveRootMcpPath)((0, enabled_profiles_js_1.parseEnabledProfiles)('content-reader'))).toBe(index_js_1.CONTENT_READER_PROFILE_PATH);
53
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.resolveRootMcpPath)((0, enabled_profiles_js_1.parseEnabledProfiles)('content-reader,content-developer'))).toBe(index_js_1.CONTENT_DEVELOPER_PROFILE_PATH);
54
+ (0, vitest_1.expect)(common_1.PROFILE_IDS.indexOf('content-developer')).toBeLessThan(common_1.PROFILE_IDS.indexOf('content-reader'));
55
+ });
56
+ (0, vitest_1.it)('lists shipped paths when unrestricted and only enabled paths when restricted', () => {
57
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.listEnabledProfilePaths)(enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES)).toEqual(common_1.PROFILE_IDS.map((id) => (0, index_js_1.getProfile)(id).path));
58
+ (0, vitest_1.expect)((0, enabled_profiles_js_1.listEnabledProfilePaths)((0, enabled_profiles_js_1.parseEnabledProfiles)('content-reader'))).toEqual([
59
+ index_js_1.CONTENT_READER_PROFILE_PATH,
60
+ ]);
61
+ });
62
+ });
@@ -9,6 +9,8 @@ export declare const ENV_PLATFORM_PORT = "PORT";
9
9
  export declare const ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL = "LIGHTDASH_TOOLS_MCP_PUBLIC_URL";
10
10
  /** Rejected at config load — MCP path is profile-owned (see profiles/). */
11
11
  export declare const ENV_LIGHTDASH_TOOLS_MCP_PATH = "LIGHTDASH_TOOLS_MCP_PATH";
12
+ /** Optional HTTP mount allowlist (comma-separated ProfileIds). Unset/empty → all. Stdio ignores. */
13
+ export declare const ENV_LIGHTDASH_TOOLS_MCP_PROFILES = "LIGHTDASH_TOOLS_MCP_PROFILES";
12
14
  /** Rejected — auth mode is inferred from credentials (ADR-0007). */
13
15
  export declare const ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = "LIGHTDASH_TOOLS_MCP_AUTH_MODE";
14
16
  export declare const ENV_LIGHTDASH_TOOLS_MCP_SHARED_KEY = "LIGHTDASH_TOOLS_MCP_SHARED_KEY";
@@ -4,7 +4,7 @@
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_PLATFORM_PORT = 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_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_PROFILES = exports.ENV_LIGHTDASH_TOOLS_MCP_PATH = exports.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL = exports.ENV_PLATFORM_PORT = 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
  /** Platform listen port (Cloud Run / many PaaS). Used only when dedicated MCP port env is unset. */
@@ -12,6 +12,8 @@ exports.ENV_PLATFORM_PORT = 'PORT';
12
12
  exports.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL = 'LIGHTDASH_TOOLS_MCP_PUBLIC_URL';
13
13
  /** Rejected at config load — MCP path is profile-owned (see profiles/). */
14
14
  exports.ENV_LIGHTDASH_TOOLS_MCP_PATH = 'LIGHTDASH_TOOLS_MCP_PATH';
15
+ /** Optional HTTP mount allowlist (comma-separated ProfileIds). Unset/empty → all. Stdio ignores. */
16
+ exports.ENV_LIGHTDASH_TOOLS_MCP_PROFILES = 'LIGHTDASH_TOOLS_MCP_PROFILES';
15
17
  /** Rejected — auth mode is inferred from credentials (ADR-0007). */
16
18
  exports.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = 'LIGHTDASH_TOOLS_MCP_AUTH_MODE';
17
19
  exports.ENV_LIGHTDASH_TOOLS_MCP_SHARED_KEY = 'LIGHTDASH_TOOLS_MCP_SHARED_KEY';
@@ -1,4 +1,5 @@
1
1
  import { SecretString } from '@lightdash-tools/client';
2
+ import { type EnabledProfilesPolicy } from './enabled-profiles.js';
2
3
  import type { McpAuthMode } from '../auth/auth-mode.js';
3
4
  export interface McpHttpConfig {
4
5
  lightdashUrl: string;
@@ -7,6 +8,8 @@ export interface McpHttpConfig {
7
8
  port: number;
8
9
  publicUrl?: string;
9
10
  mcpPath: string;
11
+ /** HTTP mount allowlist. Unrestricted when LIGHTDASH_TOOLS_MCP_PROFILES is unset. */
12
+ enabledProfiles: EnabledProfilesPolicy;
10
13
  authMode: McpAuthMode;
11
14
  sharedKey?: SecretString;
12
15
  /** Server-held Lightdash OAuth application client id (broker mode). */
@@ -7,6 +7,7 @@ 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
9
  const index_js_1 = require("../profiles/index.js");
10
+ const enabled_profiles_js_1 = require("./enabled-profiles.js");
10
11
  const env_js_1 = require("./env.js");
11
12
  const normalize_url_js_1 = require("./normalize-url.js");
12
13
  const obsolete_env_js_1 = require("./obsolete-env.js");
@@ -236,7 +237,8 @@ function loadMcpHttpConfig(env = process.env) {
236
237
  ]);
237
238
  const allowedOrigins = parseCsv(allowedOriginsRaw);
238
239
  const proxyAuth = (0, read_env_js_1.readEnv)(client_1.ENV_LIGHTDASH_PROXY_AUTHORIZATION, env);
239
- const mcpPath = (0, index_js_1.getDefaultProfile)().path;
240
+ const enabledProfiles = (0, enabled_profiles_js_1.parseEnabledProfiles)((0, read_env_js_1.readEnv)(env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES, env));
241
+ const mcpPath = (0, enabled_profiles_js_1.resolveRootMcpPath)(enabledProfiles);
240
242
  const publicUrl = publicUrlRaw ? (0, normalize_url_js_1.normalizePublicUrl)(publicUrlRaw, (0, index_js_1.listProfilePaths)()) : undefined;
241
243
  assertPublicUrlSecurity(authMode, publicUrl);
242
244
  const validateToken = parseBooleanEnv(env_js_1.ENV_LIGHTDASH_TOOLS_MCP_VALIDATE_TOKEN, (0, read_env_js_1.readEnv)(env_js_1.ENV_LIGHTDASH_TOOLS_MCP_VALIDATE_TOKEN, env), authMode === auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH);
@@ -249,6 +251,7 @@ function loadMcpHttpConfig(env = process.env) {
249
251
  { name: env_js_1.ENV_MCP_SERVER_PORT, newName: env_js_1.ENV_LIGHTDASH_TOOLS_MCP_HTTP_PORT },
250
252
  ], 3100, env_js_1.ENV_PLATFORM_PORT), publicUrl,
251
253
  mcpPath,
254
+ enabledProfiles,
252
255
  authMode, sharedKey: sharedKeyRaw ? new client_1.SecretString(sharedKeyRaw) : undefined }, resolveOAuthCredentials(authMode, oauthClientId, oauthClientSecretRaw)), { allowedOrigins, maxBodyBytes: readNumberEnv(env, env_js_1.ENV_LIGHTDASH_TOOLS_MCP_MAX_BODY_BYTES, [{ name: env_js_1.ENV_MCP_MAX_BODY_BYTES, newName: env_js_1.ENV_LIGHTDASH_TOOLS_MCP_MAX_BODY_BYTES }], 1024 * 1024), requiredScopes, scopesSupported: readScopeList(env, env_js_1.ENV_LIGHTDASH_TOOLS_MCP_SCOPES_SUPPORTED, authMode === auth_mode_js_1.MCP_AUTH_MODE_LIGHTDASH_OAUTH ? [] : [...DEFAULT_SCOPES_SUPPORTED]), validateToken, tokenValidationCacheTtlMs: readNumberEnv(env, env_js_1.ENV_LIGHTDASH_TOOLS_MCP_TOKEN_VALIDATION_CACHE_TTL_MS, [], 10000) });
253
256
  }
254
257
  function requiresLightdashApiKey(authMode) {
@@ -1,6 +1,8 @@
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("../profiles/index.js");
5
+ const enabled_profiles_js_1 = require("./enabled-profiles.js");
4
6
  const env_js_1 = require("./env.js");
5
7
  const load_mcp_config_js_1 = require("./load-mcp-config.js");
6
8
  const originalEnv = Object.assign({}, process.env);
@@ -189,6 +191,45 @@ function setOAuthCreds() {
189
191
  const config = (0, load_mcp_config_js_1.loadMcpHttpConfig)();
190
192
  (0, vitest_1.expect)(config.validateToken).toBe(false);
191
193
  });
194
+ (0, vitest_1.it)('keeps default mcpPath when MCP_PROFILES is unset', () => {
195
+ process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
196
+ process.env.NODE_ENV = 'development';
197
+ const config = (0, load_mcp_config_js_1.loadMcpHttpConfig)();
198
+ (0, vitest_1.expect)(config.enabledProfiles).toEqual(enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES);
199
+ (0, vitest_1.expect)(config.mcpPath).toBe(index_js_1.SEMANTIC_LAYER_PROFILE_PATH);
200
+ });
201
+ (0, vitest_1.it)('keeps semantic-layer mcpPath when that id is in the allowlist', () => {
202
+ process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
203
+ process.env.NODE_ENV = 'development';
204
+ process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES] = 'semantic-layer, content-reader';
205
+ const config = (0, load_mcp_config_js_1.loadMcpHttpConfig)();
206
+ (0, vitest_1.expect)(config.enabledProfiles.restricted).toBe(true);
207
+ (0, vitest_1.expect)(config.mcpPath).toBe(index_js_1.SEMANTIC_LAYER_PROFILE_PATH);
208
+ });
209
+ (0, vitest_1.it)('uses first PROFILE_IDS-enabled mcpPath when semantic-layer is omitted', () => {
210
+ process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
211
+ process.env.NODE_ENV = 'development';
212
+ process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES] = 'content-reader,content-developer';
213
+ const config = (0, load_mcp_config_js_1.loadMcpHttpConfig)();
214
+ (0, vitest_1.expect)(config.mcpPath).toBe(index_js_1.CONTENT_DEVELOPER_PROFILE_PATH);
215
+ });
216
+ (0, vitest_1.it)('rejects unknown MCP_PROFILES ids and empty segments', () => {
217
+ process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
218
+ process.env.NODE_ENV = 'development';
219
+ process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES] = 'not-a-profile';
220
+ (0, vitest_1.expect)(() => (0, load_mcp_config_js_1.loadMcpHttpConfig)()).toThrow(env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES);
221
+ process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES] = 'content-reader,';
222
+ (0, vitest_1.expect)(() => (0, load_mcp_config_js_1.loadMcpHttpConfig)()).toThrow(/empty segments/);
223
+ });
224
+ (0, vitest_1.it)('still strips disabled profile suffixes from PUBLIC_URL', () => {
225
+ setOAuthCreds();
226
+ process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PROFILES] = 'content-reader';
227
+ process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL] =
228
+ 'https://mcp.example.com/content-governance/v1/mcp';
229
+ const config = (0, load_mcp_config_js_1.loadMcpHttpConfig)();
230
+ (0, vitest_1.expect)(config.publicUrl).toBe('https://mcp.example.com');
231
+ (0, vitest_1.expect)(config.mcpPath).toBe(index_js_1.CONTENT_READER_PROFILE_PATH);
232
+ });
192
233
  (0, vitest_1.it)('rejects LIGHTDASH_TOOLS_MCP_PATH', () => {
193
234
  process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
194
235
  process.env.NODE_ENV = 'development';
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeTestMcpHttpConfig = makeTestMcpHttpConfig;
4
+ const enabled_profiles_js_1 = require("./enabled-profiles.js");
4
5
  /** Shared base `McpHttpConfig` for MCP package unit/integration tests. */
5
6
  function makeTestMcpHttpConfig(overrides) {
6
- return Object.assign({ lightdashUrl: 'https://app.lightdash.cloud', host: '127.0.0.1', port: 3100, publicUrl: 'https://mcp.example.com', mcpPath: '/semantic-layer/v1/mcp', authMode: 'lightdash-oauth', allowedOrigins: [], maxBodyBytes: 1024, requiredScopes: ['mcp:read'], scopesSupported: ['mcp:read', 'mcp:write'], validateToken: true, tokenValidationCacheTtlMs: 30000 }, overrides);
7
+ var _a;
8
+ const enabledProfiles = (_a = overrides === null || overrides === void 0 ? void 0 : overrides.enabledProfiles) !== null && _a !== void 0 ? _a : enabled_profiles_js_1.UNRESTRICTED_ENABLED_PROFILES;
9
+ return Object.assign({ lightdashUrl: 'https://app.lightdash.cloud', host: '127.0.0.1', port: 3100, publicUrl: 'https://mcp.example.com', mcpPath: (0, enabled_profiles_js_1.resolveRootMcpPath)(enabledProfiles), enabledProfiles, authMode: 'lightdash-oauth', allowedOrigins: [], maxBodyBytes: 1024, requiredScopes: ['mcp:read'], scopesSupported: ['mcp:read', 'mcp:write'], validateToken: true, tokenValidationCacheTtlMs: 30000 }, overrides);
7
10
  }
@@ -5,6 +5,8 @@ const client_1 = require("@lightdash-tools/client");
5
5
  const server_1 = require("@modelcontextprotocol/server");
6
6
  const vitest_1 = require("vitest");
7
7
  const oauth_protected_resource_js_1 = require("./auth/resource-server/oauth-protected-resource.js");
8
+ const enabled_profiles_js_1 = require("./config/enabled-profiles.js");
9
+ const test_mcp_http_config_js_1 = require("./config/test-mcp-http-config.js");
8
10
  const streamable_http_js_1 = require("./transports/streamable-http.js");
9
11
  const TOKEN_A = scopedAccessToken('mcp:read mcp:write', 'token-a');
10
12
  const TOKEN_B = scopedAccessToken('mcp:read mcp:write', 'token-b');
@@ -115,23 +117,8 @@ async function startMockLightdashServer() {
115
117
  }),
116
118
  };
117
119
  }
118
- function baseOAuthConfig(lightdashUrl) {
119
- return {
120
- lightdashUrl,
121
- host: '127.0.0.1',
122
- port: 0,
123
- publicUrl: 'http://127.0.0.1:0',
124
- mcpPath: '/semantic-layer/v1/mcp',
125
- authMode: 'lightdash-oauth',
126
- oauthClientId: 'test-client-id',
127
- oauthClientSecret: new client_1.SecretString('test-client-secret'),
128
- allowedOrigins: [],
129
- maxBodyBytes: 1024 * 1024,
130
- requiredScopes: [],
131
- scopesSupported: [],
132
- validateToken: true,
133
- tokenValidationCacheTtlMs: 30000,
134
- };
120
+ function baseOAuthConfig(lightdashUrl, overrides) {
121
+ return (0, test_mcp_http_config_js_1.makeTestMcpHttpConfig)(Object.assign({ lightdashUrl, port: 0, publicUrl: 'http://127.0.0.1:0', oauthClientId: 'test-client-id', oauthClientSecret: new client_1.SecretString('test-client-secret'), maxBodyBytes: 1024 * 1024, requiredScopes: [], scopesSupported: [] }, overrides));
135
122
  }
136
123
  async function postMcp(baseUrl, body, options) {
137
124
  var _a;
@@ -506,6 +493,46 @@ function parseSseOrJsonToolText(raw) {
506
493
  (0, vitest_1.expect)(response.status).toBe(405);
507
494
  });
508
495
  });
496
+ (0, vitest_1.describe)('MCP HTTP profile mount allowlist', () => {
497
+ let mockLightdash;
498
+ let mcpServer;
499
+ (0, vitest_1.beforeEach)(async () => {
500
+ vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
501
+ vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
502
+ mockLightdash = await startMockLightdashServer();
503
+ mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(baseOAuthConfig(mockLightdash.baseUrl, {
504
+ enabledProfiles: (0, enabled_profiles_js_1.parseEnabledProfiles)('content-reader'),
505
+ }));
506
+ });
507
+ (0, vitest_1.afterEach)(async () => {
508
+ await mcpServer.close();
509
+ await mockLightdash.close();
510
+ vitest_1.vi.restoreAllMocks();
511
+ });
512
+ (0, vitest_1.it)('404s disabled profile MCP paths and their path-specific PRM', async () => {
513
+ const mcpResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
514
+ (0, vitest_1.expect)(mcpResponse.status).toBe(404);
515
+ const prmResponse = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/semantic-layer/v1/mcp`);
516
+ (0, vitest_1.expect)(prmResponse.status).toBe(404);
517
+ });
518
+ (0, vitest_1.it)('keeps enabled profile MCP and PRM reachable', async () => {
519
+ const mcpResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
520
+ token: TOKEN_A,
521
+ path: '/content-reader/v1/mcp',
522
+ });
523
+ (0, vitest_1.expect)(mcpResponse.status).toBe(200);
524
+ const prmResponse = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/content-reader/v1/mcp`);
525
+ (0, vitest_1.expect)(prmResponse.status).toBe(200);
526
+ const metadata = (await prmResponse.json());
527
+ (0, vitest_1.expect)(metadata.resource).toBe(`${mcpServer.baseUrl}/content-reader/v1/mcp`);
528
+ });
529
+ (0, vitest_1.it)('serves root PRM for the first enabled profile path', async () => {
530
+ const response = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource`);
531
+ (0, vitest_1.expect)(response.status).toBe(200);
532
+ const metadata = (await response.json());
533
+ (0, vitest_1.expect)(metadata.resource).toBe(`${mcpServer.baseUrl}/content-reader/v1/mcp`);
534
+ });
535
+ });
509
536
  (0, vitest_1.describe)('MCP HTTP shared-key integration', () => {
510
537
  let mcpServer;
511
538
  const originalEnv = Object.assign({}, process.env);
@@ -514,20 +541,16 @@ function parseSseOrJsonToolText(raw) {
514
541
  vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
515
542
  process.env.LIGHTDASH_URL = 'https://app.lightdash.cloud';
516
543
  process.env.LIGHTDASH_API_KEY = 'ldpat_test_key';
517
- mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)({
518
- lightdashUrl: 'https://app.lightdash.cloud',
519
- host: '127.0.0.1',
544
+ mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)((0, test_mcp_http_config_js_1.makeTestMcpHttpConfig)({
520
545
  port: 0,
521
- mcpPath: '/semantic-layer/v1/mcp',
546
+ publicUrl: undefined,
522
547
  authMode: 'shared-key',
523
548
  sharedKey: new client_1.SecretString('shared-secret'),
524
- allowedOrigins: [],
525
549
  maxBodyBytes: 1024 * 1024,
526
550
  requiredScopes: [],
527
551
  scopesSupported: ['mcp:read'],
528
552
  validateToken: false,
529
- tokenValidationCacheTtlMs: 30000,
530
- });
553
+ }));
531
554
  });
532
555
  (0, vitest_1.afterEach)(async () => {
533
556
  await mcpServer.close();
@@ -7,6 +7,7 @@ const vitest_1 = require("vitest");
7
7
  const env_context_provider_js_1 = require("./auth/providers/env-context-provider.js");
8
8
  const lightdash_token_validation_js_1 = require("./auth/resource-server/lightdash-token-validation.js");
9
9
  const runtime_js_1 = require("./config/runtime.js");
10
+ const test_mcp_http_config_js_1 = require("./config/test-mcp-http-config.js");
10
11
  const server_js_1 = require("./server/server.js");
11
12
  const shared_1 = require("./tools/shared");
12
13
  const hasCredentials = !!process.env.LIGHTDASH_API_KEY && !!process.env.LIGHTDASH_URL;
@@ -55,20 +56,10 @@ vitest_1.describe.runIf(hasOAuthToken)('MCP Integration (OAuth access token)', (
55
56
  var _a;
56
57
  const lightdashUrl = process.env.LIGHTDASH_URL.replace(/\/$/, '');
57
58
  const accessToken = process.env.LIGHTDASH_TOOLS_TEST_OAUTH_ACCESS_TOKEN;
58
- const config = {
59
+ const config = (0, test_mcp_http_config_js_1.makeTestMcpHttpConfig)({
59
60
  lightdashUrl,
60
- host: '127.0.0.1',
61
- port: 3100,
62
- publicUrl: 'https://mcp.example.com',
63
- mcpPath: '/semantic-layer/v1/mcp',
64
- authMode: 'lightdash-oauth',
65
- allowedOrigins: [],
66
61
  maxBodyBytes: 1024 * 1024,
67
- requiredScopes: ['mcp:read'],
68
- scopesSupported: ['mcp:read', 'mcp:write'],
69
- validateToken: true,
70
- tokenValidationCacheTtlMs: 30000,
71
- };
62
+ });
72
63
  const user = await (0, lightdash_token_validation_js_1.validateLightdashAccessToken)(config, accessToken);
73
64
  (0, vitest_1.expect)(user.userUuid).toBeDefined();
74
65
  (0, vitest_1.expect)(user.email).toBeDefined();
@@ -4,7 +4,7 @@ URI: `lightdash://playbooks/content-developer/chart-types`
4
4
 
5
5
  Pick a viz type to **answer an insight question** from the Design Spec Objective. The table below is a **reference map**, not a build order — do not walk every row unless the user explicitly asked for multi-viz / all chart types. Prefer **clone** (`get_chart_as_code` / `duplicate_chart`) over inventing viz configs. Docs: [overview](https://docs.lightdash.com/references/chart-types/overview).
6
6
 
7
- When the insight needs period-over-period, % of total, rank, or running/rolling windows, append `metricQuery.tableCalculations` per `lightdash://playbooks/content-developer/table-calculations` (do not freestyle warehouse `OVER()` SQL).
7
+ When the insight needs period-over-period, % of total, rank, or running/rolling windows: prefer cloned native PoP metrics (`generationType: periodOverPeriod`) from the seed; otherwise append `metricQuery.tableCalculations` per `lightdash://playbooks/content-developer/table-calculations` (do not freestyle warehouse `OVER()` SQL). See [period-over-period](https://docs.lightdash.com/guides/period-over-period).
8
8
 
9
9
  When the user **does** ask for all types: follow dashboards **Multi-viz batch SOP** (shell → ≤2 concurrent chart creates → one tile update), split the board into a decision-oriented section plus a visualization-validation appendix (see `dashboards` / `dashboard-design`), and check every candidate type against the **semantic fit gate** below before adding it.
10
10
 
@@ -133,6 +133,7 @@ chartConfig:
133
133
  - Clone `chartConfig` from a rendering seed on the same `tableName`; change series `type` / top-level type only when needed.
134
134
  - FieldIds only from seed / `get_chart` / semantic-layer — never invent. this profile has **no** explore/field list tools.
135
135
  - Field IDs shown in the YAML examples below (e.g. `orders_status`) are **illustrative**, not guaranteed to exist on any given explore — verify against a seed via `get_chart_as_code` (or `get_chart`) before use.
136
+ - **Custom fields & tooltips (clone-only):** preserve `metricQuery.customDimensions` and cartesian `eChartsConfig.tooltip` from the seed ([custom fields](https://docs.lightdash.com/guides/custom-fields), [custom tooltips](https://docs.lightdash.com/guides/custom-tooltip)). Do not invent new custom SQL dimensions or freestyle tooltip field names. Metrics reused across boards belong in dbt / semantic-layer, not chart-local custom metrics.
136
137
  - When cloning charts that use SQL/bin custom dims (e.g. coupon flags), copy `metricQuery.customDimensions` verbatim.
137
138
  - Every `metricQuery.dimensions` entry must appear in viz layout / group / sankey source-target / pivot — unused dimensions corrupt GROUP BY (“Results may be incorrect”). **Exception:** a scatter with two metric axes legitimately keeps its grain dimension (e.g. customer id) in `metricQuery.dimensions` to produce one row per entity — `validate_chart` will still flag it as "unused" because the validator only recognizes x/y-axis or group-by references, not grain-only dimensions. That warning is expected on a correct two-metric scatter; do not drop the dimension to silence it.
138
139
  - For dashboard work set `dashboardSlug` **and** tile via `update_dashboard` (ownership alone does not place tiles).
@@ -23,6 +23,7 @@ this profile does **not** execute queries, compile explores, create spaces, or p
23
23
  - Do not treat chart create as done without a dashboard shell and tiles that reference those charts.
24
24
  - Do not invent `fieldId`s. Copy from `get_chart_as_code` / `get_chart` (`includeQueryDefinition`) or semantic-layer.
25
25
  - Do not invent skinny `chartConfig` (e.g. `{ series: [{ type: 'bar' }] }` only) — clone a working as-code body and keep series/layout/encode structure.
26
+ - Do not set chart `verified` or dashboard `preserveVerification` unless the user explicitly asks (requires verify permission; edits can drop the badge — [verified content](https://docs.lightdash.com/guides/verified-content)).
26
27
  - Do not call a write tool without a validated, unexpired HMAC `previewToken` from the matching `preview_*` then `confirm_preview`.
27
28
  - Do not mutate the proposed payload after `preview_*` (no edits to `description`, `name`, SQL, metrics, tiles, or other fields between preview and apply) — apply must reuse the **identical proposed** body or you get `PREVIEW_STALE` (content hash mismatch). Any intentional edit requires a new `preview_*`.
28
29
  - Do not reuse a **draft** token after confirm (confirm returns a **new** validated token) or after payload/baseline drift (`PREVIEW_STALE`).
@@ -107,4 +108,4 @@ Record when a budget stopped you. User-requested “one of every chart type” o
107
108
  - Tile shape: `{ type: 'saved_chart', x, y, w, h, properties: { savedChartUuid, title? } }` — use the UUID from `create_chart` / `duplicate_chart` (36-column grid; half-width ≈ `w: 18`). Optional `chartSlug` is metadata only; do not omit `savedChartUuid`.
108
109
  - `create_chart` response: extract UUID from `charts[0].data.uuid` (not a bare chart object).
109
110
  - Viz shapes: `lightdash://playbooks/content-developer/chart-types`.
110
- - PoP / % of total / rank / running or rolling windows on `metricQuery.tableCalculations`: `lightdash://playbooks/content-developer/table-calculations`.
111
+ - PoP: prefer cloned `generationType: periodOverPeriod` metrics; else % of total / rank / windows via `lightdash://playbooks/content-developer/table-calculations`.
@@ -79,7 +79,7 @@ Skip fancy HTML/iframe unless the user asks. Loom / heading tiles: only if reque
79
79
 
80
80
  ## Filters (optional)
81
81
 
82
- 0–3 shared **dimensions**. Prefer **one explore** for all tiles that share dashboard filters. Filters guide: [Using filters](https://docs.lightdash.com/guides/limiting-data-using-filters). Official as-code targeting: [dashboard-reference `tileTargets`](https://github.com/lightdash/lightdash/blob/main/skills/developing-in-lightdash/resources/dashboard-reference.md).
82
+ 0–3 shared **dimensions**. Prefer **one explore** for all tiles that share dashboard filters. Filters guide: [Using filters](https://docs.lightdash.com/guides/limiting-data-using-filters). Operator catalog (date windows, `is not` + NULL, etc.): [Filters reference](https://docs.lightdash.com/guides/filters). Official as-code targeting: [dashboard-reference `tileTargets`](https://github.com/lightdash/lightdash/blob/main/skills/developing-in-lightdash/resources/dashboard-reference.md).
83
83
 
84
84
  - Prefer **empty-value** saved filters so viewers choose ([saved filters](https://docs.lightdash.com/guides/limiting-data-using-filters#adding-saved-filters-to-your-dashboard)).
85
85
  - Prefer **clone** `filters` from `get_dashboard` on a working board over inventing rules.
@@ -138,6 +138,16 @@ filters:
138
138
 
139
139
  **Apply order:** compose tiles first → if excluding, `get_dashboard` for tile UUIDs → then `preview_dashboard_changes` → `confirm_preview` → `update_dashboard({ dashboard: { filters, tiles?, name?, … } })` (second update is fine when UUIDs were not known on first tile write).
140
140
 
141
+ ## Date zoom (optional)
142
+
143
+ When the Objective needs viewers to change time granularity without editing charts ([date zoom](https://docs.lightdash.com/guides/date-zoom)):
144
+
145
+ 1. Plan in the Design Spec (Default zoom + any named controls; which tiles attach).
146
+ 2. **Clone** dashboard `config` (`dateZoomConfig`, `defaultDateZoomGranularity`, `dateZoomGranularities`, `isDateZoomDisabled`) from a working board via `get_dashboard` — do not invent tile↔field bindings.
147
+ 3. Attach only charts that have a zoomable date/timestamp dimension in results; a chart with no date field cannot join a control.
148
+ 4. Optional labels: `${table_field.granularity}` in axis / big-value labels when cloning charts that already use it.
149
+ 5. Viewer zoom is temporary in the UI; saved defaults live on the dashboard `config` you upsert.
150
+
141
151
  ## Tabs
142
152
 
143
153
  Default: **no tabs**. Use only for themes / audiences / 30+ tiles ([docs tip](https://docs.lightdash.com/get-started/exploring-data/dashboards#add-tabs)).
@@ -19,7 +19,7 @@ get_project → list_spaces → discover seeds (read-only)
19
19
  1. `list_spaces` → existing `spaceUuid` (dashboards) / `spaceSlug` (chart as-code).
20
20
  2. `search_content` with **short** tokens (`orders`, space slug). Multi-word brand phrases often return empty — use `get_space`. Short tokens can also return noisy org-wide hits — prefer `get_space` inventory for seeds.
21
21
  3. Prefer **reuse** of existing charts as tiles when they already fit.
22
- 4. For new charts: find a **working seed** on the same `tableName`; never invent fieldIds.
22
+ 4. For new charts: find a **working seed** on the same `tableName`; never invent fieldIds. For PoP, prefer seeds with `generationType: periodOverPeriod` metrics (see table-calculations).
23
23
  5. Dashboard-owned charts (`dashboardSlug` set) **do not** appear as independent space charts in `get_space` / typical search — keep the UUIDs you create, or re-open the dashboard.
24
24
 
25
25
  ## Create dashboard shell (step 1 — after Design Spec approval)
@@ -4,11 +4,22 @@ URI: `lightdash://playbooks/content-developer/table-calculations`
4
4
 
5
5
  Add chart-local metrics on top of explore dimensions/metrics via `metricQuery.tableCalculations`. Prefer clone (`get_chart_as_code`) then append calcs. This profile **cannot** run queries to verify row values.
6
6
 
7
- Docs: [overview](https://docs.lightdash.com/guides/table-calculations) · [formula](https://docs.lightdash.com/guides/formula-table-calculations) · [SQL templates](https://docs.lightdash.com/guides/table-calculations/sql-templates) · [as-code](https://docs.lightdash.com/guides/developer/dashboards-as-code) · [row](https://docs.lightdash.com/references/table-calculation-functions/row-functions) / [pivot](https://docs.lightdash.com/references/table-calculation-functions/pivot-functions) / [aggregate](https://docs.lightdash.com/references/table-calculation-functions/aggregate-functions) functions.
7
+ Docs: [overview](https://docs.lightdash.com/guides/table-calculations) · [formula](https://docs.lightdash.com/guides/formula-table-calculations) · [SQL templates](https://docs.lightdash.com/guides/table-calculations/sql-templates) · [as-code](https://docs.lightdash.com/guides/developer/dashboards-as-code) · [period-over-period](https://docs.lightdash.com/guides/period-over-period) · [row](https://docs.lightdash.com/references/table-calculation-functions/row-functions) / [pivot](https://docs.lightdash.com/references/table-calculation-functions/pivot-functions) / [aggregate](https://docs.lightdash.com/references/table-calculation-functions/aggregate-functions) functions.
8
8
 
9
- ## When to use
9
+ ## Native PoP metrics (prefer before table calcs)
10
10
 
11
- - Chart-specific PoP, % of total, rank, running total, rolling window, pivot share.
11
+ Period-over-period may already exist on a seed as **system-generated metrics** ([period-over-period guide](https://docs.lightdash.com/guides/period-over-period); OpenAPI `generationType: periodOverPeriod`).
12
+
13
+ 1. `get_chart_as_code` on a rendering seed.
14
+ 2. If any metric has `generationType: periodOverPeriod` (plus `baseMetricId` / `timeDimensionId` / `periodOffset` / `granularity` as present), **preserve those metrics verbatim** — do not rebuild them as table calculations.
15
+ 3. Else use table calculations below for % change, lag, running totals, etc.
16
+ 4. KPI `big_number` with `showComparison` / compare-to-previous-row: keep from seed when present.
17
+
18
+ **Hard ban:** do not invent PoP metrics by hand. This profile cannot use the Explorer “Add period comparison” UI — only clone as-code bodies.
19
+
20
+ ## When to use table calculations
21
+
22
+ - Chart-specific PoP (when no native PoP metrics on the seed), % of total, rank, running total, rolling window, pivot share.
12
23
  - If the same calc is reused across many boards → put it in **dbt** / the semantic layer instead ([overview](https://docs.lightdash.com/guides/table-calculations)).
13
24
 
14
25
  ## Preference (playbook policy)
@@ -113,6 +124,7 @@ Field IDs are **illustrative** — copy real `fieldId`s from the explore / seed.
113
124
  - Do not invent `fieldId`s or results-header column names. Copy them from `get_chart_as_code` / explore seeds — playbook skeletons are examples only.
114
125
  - `preview_chart_changes` / `confirm_preview` do **not** prove template `fieldId`s or formula headers exist; inventing IDs can still preview-validate and only fail at query time.
115
126
  - Do not invent SQL helpers — use `total()` / `row_total()` ([aggregate](https://docs.lightdash.com/references/table-calculation-functions/aggregate-functions)) or documented `pivot_*` ([pivot](https://docs.lightdash.com/references/table-calculation-functions/pivot-functions)). There is no `pivot_row_total`.
127
+ - Do not invent native PoP metrics (`generationType: periodOverPeriod`) — clone from a seed or use table calcs instead.
116
128
  - Do not convert formula ↔ sql in place — recreate the calc.
117
129
  - Do not use `pivot_*` / `row_total` without a pivoted dimension (`pivotConfig.columns`).
118
130
  - Do not author SQL **charts** or open data-analyst / raw SQL execution to “fix” a table calc on this profile.
@@ -22,6 +22,7 @@ Do not attach dashboard filters whose target.tableName is absent from a tile exp
22
22
  Do not treat chart create as done without a dashboard shell and tiles.
23
23
  Do not invent fieldIds — clone via get_chart_as_code / get_chart or use semantic-layer.
24
24
  Do not invent skinny chartConfig — clone a working as-code body and keep series/layout/encode.
25
+ Do not set chart verified or dashboard preserveVerification unless the user explicitly asks (verify permission required).
25
26
  Do not apply a write tool without a confirmed, unexpired HMAC previewToken from the matching preview_* tool (confirm_preview unlocks every write; use the new validated token).
26
27
  Do not mutate the proposed payload after preview_* (description/name/SQL/metrics/tiles) — apply must reuse the identical proposed body or PREVIEW_STALE (content hash mismatch); any edit requires a new preview_*.
27
28
  Do not treat validate_chart / validate_dashboard as a preview unlock — they are saved-UUID health checks only (validate_chart needs chartUuid).
@@ -22,6 +22,7 @@ exports.contentReaderProfile = {
22
22
  tools: [
23
23
  projects_js_1.getProjectReaderTool,
24
24
  reader_content_js_1.searchContentTool,
25
+ reader_content_js_1.listVerifiedContentTool,
25
26
  spaces_js_1.listSpacesTool,
26
27
  spaces_js_1.getSpaceTool,
27
28
  reader_content_js_1.getDashboardTool,
@@ -35,15 +35,16 @@ ${playbooks_js_1.CONTENT_READER_HARD_BANS}
35
35
 
36
36
  Project: ${projectUuid !== null && projectUuid !== void 0 ? projectUuid : '(use HTTP pin or ask for projectUuid — PROJECT_SCOPE_REQUIRED otherwise)'}.
37
37
  Content types hint: ${contentTypes !== null && contentTypes !== void 0 ? contentTypes : '(any)'}.
38
- Verified only: ${verifiedOnly !== null && verifiedOnly !== void 0 ? verifiedOnly : false} (verification is often null — fall back to pinned + views + description).
38
+ Verified preference: ${verifiedOnly !== null && verifiedOnly !== void 0 ? verifiedOnly : false} (when true, call list_verified_content first — search_content does not filter by verification).
39
39
  Space filter: ${spaceUuid !== null && spaceUuid !== void 0 ? spaceUuid : '(none)'}.
40
40
 
41
41
  Procedure:
42
42
  1. get_project with projectUuid/pin; record readerCapabilities.
43
- 2. search_content with short tokens (retry Japanese/single keyword / sortBy=views if empty). Use spaceUuids when given. pageSize≤25; ≤2 pages.
44
- 3. Prefer semantic charts (source≠sql). Rank by relevance, views, pinnedList; verification is optional.
45
- 4. Optionally list_spaces / get_space (≤3) to confirm path.
46
- 5. Return ≤5 candidates (name/type/uuid/space/views/source/why). Do not execute unless values were requested.`, 'discover'));
43
+ 2. When verifiedOnly is true (or the user asked for trusted/canonical content): call list_verified_content first and prefer those matches.
44
+ 3. Else (or when the verified list is empty): search_content with short tokens (retry Japanese/single keyword / sortBy=views if empty). Use spaceUuids when given. pageSize≤25; ≤2 pages.
45
+ 4. Prefer semantic charts (source≠sql). Rank: verified first → pinned + views + description.
46
+ 5. Optionally list_spaces / get_space (≤3) to confirm path.
47
+ 6. Return ≤5 candidates (name/type/uuid/space/views/verified/source/why). Do not execute unless values were requested.`, 'discover'));
47
48
  server.registerPrompt('explain_chart', {
48
49
  title: 'Explain chart',
49
50
  description: 'Explain a saved chart from metadata (optional bounded execution)',
@@ -87,8 +88,8 @@ Execute tiles: ${executeTiles !== null && executeTiles !== void 0 ? executeTiles
87
88
  Procedure:
88
89
  1. get_dashboard with includeTiles (+ filters as needed). Use tileUuid (not uuid); skip non-executable/markdown tiles.
89
90
  2. Describe purpose, filters, parameters, verification, and tile structure — summarize, do not dump all tiles.
90
- 3. When execution is requested, run_dashboard_tile for ≤max relevant executable tiles; preserve dashboard context; value-only overrides.
91
- 4. Report values/trends/failures with content + query UUIDs. Unexecuted tiles must not support conclusions.`, TOPIC_EXPLAIN_RUN));
91
+ 3. When execution is requested, run_dashboard_tile for ≤max relevant executable tiles; preserve dashboard context; value-only overrides. Execution uses saved date-zoom defaults unless the user asks to simulate zoom via dateZoom.
92
+ 4. Report values/trends/failures with content + query UUIDs (cite appliedDateZoom when set). Unexecuted tiles must not support conclusions.`, TOPIC_EXPLAIN_RUN));
92
93
  server.registerPrompt('answer_from_content', {
93
94
  title: 'Answer from content',
94
95
  description: 'Answer a question using existing saved Lightdash content only',
@@ -105,11 +106,11 @@ ${question}
105
106
  ${playbooks_js_1.CONTENT_READER_HARD_BANS}
106
107
 
107
108
  Project: ${projectUuid !== null && projectUuid !== void 0 ? projectUuid : PROJECT_UUID_HINT}.
108
- Prefer verified=${verifiedOnly !== null && verifiedOnly !== void 0 ? verifiedOnly : false} when present; else pinned + views + description.
109
+ Prefer verified=${verifiedOnly !== null && verifiedOnly !== void 0 ? verifiedOnly : false} when set — call list_verified_content first; else search_content (pinned + views + description). search_content does not filter by verification.
109
110
  Max executions: ${maximumExecutions !== null && maximumExecutions !== void 0 ? maximumExecutions : 3}.
110
111
 
111
112
  Procedure:
112
- 1. get_project → search_content (short tokens; retry if empty) → pick best semantic content.
113
+ 1. get_project → when verified preferred, list_verified_content first; else search_content (short tokens; retry if empty) → pick best semantic content.
113
114
  2. Inspect metadata; execute the smallest number of saved charts/tiles required (≤ max), cache-first.
114
115
  3. Skip SQL / non-executable sources. Value-only parameter/filter overrides.
115
116
  4. State answer, content used, filter/parameter context, result time/cache, truncation, and limitations.`, TOPIC_EXPLAIN_RUN));
@@ -11,7 +11,7 @@ Compare **definitions before values**. Matching titles/labels ≠ same metric, g
11
11
  3. Diff checklist:
12
12
  - Explore / `tableName`
13
13
  - Metrics & dimensions (`fieldId`s)
14
- - Filters (targets, operators, windows — e.g. `inThePast` days)
14
+ - Filters (targets, operators, windows — e.g. `inThePast` days; `in the last` vs completed periods vs `in the current` — [filters reference](https://docs.lightdash.com/guides/filters))
15
15
  - Time grain / timezone fields
16
16
  - Parameters, sorts, limits, pivots, table calculations
17
17
  - Chart `source` / `chartType` (semantic vs SQL)
@@ -45,6 +45,7 @@ Record budget / pagination / truncation stops in the answer.
45
45
  | ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
46
46
  | `get_project` | Resolve project; read `readerCapabilities` + pin context |
47
47
  | `search_content` | Find charts/dashboards/spaces/data apps |
48
+ | `list_verified_content` | List admin-verified charts/dashboards (prefer as trusted seeds) |
48
49
  | `list_spaces` / `get_space` | Space hierarchy + immediate content |
49
50
  | `get_dashboard` / `get_chart` | Structure / definition (saved SQL **chart** bodies hidden; semantic `tableCalculations` may appear when query is included) |
50
51
  | `list_project_parameters` / `get_project_parameters` | Parameter defs / values |
@@ -6,17 +6,26 @@ URI: `lightdash://playbooks/content-reader/discover`
6
6
 
7
7
  Map the user request to: find / explain / retrieve values / summarize dashboard / compare / investigate. Discovery-only intents **must not** execute.
8
8
 
9
+ ## Verified content first
10
+
11
+ When the user asks for trusted / canonical / verified content, or the prompt sets `verifiedOnly=true`:
12
+
13
+ 1. Call `list_verified_content` **before** keyword `search_content`.
14
+ 2. Prefer verified matches as an absolute trump ([verified content](https://docs.lightdash.com/guides/verified-content)).
15
+ 3. If the list is empty, fall back to search — verification is often absent in real orgs; do not stall.
16
+
9
17
  ## Search strategy
10
18
 
11
19
  1. Prefer **short, high-signal tokens** that appear in titles (product names, Japanese KPI words). Multi-word English phrases often return **zero** hits even when related content exists.
12
20
  2. If the first query is empty, try: alternate language tokens, a single keyword, `spaceUuids` / `parentSpaceUuid`, or browse with `sortBy=views` + `sortDirection=desc` (optional empty/`query` omitted) and then refine.
13
21
  3. Always set `pageSize` (≤25). Prefer `contentTypes` when the user asked for charts vs dashboards.
14
22
  4. Read `source` on chart hits: `dbt_explore` (or similar semantic) vs `sql`. Treat `sql` as **not executable** on this profile.
15
- 5. Ranking heuristics when relevance ties:
23
+ 5. Ranking heuristics when relevance ties (after verified preference above):
16
24
  - Higher `views` / pinned (`pinnedList` non-null)
17
25
  - Richer description / clearer name match
18
26
  - Prefer non-deleted / non-sandbox space names when obvious
19
- - Verification is often **null** in real orgs — do not stall waiting for verified content; prefer pinned + views + description instead
27
+
28
+ `search_content` does **not** filter by verification — use `list_verified_content` for that.
20
29
 
21
30
  ## Spaces
22
31
 
@@ -29,7 +38,7 @@ Map the user request to: find / explain / retrieve values / summarize dashboard
29
38
  Return **≤5** candidates:
30
39
 
31
40
  ```text
32
- - name (type) — uuid/slug — space — views/pinned — source(if chart) — why relevant — warnings
41
+ - name (type) — uuid/slug — space — views/pinned — verified? — source(if chart) — why relevant — warnings
33
42
  ```
34
43
 
35
44
  Do not execute unless the user asked for values or analysis.
@@ -36,7 +36,8 @@ Defaults: `useCache=true`, modest `limit` (≤100; summarize ≤20 rows in the a
36
36
  1. Pick tiles with `executable=true` and a `chartUuid` (skip markdown / non-chart tiles).
37
37
  2. Call `run_dashboard_tile` with dashboard UUID/slug + **`tileUuid`** from `get_dashboard`.
38
38
  3. Preserve dashboard context; only pass `filterOverrides` / `parameterOverrides` for **existing** filter ids / known parameter names with **values** (never retarget filters).
39
- 4. Cap tiles per summary (`maximumTiles` / budget ≤5). Unexecuted tiles must not support conclusions.
39
+ 4. Optional **date zoom**: pass `dateZoom: { granularity?, xAxisFieldId? }` when the user asks to simulate a zoom ([date zoom](https://docs.lightdash.com/guides/date-zoom)). Otherwise execution uses the dashboard’s saved default granularity. Cite `appliedDateZoom` in the report when present.
40
+ 5. Cap tiles per summary (`maximumTiles` / budget ≤5). Unexecuted tiles must not support conclusions.
40
41
 
41
42
  ## Async handles
42
43
 
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Shipped MCP profiles (path → definition). No PROFILE/PATH env knobs (ADR-0006).
2
+ * Shipped MCP profiles (path → definition). No free-form PATH env (ADR-0006).
3
+ * HTTP may filter mounts via LIGHTDASH_TOOLS_MCP_PROFILES (ADR-0024); catalog stays complete.
3
4
  */
4
5
  import type { ProfileDefinition, ProfileId } from './types.js';
5
6
  export type { ProfileDefinition, ProfileId } from './types.js';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
- * Shipped MCP profiles (path → definition). No PROFILE/PATH env knobs (ADR-0006).
3
+ * Shipped MCP profiles (path → definition). No free-form PATH env (ADR-0006).
4
+ * HTTP may filter mounts via LIGHTDASH_TOOLS_MCP_PROFILES (ADR-0024); catalog stays complete.
4
5
  */
5
6
  Object.defineProperty(exports, "__esModule", { value: true });
6
7
  exports.PROFILES = exports.DEFAULT_PROFILE_ID = exports.DATA_ANALYST_PROFILE_PATH = exports.CONTENT_GOVERNANCE_PROFILE_PATH = exports.CONTENT_DEVELOPER_PROFILE_PATH = exports.CONTENT_READER_PROFILE_PATH = exports.ORGANIZATION_AUDIT_PROFILE_PATH = exports.SEMANTIC_LAYER_PROFILE_PATH = exports.AI_AGENT_OPS_PROFILE_PATH = void 0;
@@ -55,8 +55,9 @@ const index_js_1 = require("./index.js");
55
55
  });
56
56
  (0, vitest_1.it)('content-reader membership and server name', () => {
57
57
  const profile = (0, index_js_1.getProfile)('content-reader');
58
- (0, vitest_1.expect)((0, index_js_1.listToolIds)(profile)).toHaveLength(14);
58
+ (0, vitest_1.expect)((0, index_js_1.listToolIds)(profile)).toHaveLength(15);
59
59
  (0, vitest_1.expect)((0, index_js_1.listToolIds)(profile)).toContain('export_chart_image');
60
+ (0, vitest_1.expect)((0, index_js_1.listToolIds)(profile)).toContain('list_verified_content');
60
61
  (0, vitest_1.expect)((0, index_js_1.getProfileServerName)(profile)).toBe('lightdash-mcp-content');
61
62
  });
62
63
  (0, vitest_1.it)('content-developer membership and short server name', () => {
@@ -197,8 +197,9 @@ async function initializeThenListTools(child, getStderr, clientName) {
197
197
  child = spawned.child;
198
198
  const { serverName, tools } = await initializeThenListTools(child, spawned.getStderr, 'stdio-process-smoke');
199
199
  (0, vitest_1.expect)(serverName).toBe('lightdash-mcp-content');
200
- (0, vitest_1.expect)(tools).toHaveLength(14);
200
+ (0, vitest_1.expect)(tools).toHaveLength(15);
201
201
  (0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_search_content')).toBe(true);
202
+ (0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_list_verified_content')).toBe(true);
202
203
  (0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_run_chart')).toBe(true);
203
204
  (0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_export_chart_image')).toBe(true);
204
205
  killChild(child);
@@ -7,8 +7,10 @@ export declare function detectChartType(chart: Record<string, unknown>): 'semant
7
7
  /** Pass through OpenAPI TableCalculation fields agents need to clone. */
8
8
  export declare function toReaderTableCalculation(tc: unknown): Record<string, unknown>;
9
9
  export declare function registerSearchContent(server: McpServer, contextProvider: McpContextProvider): void;
10
+ export declare function registerListVerifiedContent(server: McpServer, contextProvider: McpContextProvider): void;
10
11
  export declare function registerGetDashboard(server: McpServer, contextProvider: McpContextProvider): void;
11
12
  export declare function registerGetChart(server: McpServer, contextProvider: McpContextProvider): void;
12
13
  export declare const searchContentTool: import("../types.js").ToolModule;
14
+ export declare const listVerifiedContentTool: import("../types.js").ToolModule;
13
15
  export declare const getDashboardTool: import("../types.js").ToolModule;
14
16
  export declare const getChartTool: import("../types.js").ToolModule;
@@ -3,10 +3,11 @@
3
3
  * Content-reader discovery/metadata tools: search, dashboard, chart.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getChartTool = exports.getDashboardTool = exports.searchContentTool = void 0;
6
+ exports.getChartTool = exports.getDashboardTool = exports.listVerifiedContentTool = exports.searchContentTool = void 0;
7
7
  exports.detectChartType = detectChartType;
8
8
  exports.toReaderTableCalculation = toReaderTableCalculation;
9
9
  exports.registerSearchContent = registerSearchContent;
10
+ exports.registerListVerifiedContent = registerListVerifiedContent;
10
11
  exports.registerGetDashboard = registerGetDashboard;
11
12
  exports.registerGetChart = registerGetChart;
12
13
  const common_1 = require("@lightdash-tools/common");
@@ -180,6 +181,31 @@ function registerSearchContent(server, contextProvider) {
180
181
  }
181
182
  }));
182
183
  }
184
+ function registerListVerifiedContent(server, contextProvider) {
185
+ (0, content_reader_js_1.registerContentReaderTool)(server, 'list_verified_content', {
186
+ title: 'List verified content',
187
+ description: 'List admin-verified charts and dashboards in the resolved project (prefer these as trusted seeds)',
188
+ safety: content_reader_js_1.METADATA_SAFETY,
189
+ inputSchema: {
190
+ projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
191
+ },
192
+ }, (profile) => (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
193
+ try {
194
+ const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
195
+ const items = await c.v1.projects.listVerifiedContent(scope.projectUuid);
196
+ return (0, shared_js_1.jsonToolResult)((0, envelope_js_1.contentReaderEnvelope)({ items }, {
197
+ profile,
198
+ projectUuid: scope.projectUuid,
199
+ projectPinned: scope.projectPinned,
200
+ complete: true,
201
+ truncated: false,
202
+ }));
203
+ }
204
+ catch (err) {
205
+ return (0, reader_tool_helpers_js_1.projectScopeErrorResult)(err);
206
+ }
207
+ }));
208
+ }
183
209
  function registerGetDashboard(server, contextProvider) {
184
210
  (0, content_reader_js_1.registerContentReaderTool)(server, 'get_dashboard', {
185
211
  title: 'Get dashboard',
@@ -241,5 +267,6 @@ function registerGetChart(server, contextProvider) {
241
267
  }
242
268
  // ToolModule exports (profile mounts)
243
269
  exports.searchContentTool = (0, types_js_1.defineTool)('search_content', registerSearchContent);
270
+ exports.listVerifiedContentTool = (0, types_js_1.defineTool)('list_verified_content', registerListVerifiedContent);
244
271
  exports.getDashboardTool = (0, types_js_1.defineTool)('get_dashboard', registerGetDashboard);
245
272
  exports.getChartTool = (0, types_js_1.defineTool)('get_chart', registerGetChart);
@@ -16,6 +16,7 @@ const lightdash_oauth_middleware_js_1 = require("../auth/resource-server/lightda
16
16
  const oauth_protected_resource_js_1 = require("../auth/resource-server/oauth-protected-resource.js");
17
17
  const shared_key_middleware_js_1 = require("../auth/resource-server/shared-key-middleware.js");
18
18
  const token_hash_js_1 = require("../auth/token-hash.js");
19
+ const enabled_profiles_js_1 = require("../config/enabled-profiles.js");
19
20
  const load_mcp_config_js_1 = require("../config/load-mcp-config.js");
20
21
  const runtime_js_1 = require("../config/runtime.js");
21
22
  const available_projects_js_1 = require("../governance/available-projects.js");
@@ -175,7 +176,9 @@ async function createStreamableHttpServer(config) {
175
176
  (0, load_mcp_config_js_1.emitMcpHttpSecurityWarnings)(inputConfig);
176
177
  (0, runtime_js_1.warnIgnoredCliGuardrailEnvVars)();
177
178
  (0, available_projects_js_1.validateAvailableProjectsConfig)();
178
- (0, request_state_key_js_1.assertHttpSignedStateKeyConfigured)();
179
+ if ((0, enabled_profiles_js_1.requiresSignedStateKey)(inputConfig.enabledProfiles)) {
180
+ (0, request_state_key_js_1.assertHttpSignedStateKeyConfigured)();
181
+ }
179
182
  (0, audit_js_1.initAuditLog)((0, runtime_js_1.getAuditLogPath)());
180
183
  let httpConfig = inputConfig;
181
184
  let oauthBroker;
@@ -219,7 +222,7 @@ async function createStreamableHttpServer(config) {
219
222
  function startStreamableHttpServer(config) {
220
223
  void createStreamableHttpServer(config)
221
224
  .then(({ baseUrl, config: httpConfig }) => {
222
- const paths = (0, index_js_1.listProfilePaths)()
225
+ const paths = (0, enabled_profiles_js_1.listEnabledProfilePaths)(httpConfig.enabledProfiles)
223
226
  .map((p) => `${baseUrl}${p}`)
224
227
  .join(', ');
225
228
  console.error(`Lightdash MCP server listening on ${paths} (auth: ${httpConfig.authMode})`);
@@ -299,7 +302,7 @@ async function handleHttpRequest(req, res, config, oauthBroker, nodeHandler) {
299
302
  return;
300
303
  }
301
304
  const profile = (0, index_js_1.getProfileByPath)(path);
302
- if (!profile) {
305
+ if (!profile || !(0, enabled_profiles_js_1.isProfileEnabled)(config.enabledProfiles, profile.id)) {
303
306
  (0, http_response_js_1.sendJson)(res, 404, { error: 'Not Found' });
304
307
  return;
305
308
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vitest_1 = require("vitest");
4
4
  const oauth_protected_resource_js_1 = require("../auth/resource-server/oauth-protected-resource.js");
5
5
  const www_authenticate_js_1 = require("../auth/resource-server/www-authenticate.js");
6
+ const enabled_profiles_js_1 = require("../config/enabled-profiles.js");
6
7
  const env_js_1 = require("../config/env.js");
7
8
  const load_mcp_config_js_1 = require("../config/load-mcp-config.js");
8
9
  const test_mcp_http_config_js_1 = require("../config/test-mcp-http-config.js");
@@ -104,4 +105,19 @@ function clearMcpEnv() {
104
105
  process.env.VITEST = savedVitest;
105
106
  }
106
107
  });
108
+ (0, vitest_1.it)('allows HTTP startup without request-state key when write profiles are disabled', async () => {
109
+ const savedVitest = process.env.VITEST;
110
+ delete process.env.VITEST;
111
+ process.env.NODE_ENV = 'production';
112
+ delete process.env[env_js_1.ENV_LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY];
113
+ const handle = await (0, streamable_http_js_1.createStreamableHttpServer)((0, test_mcp_http_config_js_1.makeTestMcpHttpConfig)({
114
+ port: 0,
115
+ enabledProfiles: (0, enabled_profiles_js_1.parseEnabledProfiles)('content-reader'),
116
+ }));
117
+ (0, vitest_1.expect)(handle.port).toBeGreaterThan(0);
118
+ await handle.close();
119
+ if (savedVitest !== undefined) {
120
+ process.env.VITEST = savedVitest;
121
+ }
122
+ });
107
123
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash-tools/mcp",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
4
4
  "description": "MCP server for Lightdash semantic-layer, organization-audit, content-reader, content-developer, content-governance, and ai-agent-ops profiles.",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  "commander": "^15.0.0",
25
25
  "hono": "^4.13.0",
26
26
  "zod": "^4.4.3",
27
- "@lightdash-tools/client": "0.13.2",
28
- "@lightdash-tools/common": "0.13.2"
27
+ "@lightdash-tools/client": "0.14.0",
28
+ "@lightdash-tools/common": "0.14.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@modelcontextprotocol/client": "2.0.0",