@lightdash-tools/mcp 0.11.0 → 0.13.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 (123) hide show
  1. package/README.md +23 -14
  2. package/dist/bin.d.ts +1 -0
  3. package/dist/bin.js +31 -57
  4. package/dist/cli-help.d.ts +5 -0
  5. package/dist/cli-help.js +23 -0
  6. package/dist/cli-help.test.js +24 -0
  7. package/dist/config/env.d.ts +2 -2
  8. package/dist/config/env.js +3 -3
  9. package/dist/config/load-mcp-config.js +10 -2
  10. package/dist/config/load-mcp-config.test.js +34 -6
  11. package/dist/config/obsolete-env.js +0 -4
  12. package/dist/config/obsolete-env.test.js +0 -5
  13. package/dist/config/runtime.js +1 -1
  14. package/dist/index.d.ts +5 -2
  15. package/dist/index.js +22 -32
  16. package/dist/profiles/ai-agent-ops/v1/index.js +25 -6
  17. package/dist/profiles/ai-agent-ops/v1/prompts.test.js +2 -5
  18. package/dist/profiles/content-developer/v1/index.js +36 -6
  19. package/dist/profiles/content-developer/v1/prompts.test.js +7 -8
  20. package/dist/profiles/content-governance/v1/index.js +7 -6
  21. package/dist/profiles/content-governance/v1/prompts.test.js +2 -5
  22. package/dist/profiles/content-reader/v1/index.js +26 -6
  23. package/dist/profiles/content-reader/v1/prompts.test.js +2 -5
  24. package/dist/profiles/data-analyst/v1/index.js +19 -6
  25. package/dist/profiles/data-analyst/v1/prompts.test.js +2 -4
  26. package/dist/profiles/index.d.ts +3 -1
  27. package/dist/profiles/index.js +6 -1
  28. package/dist/profiles/index.test.js +29 -14
  29. package/dist/profiles/organization-audit/v1/index.js +27 -6
  30. package/dist/profiles/organization-audit/v1/prompts.test.js +2 -5
  31. package/dist/profiles/semantic-layer/v1/index.js +17 -6
  32. package/dist/profiles/semantic-layer/v1/prompts.js +3 -2
  33. package/dist/profiles/semantic-layer/v1/prompts.test.js +2 -5
  34. package/dist/profiles/semantic-layer/v1/resources/playbooks/compose-compile.md +14 -8
  35. package/dist/profiles/semantic-layer/v1/resources/playbooks/core.md +9 -9
  36. package/dist/profiles/semantic-layer/v1/resources/playbooks/explore.md +4 -3
  37. package/dist/profiles/test-support/playbook-invariants.d.ts +5 -0
  38. package/dist/profiles/test-support/playbook-invariants.js +14 -0
  39. package/dist/profiles/types.d.ts +6 -1
  40. package/dist/profiles/types.js +1 -1
  41. package/dist/protocol-contract.test.js +2 -2
  42. package/dist/server/capabilities.d.ts +2 -2
  43. package/dist/server/capabilities.js +3 -4
  44. package/dist/server/capabilities.test.js +4 -5
  45. package/dist/stdio.process.test.js +114 -193
  46. package/dist/tools/ai-agents/agents.d.ts +2 -0
  47. package/dist/tools/ai-agents/agents.js +5 -0
  48. package/dist/tools/ai-agents/discovery.d.ts +4 -0
  49. package/dist/tools/ai-agents/discovery.js +7 -0
  50. package/dist/tools/ai-agents/evaluations.d.ts +9 -0
  51. package/dist/tools/ai-agents/evaluations.js +12 -0
  52. package/dist/tools/ai-agents/threads.d.ts +2 -0
  53. package/dist/tools/ai-agents/threads.js +5 -0
  54. package/dist/tools/composition/explain-content.d.ts +1 -0
  55. package/dist/tools/composition/explain-content.js +4 -0
  56. package/dist/tools/organization/invariants.test.js +7 -3
  57. package/dist/tools/organization/inventory.d.ts +5 -0
  58. package/dist/tools/organization/inventory.js +8 -0
  59. package/dist/tools/organization/roles.d.ts +5 -0
  60. package/dist/tools/organization/roles.js +8 -0
  61. package/dist/tools/project/content.d.ts +4 -0
  62. package/dist/tools/project/content.js +7 -0
  63. package/dist/tools/project/delete-chart.d.ts +3 -1
  64. package/dist/tools/project/delete-chart.js +4 -2
  65. package/dist/tools/project/delete-dashboard.d.ts +3 -1
  66. package/dist/tools/project/delete-dashboard.js +4 -2
  67. package/dist/tools/project/developer-content-preview.d.ts +3 -0
  68. package/dist/tools/project/developer-content-preview.js +6 -0
  69. package/dist/tools/project/developer-content.d.ts +16 -1
  70. package/dist/tools/project/developer-content.js +18 -5
  71. package/dist/tools/project/developer-get-chart-as-code.d.ts +1 -0
  72. package/dist/tools/project/developer-get-chart-as-code.js +4 -0
  73. package/dist/tools/project/get-dashboard-promote-diff.d.ts +1 -0
  74. package/dist/tools/project/get-dashboard-promote-diff.js +4 -0
  75. package/dist/tools/project/invariants.test.js +6 -18
  76. package/dist/tools/project/parameters.d.ts +2 -0
  77. package/dist/tools/project/parameters.js +5 -0
  78. package/dist/tools/project/projects.d.ts +8 -2
  79. package/dist/tools/project/projects.js +34 -38
  80. package/dist/tools/project/projects.test.js +6 -6
  81. package/dist/tools/project/promote-dashboard.d.ts +3 -1
  82. package/dist/tools/project/promote-dashboard.js +4 -2
  83. package/dist/tools/project/reader-content.d.ts +3 -0
  84. package/dist/tools/project/reader-content.js +6 -0
  85. package/dist/tools/project/reader-execution.d.ts +2 -0
  86. package/dist/tools/project/reader-execution.js +5 -0
  87. package/dist/tools/project/reader-export-chart-image.d.ts +1 -0
  88. package/dist/tools/project/reader-export-chart-image.js +4 -0
  89. package/dist/tools/project/schedulers.d.ts +2 -0
  90. package/dist/tools/project/schedulers.js +5 -0
  91. package/dist/tools/project/spaces.d.ts +2 -0
  92. package/dist/tools/project/spaces.js +5 -0
  93. package/dist/tools/query/lifecycle.d.ts +2 -0
  94. package/dist/tools/query/lifecycle.js +5 -0
  95. package/dist/tools/query/run-metric-query.d.ts +1 -0
  96. package/dist/tools/query/run-metric-query.js +4 -0
  97. package/dist/tools/registry.d.ts +5 -284
  98. package/dist/tools/registry.js +9 -137
  99. package/dist/tools/registry.test.js +36 -0
  100. package/dist/tools/semantic/explores.d.ts +5 -1
  101. package/dist/tools/semantic/explores.js +8 -1
  102. package/dist/tools/semantic/metrics.d.ts +3 -1
  103. package/dist/tools/semantic/metrics.js +6 -1
  104. package/dist/tools/semantic/query.d.ts +2 -1
  105. package/dist/tools/semantic/query.js +11 -3
  106. package/dist/tools/semantic/query.test.d.ts +4 -0
  107. package/dist/tools/semantic/query.test.js +134 -0
  108. package/dist/tools/shared.d.ts +1 -1
  109. package/dist/tools/shared.js +2 -2
  110. package/dist/tools/space/access.d.ts +2 -0
  111. package/dist/tools/space/access.js +5 -0
  112. package/dist/tools/types.d.ts +18 -0
  113. package/dist/tools/types.js +29 -0
  114. package/dist/tools/types.test.js +50 -0
  115. package/package.json +6 -6
  116. package/dist/index.test.js +0 -9
  117. package/dist/profiles/profile.membership.test.js +0 -36
  118. package/dist/tools/index.d.ts +0 -4
  119. package/dist/tools/index.js +0 -8
  120. package/dist/tools/index.test.js +0 -78
  121. /package/dist/{index.test.d.ts → cli-help.test.d.ts} +0 -0
  122. /package/dist/{profiles/profile.membership.test.d.ts → tools/registry.test.d.ts} +0 -0
  123. /package/dist/tools/{index.test.d.ts → types.test.d.ts} +0 -0
@@ -31,15 +31,15 @@ Record when a budget stopped you.
31
31
 
32
32
  ## Allowed tools (`lightdash_` prefix)
33
33
 
34
- | Tool | Use for |
35
- | ------------------------------- | --------------------------------------------------------------------------------------------- |
36
- | `list_projects` / `get_project` | Confirm UUID ↔ name. Credentials never returned (`REDACTED` warning is normal). |
37
- | `list_explores` | Summaries only. **Always** pass `search` + `limit`. |
38
- | `list_dimensions` | Compact `{ name, label, table, type, fieldId }`. Default = base table only. |
39
- | `get_explore` | **Preferred** metric menu: `tables[baseTable].metrics` names/labels only. Ignore join tables. |
40
- | `list_metrics` / `get_metric` | Optional catalog / definition dig. Filter `tableName === exploreId`. |
41
- | `compile_query` | Compile only — never “run”. |
42
- | `get_field_lineage` | Optional provenance; summarize, don’t dump. |
34
+ | Tool | Use for |
35
+ | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
36
+ | `list_projects` / `get_project` | Confirm UUID ↔ name. Credentials never returned (`REDACTED` warning is normal). |
37
+ | `list_explores` | Summaries only. **Always** pass `search` + `limit`. |
38
+ | `list_dimensions` | Compact `{ name, label, table, type, fieldId }`. Default = base table only. |
39
+ | `get_explore` | **Preferred** metric menu: `tables[baseTable].metrics` names/labels only. Ignore join **metrics**; joined dims via `list_dimensions` (`baseTableOnly=false`) when needed. |
40
+ | `list_metrics` / `get_metric` | Optional catalog / definition dig. Filter `tableName === exploreId`. |
41
+ | `compile_query` | Compile only — never “run”. Sets `exploreName` from `exploreId`; defaults missing `tableCalculations` to `[]`. Prefer compiled SQL aliases over metric labels. |
42
+ | `get_field_lineage` | Optional provenance; summarize, don’t dump. |
43
43
 
44
44
  ## Project scope (critical)
45
45
 
@@ -37,7 +37,7 @@ Remember: `databaseName` may differ from the Lightdash project’s usual warehou
37
37
 
38
38
  1. `list_explores` → disambiguate → lock `exploreId` (= explore `name`).
39
39
  2. `list_dimensions` (default `baseTableOnly=true`). Set `baseTableOnly=false` only if you need joined-table fields (payload grows a lot).
40
- 3. Metrics: **`get_explore` → `tables[baseTable].metrics` only** (see below). Do not dump the explore JSON.
40
+ 3. Metrics: **`get_explore` → `tables[baseTable].metrics` only** (see below). Ignore join metrics; do not dump the explore JSON.
41
41
  4. Stop at a shortlist unless the user asked to compile.
42
42
 
43
43
  ## Metrics: catalog vs explore-local (critical)
@@ -53,11 +53,12 @@ Remember: `databaseName` may differ from the Lightdash project’s usual warehou
53
53
 
54
54
  Rules:
55
55
 
56
- 1. Once the explore is known, prefer **`get_explore` → `tables[baseTable].metrics`** for the local menu (names + labels only). Ignore other keys under `tables` (joins).
56
+ 1. Once the explore is known, prefer **`get_explore` → `tables[baseTable].metrics`** for the local menu (names + labels only). Ignore join **metrics** under other `tables` keys; do not dump the explore JSON.
57
57
  2. Optional catalog: at most **one** `list_metrics` page. Keep rows where `tableName` **equals the full explore id**.
58
- 3. `get_metric` `tableName` must be the full explore id. Short labels → “Metric not found”. Call only when definition/SQL is needed; summarize — payloads include huge `availableTimeDimensions` from joins.
58
+ 3. `get_metric` `tableName` must be the full explore id. Short labels → “Metric not found”. Call only when definition/SQL is needed; summarize — payloads include huge `availableTimeDimensions` from joins. Prefer `compiledSql` over name/label when they disagree.
59
59
  4. Compile metric ids as `{exploreId}_{metricName}` (same pattern as dimension `fieldId` from `list_dimensions`).
60
60
  5. Dimension-only (`metrics: []`) is valid for volume-by-time; for “insights” prefer real explore metrics when available.
61
+ 6. Joined **dimension** `fieldId`s (e.g. `customers_*` on an `orders` explore) are valid when `list_dimensions` with `baseTableOnly=false` returns them — use only those copied ids.
61
62
 
62
63
  ## Dimension shortlist (large explores)
63
64
 
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Shared playbook coverage checks for profile prompt tests.
3
+ */
4
+ import type { ProfileId } from '../types.js';
5
+ export declare function expectPlaybookCoversProfileTools(profileId: ProfileId, markdown: string): void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /**
3
+ * Shared playbook coverage checks for profile prompt tests.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.expectPlaybookCoversProfileTools = expectPlaybookCoversProfileTools;
7
+ const vitest_1 = require("vitest");
8
+ const index_js_1 = require("../index.js");
9
+ function expectPlaybookCoversProfileTools(profileId, markdown) {
10
+ for (const id of (0, index_js_1.listToolIds)((0, index_js_1.getProfile)(profileId))) {
11
+ (0, vitest_1.expect)(markdown.includes(id) || markdown.includes(`lightdash_${id}`)).toBe(true);
12
+ }
13
+ (0, vitest_1.expect)(markdown).not.toMatch(/\bldt__/);
14
+ }
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Profile packaging types (tools from the operation catalog, ADR-0006).
2
+ * Profile packaging types — tools are ToolModules imported by each profile.
3
3
  */
4
+ import type { ToolModule } from '../tools/types.js';
4
5
  import type { ProfileId } from '@lightdash-tools/common';
5
6
  import type { McpServer } from '@modelcontextprotocol/server';
6
7
  export type { ProfileId };
@@ -13,6 +14,10 @@ export type ProfileDefinition = {
13
14
  * Use a shorter name when combined with `lightdash_*` tools would exceed ~60 chars.
14
15
  */
15
16
  serverName?: string;
17
+ /**
18
+ * Mounted tools for this profile (import ToolModules; array order is tools/list order).
19
+ */
20
+ tools: readonly ToolModule[];
16
21
  registerPrompts: (server: McpServer) => void;
17
22
  registerResources: (server: McpServer) => void;
18
23
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  /**
3
- * Profile packaging types (tools from the operation catalog, ADR-0006).
3
+ * Profile packaging types — tools are ToolModules imported by each profile.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  * (createMcpHandler + StreamableHTTPClientTransport with versionNegotiation).
6
6
  * No Lightdash network calls — stub McpContextProvider only.
7
7
  */
8
- const common_1 = require("@lightdash-tools/common");
9
8
  const client_1 = require("@modelcontextprotocol/client");
10
9
  const server_1 = require("@modelcontextprotocol/server");
11
10
  const vitest_1 = require("vitest");
11
+ const index_js_1 = require("./profiles/index.js");
12
12
  const server_js_1 = require("./server/server.js");
13
13
  const shared_js_1 = require("./tools/shared.js");
14
- const EXPECTED_TOOL_COUNT = (0, common_1.listMcpToolNamesByProfile)('semantic-layer').length;
14
+ const EXPECTED_TOOL_COUNT = (0, index_js_1.getProfile)('semantic-layer').tools.length;
15
15
  function createStubContextProvider() {
16
16
  return {
17
17
  getContext: async () => ({
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Register tools / prompts / resources for a profile.
2
+ * Registers MCP capabilities for a profile.
3
3
  */
4
4
  import type { McpContextProvider } from './request-context.js';
5
5
  import type { ProfileDefinition } from '../profiles/types.js';
@@ -10,6 +10,6 @@ export type RegisterCapabilitiesOptions = {
10
10
  };
11
11
  /**
12
12
  * Registers MCP capabilities for the given profile.
13
- * Tools come from the operation catalog via listMcpToolNamesByProfile (ADR-0006).
13
+ * Tools come from profile.tools (ToolModule imports).
14
14
  */
15
15
  export declare function registerCapabilities(server: McpServer, contextProvider: McpContextProvider, options?: RegisterCapabilitiesOptions): void;
@@ -1,22 +1,21 @@
1
1
  "use strict";
2
2
  /**
3
- * Register tools / prompts / resources for a profile.
3
+ * Registers MCP capabilities for a profile.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.registerCapabilities = registerCapabilities;
7
- const common_1 = require("@lightdash-tools/common");
8
7
  const server_profile_js_1 = require("../audit/server-profile.js");
9
8
  const index_js_1 = require("../profiles/index.js");
10
9
  const registry_js_1 = require("../tools/registry.js");
11
10
  /**
12
11
  * Registers MCP capabilities for the given profile.
13
- * Tools come from the operation catalog via listMcpToolNamesByProfile (ADR-0006).
12
+ * Tools come from profile.tools (ToolModule imports).
14
13
  */
15
14
  function registerCapabilities(server, contextProvider, options) {
16
15
  var _a;
17
16
  const profile = (_a = options === null || options === void 0 ? void 0 : options.profile) !== null && _a !== void 0 ? _a : (0, index_js_1.getDefaultProfile)();
18
17
  (0, server_profile_js_1.bindServerProfile)(server, profile.id);
19
- (0, registry_js_1.registerToolsByIds)(server, contextProvider, (0, common_1.listMcpToolNamesByProfile)(profile.id));
18
+ (0, registry_js_1.registerTools)(server, contextProvider, profile.tools);
20
19
  profile.registerPrompts(server);
21
20
  profile.registerResources(server);
22
21
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const common_1 = require("@lightdash-tools/common");
4
3
  const server_1 = require("@modelcontextprotocol/server");
5
4
  const vitest_1 = require("vitest");
6
5
  const server_profile_js_1 = require("../audit/server-profile.js");
@@ -10,7 +9,7 @@ const capabilities_js_1 = require("./capabilities.js");
10
9
  vitest_1.vi.mock('../tools/registry.js', async (importOriginal) => {
11
10
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports -- vitest importOriginal
12
11
  const actual = await importOriginal();
13
- return Object.assign(Object.assign({}, actual), { registerToolsByIds: vitest_1.vi.fn() });
12
+ return Object.assign(Object.assign({}, actual), { registerTools: vitest_1.vi.fn() });
14
13
  });
15
14
  function createMockContextProvider(lightdashClient = {}) {
16
15
  return {
@@ -29,13 +28,13 @@ function createMockContextProvider(lightdashClient = {}) {
29
28
  server = new server_1.McpServer({ name: 'test', version: '0.0.0' });
30
29
  registerPromptSpy = vitest_1.vi.spyOn(server, 'registerPrompt');
31
30
  registerResourceSpy = vitest_1.vi.spyOn(server, 'registerResource');
32
- vitest_1.vi.mocked(registry_js_1.registerToolsByIds).mockClear();
31
+ vitest_1.vi.mocked(registry_js_1.registerTools).mockClear();
33
32
  });
34
- (0, vitest_1.it)('registers catalog tools and prompts/resources for the profile', () => {
33
+ (0, vitest_1.it)('registers profile tools and prompts/resources', () => {
35
34
  const profile = (0, index_js_1.getDefaultProfile)();
36
35
  (0, capabilities_js_1.registerCapabilities)(server, mockContextProvider, { profile });
37
36
  (0, vitest_1.expect)((0, server_profile_js_1.getServerProfile)(server)).toBe(profile.id);
38
- (0, vitest_1.expect)(registry_js_1.registerToolsByIds).toHaveBeenCalledWith(server, mockContextProvider, (0, common_1.listMcpToolNamesByProfile)(profile.id));
37
+ (0, vitest_1.expect)(registry_js_1.registerTools).toHaveBeenCalledWith(server, mockContextProvider, profile.tools);
39
38
  (0, vitest_1.expect)(registerPromptSpy).toHaveBeenCalled();
40
39
  (0, vitest_1.expect)(registerResourceSpy).toHaveBeenCalled();
41
40
  });
@@ -9,15 +9,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  */
10
10
  const node_child_process_1 = require("node:child_process");
11
11
  const node_path_1 = __importDefault(require("node:path"));
12
- const common_1 = require("@lightdash-tools/common");
13
12
  const server_1 = require("@modelcontextprotocol/server");
14
13
  const vitest_1 = require("vitest");
14
+ const index_js_1 = require("./profiles/index.js");
15
15
  const shared_js_1 = require("./tools/shared.js");
16
16
  /** Vitest runs from the monorepo root (`vitest.config.ts`). */
17
17
  const repoRoot = process.cwd();
18
18
  const binPath = node_path_1.default.join(repoRoot, 'packages/mcp/dist/bin.js');
19
19
  const INIT_TIMEOUT_MS = 5000;
20
- const SEMANTIC_LAYER_TOOL_COUNT = (0, common_1.listMcpToolNamesByProfile)('semantic-layer').length;
20
+ const SEMANTIC_LAYER_TOOL_COUNT = (0, index_js_1.getProfile)('semantic-layer').tools.length;
21
21
  function writeLine(child, message) {
22
22
  child.stdin.write(`${JSON.stringify(message)}\n`);
23
23
  }
@@ -71,6 +71,68 @@ function killChild(child) {
71
71
  return;
72
72
  child.kill('SIGTERM');
73
73
  }
74
+ function stdioSmokeEnv(overrides = {}) {
75
+ return Object.assign(Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_AUDIT_LOG: undefined }), overrides);
76
+ }
77
+ function spawnStdioBin(args, envOverrides = {}) {
78
+ let stderr = '';
79
+ const child = (0, node_child_process_1.spawn)(process.execPath, [binPath, ...args], {
80
+ cwd: repoRoot,
81
+ env: stdioSmokeEnv(envOverrides),
82
+ stdio: ['pipe', 'pipe', 'pipe'],
83
+ });
84
+ child.stderr.setEncoding('utf8');
85
+ child.stderr.on('data', (chunk) => {
86
+ stderr += chunk;
87
+ });
88
+ return { child, getStderr: () => stderr };
89
+ }
90
+ async function spawnBinAndAwaitExit(args, envOverrides = {}) {
91
+ let stdout = '';
92
+ const { child, getStderr } = spawnStdioBin(args, envOverrides);
93
+ child.stdout.setEncoding('utf8');
94
+ child.stdout.on('data', (chunk) => {
95
+ stdout += chunk;
96
+ });
97
+ const code = await new Promise((resolve) => {
98
+ child.once('exit', (exitCode) => resolve(exitCode));
99
+ });
100
+ return { code, stderr: getStderr(), stdout };
101
+ }
102
+ /** Legacy initialize → notifications/initialized → tools/list over stdio. */
103
+ async function initializeThenListTools(child, getStderr, clientName) {
104
+ var _a;
105
+ writeLine(child, {
106
+ jsonrpc: '2.0',
107
+ id: 1,
108
+ method: 'initialize',
109
+ params: {
110
+ protocolVersion: '2024-11-05',
111
+ capabilities: {},
112
+ clientInfo: { name: clientName, version: '0.0.0' },
113
+ },
114
+ });
115
+ const initResponse = await readJsonRpcResponse(child, 1, INIT_TIMEOUT_MS, getStderr);
116
+ (0, vitest_1.expect)(initResponse.error).toBeUndefined();
117
+ (0, vitest_1.expect)(initResponse.result).toBeDefined();
118
+ const initResult = initResponse.result;
119
+ (0, vitest_1.expect)(initResult.protocolVersion).toBeTruthy();
120
+ writeLine(child, {
121
+ jsonrpc: '2.0',
122
+ method: 'notifications/initialized',
123
+ });
124
+ writeLine(child, {
125
+ jsonrpc: '2.0',
126
+ id: 2,
127
+ method: 'tools/list',
128
+ params: {},
129
+ });
130
+ const listResponse = await readJsonRpcResponse(child, 2, INIT_TIMEOUT_MS, getStderr);
131
+ (0, vitest_1.expect)(listResponse.error).toBeUndefined();
132
+ const tools = listResponse.result.tools;
133
+ (0, vitest_1.expect)(Array.isArray(tools)).toBe(true);
134
+ return { serverName: (_a = initResult.serverInfo) === null || _a === void 0 ? void 0 : _a.name, tools: tools !== null && tools !== void 0 ? tools : [] };
135
+ }
74
136
  (0, vitest_1.describe)('stdio process smoke', () => {
75
137
  let child;
76
138
  (0, vitest_1.afterEach)(() => {
@@ -79,16 +141,9 @@ function killChild(child) {
79
141
  });
80
142
  (0, vitest_1.it)('server/discover then tools/list over stdio (modern era)', async () => {
81
143
  var _a;
82
- let stderr = '';
83
- child = (0, node_child_process_1.spawn)(process.execPath, [binPath], {
84
- cwd: repoRoot,
85
- env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'semantic-layer', LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
86
- stdio: ['pipe', 'pipe', 'pipe'],
87
- });
88
- child.stderr.setEncoding('utf8');
89
- child.stderr.on('data', (chunk) => {
90
- stderr += chunk;
91
- });
144
+ const spawned = spawnStdioBin(['stdio', '--profile', 'semantic-layer']);
145
+ child = spawned.child;
146
+ const getStderr = spawned.getStderr;
92
147
  const modernMeta = {
93
148
  [server_1.PROTOCOL_VERSION_META_KEY]: '2026-07-28',
94
149
  [server_1.CLIENT_INFO_META_KEY]: {
@@ -103,7 +158,7 @@ function killChild(child) {
103
158
  method: 'server/discover',
104
159
  params: { _meta: modernMeta },
105
160
  });
106
- const discoverResponse = await readJsonRpcResponse(child, 1, INIT_TIMEOUT_MS, () => stderr);
161
+ const discoverResponse = await readJsonRpcResponse(child, 1, INIT_TIMEOUT_MS, getStderr);
107
162
  (0, vitest_1.expect)(discoverResponse.error).toBeUndefined();
108
163
  (0, vitest_1.expect)(discoverResponse.result).toBeDefined();
109
164
  const discoverResult = discoverResponse.result;
@@ -115,7 +170,7 @@ function killChild(child) {
115
170
  method: 'tools/list',
116
171
  params: { _meta: modernMeta },
117
172
  });
118
- const listResponse = await readJsonRpcResponse(child, 2, INIT_TIMEOUT_MS, () => stderr);
173
+ const listResponse = await readJsonRpcResponse(child, 2, INIT_TIMEOUT_MS, getStderr);
119
174
  (0, vitest_1.expect)(listResponse.error).toBeUndefined();
120
175
  (0, vitest_1.expect)(listResponse.result).toMatchObject({
121
176
  tools: vitest_1.expect.arrayContaining([
@@ -128,148 +183,34 @@ function killChild(child) {
128
183
  child = undefined;
129
184
  });
130
185
  (0, vitest_1.it)('initialize then tools/list over stdio', async () => {
131
- var _a;
132
- let stderr = '';
133
- child = (0, node_child_process_1.spawn)(process.execPath, [binPath], {
134
- cwd: repoRoot,
135
- env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'semantic-layer',
136
- // Avoid inheriting real credentials or network-affecting settings.
137
- LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
138
- stdio: ['pipe', 'pipe', 'pipe'],
139
- });
140
- // Drain stderr so the child cannot block on a full pipe and preserve it for failures.
141
- child.stderr.setEncoding('utf8');
142
- child.stderr.on('data', (chunk) => {
143
- stderr += chunk;
144
- });
145
- writeLine(child, {
146
- jsonrpc: '2.0',
147
- id: 1,
148
- method: 'initialize',
149
- params: {
150
- protocolVersion: '2024-11-05',
151
- capabilities: {},
152
- clientInfo: { name: 'stdio-process-smoke', version: '0.0.0' },
153
- },
154
- });
155
- const initResponse = await readJsonRpcResponse(child, 1, INIT_TIMEOUT_MS, () => stderr);
156
- (0, vitest_1.expect)(initResponse.error).toBeUndefined();
157
- (0, vitest_1.expect)(initResponse.result).toBeDefined();
158
- const initResult = initResponse.result;
159
- (0, vitest_1.expect)((_a = initResult.serverInfo) === null || _a === void 0 ? void 0 : _a.name).toBe('lightdash-mcp-semantic-layer');
160
- (0, vitest_1.expect)(initResult.protocolVersion).toBeTruthy();
161
- writeLine(child, {
162
- jsonrpc: '2.0',
163
- method: 'notifications/initialized',
164
- });
165
- writeLine(child, {
166
- jsonrpc: '2.0',
167
- id: 2,
168
- method: 'tools/list',
169
- params: {},
170
- });
171
- const listResponse = await readJsonRpcResponse(child, 2, INIT_TIMEOUT_MS, () => stderr);
172
- (0, vitest_1.expect)(listResponse.error).toBeUndefined();
173
- const listResult = listResponse.result;
174
- (0, vitest_1.expect)(Array.isArray(listResult.tools)).toBe(true);
175
- (0, vitest_1.expect)(listResult.tools.length).toBeGreaterThan(0);
176
- (0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_list_projects')).toBe(true);
186
+ const spawned = spawnStdioBin(['stdio', '--profile', 'semantic-layer']);
187
+ child = spawned.child;
188
+ const { serverName, tools } = await initializeThenListTools(child, spawned.getStderr, 'stdio-process-smoke');
189
+ (0, vitest_1.expect)(serverName).toBe('lightdash-mcp-semantic-layer');
190
+ (0, vitest_1.expect)(tools.length).toBeGreaterThan(0);
191
+ (0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_list_projects')).toBe(true);
177
192
  killChild(child);
178
193
  child = undefined;
179
194
  });
180
195
  (0, vitest_1.it)('initialize then tools/list for content-reader profile', async () => {
181
- var _a;
182
- let stderr = '';
183
- child = (0, node_child_process_1.spawn)(process.execPath, [binPath, 'content-reader'], {
184
- cwd: repoRoot,
185
- env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'content-reader', LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
186
- stdio: ['pipe', 'pipe', 'pipe'],
187
- });
188
- child.stderr.setEncoding('utf8');
189
- child.stderr.on('data', (chunk) => {
190
- stderr += chunk;
191
- });
192
- writeLine(child, {
193
- jsonrpc: '2.0',
194
- id: 1,
195
- method: 'initialize',
196
- params: {
197
- protocolVersion: '2024-11-05',
198
- capabilities: {},
199
- clientInfo: { name: 'stdio-process-smoke', version: '0.0.0' },
200
- },
201
- });
202
- const initResponse = await readJsonRpcResponse(child, 1, INIT_TIMEOUT_MS, () => stderr);
203
- (0, vitest_1.expect)(initResponse.error).toBeUndefined();
204
- (0, vitest_1.expect)(initResponse.result).toBeDefined();
205
- const initResult = initResponse.result;
206
- (0, vitest_1.expect)((_a = initResult.serverInfo) === null || _a === void 0 ? void 0 : _a.name).toBe('lightdash-mcp-content');
207
- (0, vitest_1.expect)(initResult.protocolVersion).toBeTruthy();
208
- writeLine(child, {
209
- jsonrpc: '2.0',
210
- method: 'notifications/initialized',
211
- });
212
- writeLine(child, {
213
- jsonrpc: '2.0',
214
- id: 2,
215
- method: 'tools/list',
216
- params: {},
217
- });
218
- const listResponse = await readJsonRpcResponse(child, 2, INIT_TIMEOUT_MS, () => stderr);
219
- (0, vitest_1.expect)(listResponse.error).toBeUndefined();
220
- const listResult = listResponse.result;
221
- (0, vitest_1.expect)(Array.isArray(listResult.tools)).toBe(true);
222
- (0, vitest_1.expect)(listResult.tools).toHaveLength(14);
223
- (0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_search_content')).toBe(true);
224
- (0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_run_chart')).toBe(true);
225
- (0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_export_chart_image')).toBe(true);
196
+ const spawned = spawnStdioBin(['stdio', '--profile', 'content-reader']);
197
+ child = spawned.child;
198
+ const { serverName, tools } = await initializeThenListTools(child, spawned.getStderr, 'stdio-process-smoke');
199
+ (0, vitest_1.expect)(serverName).toBe('lightdash-mcp-content');
200
+ (0, vitest_1.expect)(tools).toHaveLength(14);
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_run_chart')).toBe(true);
203
+ (0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_export_chart_image')).toBe(true);
226
204
  killChild(child);
227
205
  child = undefined;
228
206
  });
229
207
  (0, vitest_1.it)('initialize then tools/list for content-governance profile', async () => {
230
- var _a;
231
- let stderr = '';
232
- child = (0, node_child_process_1.spawn)(process.execPath, [binPath, 'content-governance'], {
233
- cwd: repoRoot,
234
- env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'content-governance', LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
235
- stdio: ['pipe', 'pipe', 'pipe'],
236
- });
237
- child.stderr.setEncoding('utf8');
238
- child.stderr.on('data', (chunk) => {
239
- stderr += chunk;
240
- });
241
- writeLine(child, {
242
- jsonrpc: '2.0',
243
- id: 1,
244
- method: 'initialize',
245
- params: {
246
- protocolVersion: '2024-11-05',
247
- capabilities: {},
248
- clientInfo: { name: 'stdio-process-smoke', version: '0.0.0' },
249
- },
250
- });
251
- const initResponse = await readJsonRpcResponse(child, 1, INIT_TIMEOUT_MS, () => stderr);
252
- (0, vitest_1.expect)(initResponse.error).toBeUndefined();
253
- (0, vitest_1.expect)(initResponse.result).toBeDefined();
254
- const initResult = initResponse.result;
255
- (0, vitest_1.expect)((_a = initResult.serverInfo) === null || _a === void 0 ? void 0 : _a.name).toBe('lightdash-mcp-gov');
256
- (0, vitest_1.expect)(initResult.protocolVersion).toBeTruthy();
257
- writeLine(child, {
258
- jsonrpc: '2.0',
259
- method: 'notifications/initialized',
260
- });
261
- writeLine(child, {
262
- jsonrpc: '2.0',
263
- id: 2,
264
- method: 'tools/list',
265
- params: {},
266
- });
267
- const listResponse = await readJsonRpcResponse(child, 2, INIT_TIMEOUT_MS, () => stderr);
268
- (0, vitest_1.expect)(listResponse.error).toBeUndefined();
269
- const listResult = listResponse.result;
270
- (0, vitest_1.expect)(Array.isArray(listResult.tools)).toBe(true);
271
- (0, vitest_1.expect)(listResult.tools).toHaveLength(4);
272
- (0, vitest_1.expect)(listResult.tools.map((t) => t.name).sort()).toEqual([
208
+ const spawned = spawnStdioBin(['stdio', '--profile', 'content-governance']);
209
+ child = spawned.child;
210
+ const { serverName, tools } = await initializeThenListTools(child, spawned.getStderr, 'stdio-process-smoke');
211
+ (0, vitest_1.expect)(serverName).toBe('lightdash-mcp-gov');
212
+ (0, vitest_1.expect)(tools).toHaveLength(4);
213
+ (0, vitest_1.expect)(tools.map((t) => t.name).sort()).toEqual([
273
214
  'lightdash_delete_chart',
274
215
  'lightdash_delete_dashboard',
275
216
  'lightdash_get_dashboard_promote_diff',
@@ -279,52 +220,32 @@ function killChild(child) {
279
220
  child = undefined;
280
221
  });
281
222
  (0, vitest_1.it)('initialize then tools/list for content-developer profile', async () => {
282
- var _a;
283
- let stderr = '';
284
- child = (0, node_child_process_1.spawn)(process.execPath, [binPath, 'content-developer'], {
285
- cwd: repoRoot,
286
- env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke', LIGHTDASH_TOOLS_MCP_STDIO_PROFILE: 'content-developer', LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
287
- stdio: ['pipe', 'pipe', 'pipe'],
288
- });
289
- child.stderr.setEncoding('utf8');
290
- child.stderr.on('data', (chunk) => {
291
- stderr += chunk;
292
- });
293
- writeLine(child, {
294
- jsonrpc: '2.0',
295
- id: 1,
296
- method: 'initialize',
297
- params: {
298
- protocolVersion: '2024-11-05',
299
- capabilities: {},
300
- clientInfo: { name: 'stdio-process-smoke', version: '0.0.0' },
301
- },
302
- });
303
- const initResponse = await readJsonRpcResponse(child, 1, INIT_TIMEOUT_MS, () => stderr);
304
- (0, vitest_1.expect)(initResponse.error).toBeUndefined();
305
- (0, vitest_1.expect)(initResponse.result).toBeDefined();
306
- const initResult = initResponse.result;
307
- (0, vitest_1.expect)((_a = initResult.serverInfo) === null || _a === void 0 ? void 0 : _a.name).toBe('lightdash-mcp-cdev');
308
- (0, vitest_1.expect)(initResult.protocolVersion).toBeTruthy();
309
- writeLine(child, {
310
- jsonrpc: '2.0',
311
- method: 'notifications/initialized',
312
- });
313
- writeLine(child, {
314
- jsonrpc: '2.0',
315
- id: 2,
316
- method: 'tools/list',
317
- params: {},
318
- });
319
- const listResponse = await readJsonRpcResponse(child, 2, INIT_TIMEOUT_MS, () => stderr);
320
- (0, vitest_1.expect)(listResponse.error).toBeUndefined();
321
- const listResult = listResponse.result;
322
- (0, vitest_1.expect)(Array.isArray(listResult.tools)).toBe(true);
323
- (0, vitest_1.expect)(listResult.tools).toHaveLength(26);
324
- (0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_get_chart_as_code')).toBe(true);
325
- (0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_preview_dashboard_changes')).toBe(true);
326
- (0, vitest_1.expect)(listResult.tools.some((t) => t.name === 'lightdash_move_content')).toBe(true);
223
+ const spawned = spawnStdioBin(['stdio', '--profile', 'content-developer']);
224
+ child = spawned.child;
225
+ const { serverName, tools } = await initializeThenListTools(child, spawned.getStderr, 'stdio-process-smoke');
226
+ (0, vitest_1.expect)(serverName).toBe('lightdash-mcp-cdev');
227
+ (0, vitest_1.expect)(tools).toHaveLength(26);
228
+ (0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_get_chart_as_code')).toBe(true);
229
+ (0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_preview_dashboard_changes')).toBe(true);
230
+ (0, vitest_1.expect)(tools.some((t) => t.name === 'lightdash_move_content')).toBe(true);
327
231
  killChild(child);
328
232
  child = undefined;
329
233
  });
234
+ (0, vitest_1.it)('bare invoke exits nonzero without a transport', async () => {
235
+ const result = await spawnBinAndAwaitExit([]);
236
+ (0, vitest_1.expect)(result.code).toBe(1);
237
+ (0, vitest_1.expect)(result.stderr).toMatch(/stdio --profile/i);
238
+ (0, vitest_1.expect)(result.stdout).toBe('');
239
+ });
240
+ (0, vitest_1.it)('stdio without --profile exits nonzero', async () => {
241
+ const result = await spawnBinAndAwaitExit(['stdio']);
242
+ (0, vitest_1.expect)(result.code).not.toBe(0);
243
+ (0, vitest_1.expect)(result.stderr).toMatch(/required option|--profile|usage:/i);
244
+ });
245
+ (0, vitest_1.it)('stdio with invalid --profile exits nonzero', async () => {
246
+ const result = await spawnBinAndAwaitExit(['stdio', '--profile', 'not-a-profile']);
247
+ (0, vitest_1.expect)(result.code).toBe(1);
248
+ (0, vitest_1.expect)(result.stderr).toMatch(/Invalid profile/i);
249
+ (0, vitest_1.expect)(result.stdout).toBe('');
250
+ });
330
251
  });
@@ -5,3 +5,5 @@ import type { McpContextProvider } from '../../server/request-context.js';
5
5
  import type { McpServer } from '@modelcontextprotocol/server';
6
6
  export declare function registerListProjectAgents(server: McpServer, contextProvider: McpContextProvider): void;
7
7
  export declare function registerGetProjectAgent(server: McpServer, contextProvider: McpContextProvider): void;
8
+ export declare const listProjectAgentsTool: import("../types.js").ToolModule;
9
+ export declare const getProjectAgentTool: import("../types.js").ToolModule;
@@ -3,9 +3,11 @@
3
3
  * Project AI agent inventory tools (ai-agent-ops profile).
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getProjectAgentTool = exports.listProjectAgentsTool = void 0;
6
7
  exports.registerListProjectAgents = registerListProjectAgents;
7
8
  exports.registerGetProjectAgent = registerGetProjectAgent;
8
9
  const shared_js_1 = require("../shared.js");
10
+ const types_js_1 = require("../types.js");
9
11
  const helpers_js_1 = require("./helpers.js");
10
12
  function registerListProjectAgents(server, contextProvider) {
11
13
  (0, shared_js_1.registerToolSafe)(server, 'list_project_agents', {
@@ -30,3 +32,6 @@ function registerGetProjectAgent(server, contextProvider) {
30
32
  data: await c.v1.aiAgents.getAgent(scope.projectUuid, agentUuid),
31
33
  }))));
32
34
  }
35
+ // ToolModule exports (profile mounts)
36
+ exports.listProjectAgentsTool = (0, types_js_1.defineTool)('list_project_agents', registerListProjectAgents);
37
+ exports.getProjectAgentTool = (0, types_js_1.defineTool)('get_project_agent', registerGetProjectAgent);
@@ -7,3 +7,7 @@ export declare function registerEvaluateAgentReadiness(server: McpServer, contex
7
7
  export declare function registerGetAgentSuggestions(server: McpServer, contextProvider: McpContextProvider): void;
8
8
  export declare function registerGetAgentModels(server: McpServer, contextProvider: McpContextProvider): void;
9
9
  export declare function registerGetExploreAccessSummary(server: McpServer, contextProvider: McpContextProvider): void;
10
+ export declare const evaluateAgentReadinessTool: import("../types.js").ToolModule;
11
+ export declare const getAgentSuggestionsTool: import("../types.js").ToolModule;
12
+ export declare const getAgentModelsTool: import("../types.js").ToolModule;
13
+ export declare const getExploreAccessSummaryTool: import("../types.js").ToolModule;
@@ -3,12 +3,14 @@
3
3
  * AI agent discovery tools (readiness, suggestions, models, explore access).
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getExploreAccessSummaryTool = exports.getAgentModelsTool = exports.getAgentSuggestionsTool = exports.evaluateAgentReadinessTool = void 0;
6
7
  exports.registerEvaluateAgentReadiness = registerEvaluateAgentReadiness;
7
8
  exports.registerGetAgentSuggestions = registerGetAgentSuggestions;
8
9
  exports.registerGetAgentModels = registerGetAgentModels;
9
10
  exports.registerGetExploreAccessSummary = registerGetExploreAccessSummary;
10
11
  const zod_1 = require("zod");
11
12
  const shared_js_1 = require("../shared.js");
13
+ const types_js_1 = require("../types.js");
12
14
  const helpers_js_1 = require("./helpers.js");
13
15
  const READINESS_LIMITATION = 'evaluate_agent_readiness calls the Lightdash readiness API only. It is not an evaluation-suite run and does not invoke the agent end-to-end.';
14
16
  function registerEvaluateAgentReadiness(server, contextProvider) {
@@ -71,3 +73,8 @@ function registerGetExploreAccessSummary(server, contextProvider) {
71
73
  }),
72
74
  }))));
73
75
  }
76
+ // ToolModule exports (profile mounts)
77
+ exports.evaluateAgentReadinessTool = (0, types_js_1.defineTool)('evaluate_agent_readiness', registerEvaluateAgentReadiness);
78
+ exports.getAgentSuggestionsTool = (0, types_js_1.defineTool)('get_agent_suggestions', registerGetAgentSuggestions);
79
+ exports.getAgentModelsTool = (0, types_js_1.defineTool)('get_agent_models', registerGetAgentModels);
80
+ exports.getExploreAccessSummaryTool = (0, types_js_1.defineTool)('get_explore_access_summary', registerGetExploreAccessSummary);