@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.
- package/README.md +23 -14
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +31 -57
- package/dist/cli-help.d.ts +5 -0
- package/dist/cli-help.js +23 -0
- package/dist/cli-help.test.js +24 -0
- package/dist/config/env.d.ts +2 -2
- package/dist/config/env.js +3 -3
- package/dist/config/load-mcp-config.js +10 -2
- package/dist/config/load-mcp-config.test.js +34 -6
- package/dist/config/obsolete-env.js +0 -4
- package/dist/config/obsolete-env.test.js +0 -5
- package/dist/config/runtime.js +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +22 -32
- package/dist/profiles/ai-agent-ops/v1/index.js +25 -6
- package/dist/profiles/ai-agent-ops/v1/prompts.test.js +2 -5
- package/dist/profiles/content-developer/v1/index.js +36 -6
- package/dist/profiles/content-developer/v1/prompts.test.js +7 -8
- package/dist/profiles/content-governance/v1/index.js +7 -6
- package/dist/profiles/content-governance/v1/prompts.test.js +2 -5
- package/dist/profiles/content-reader/v1/index.js +26 -6
- package/dist/profiles/content-reader/v1/prompts.test.js +2 -5
- package/dist/profiles/data-analyst/v1/index.js +19 -6
- package/dist/profiles/data-analyst/v1/prompts.test.js +2 -4
- package/dist/profiles/index.d.ts +3 -1
- package/dist/profiles/index.js +6 -1
- package/dist/profiles/index.test.js +29 -14
- package/dist/profiles/organization-audit/v1/index.js +27 -6
- package/dist/profiles/organization-audit/v1/prompts.test.js +2 -5
- package/dist/profiles/semantic-layer/v1/index.js +17 -6
- package/dist/profiles/semantic-layer/v1/prompts.js +3 -2
- package/dist/profiles/semantic-layer/v1/prompts.test.js +2 -5
- package/dist/profiles/semantic-layer/v1/resources/playbooks/compose-compile.md +14 -8
- package/dist/profiles/semantic-layer/v1/resources/playbooks/core.md +9 -9
- package/dist/profiles/semantic-layer/v1/resources/playbooks/explore.md +4 -3
- package/dist/profiles/test-support/playbook-invariants.d.ts +5 -0
- package/dist/profiles/test-support/playbook-invariants.js +14 -0
- package/dist/profiles/types.d.ts +6 -1
- package/dist/profiles/types.js +1 -1
- package/dist/protocol-contract.test.js +2 -2
- package/dist/server/capabilities.d.ts +2 -2
- package/dist/server/capabilities.js +3 -4
- package/dist/server/capabilities.test.js +4 -5
- package/dist/stdio.process.test.js +114 -193
- package/dist/tools/ai-agents/agents.d.ts +2 -0
- package/dist/tools/ai-agents/agents.js +5 -0
- package/dist/tools/ai-agents/discovery.d.ts +4 -0
- package/dist/tools/ai-agents/discovery.js +7 -0
- package/dist/tools/ai-agents/evaluations.d.ts +9 -0
- package/dist/tools/ai-agents/evaluations.js +12 -0
- package/dist/tools/ai-agents/threads.d.ts +2 -0
- package/dist/tools/ai-agents/threads.js +5 -0
- package/dist/tools/composition/explain-content.d.ts +1 -0
- package/dist/tools/composition/explain-content.js +4 -0
- package/dist/tools/organization/invariants.test.js +7 -3
- package/dist/tools/organization/inventory.d.ts +5 -0
- package/dist/tools/organization/inventory.js +8 -0
- package/dist/tools/organization/roles.d.ts +5 -0
- package/dist/tools/organization/roles.js +8 -0
- package/dist/tools/project/content.d.ts +4 -0
- package/dist/tools/project/content.js +7 -0
- package/dist/tools/project/delete-chart.d.ts +3 -1
- package/dist/tools/project/delete-chart.js +4 -2
- package/dist/tools/project/delete-dashboard.d.ts +3 -1
- package/dist/tools/project/delete-dashboard.js +4 -2
- package/dist/tools/project/developer-content-preview.d.ts +3 -0
- package/dist/tools/project/developer-content-preview.js +6 -0
- package/dist/tools/project/developer-content.d.ts +16 -1
- package/dist/tools/project/developer-content.js +18 -5
- package/dist/tools/project/developer-get-chart-as-code.d.ts +1 -0
- package/dist/tools/project/developer-get-chart-as-code.js +4 -0
- package/dist/tools/project/get-dashboard-promote-diff.d.ts +1 -0
- package/dist/tools/project/get-dashboard-promote-diff.js +4 -0
- package/dist/tools/project/invariants.test.js +6 -18
- package/dist/tools/project/parameters.d.ts +2 -0
- package/dist/tools/project/parameters.js +5 -0
- package/dist/tools/project/projects.d.ts +8 -2
- package/dist/tools/project/projects.js +34 -38
- package/dist/tools/project/projects.test.js +6 -6
- package/dist/tools/project/promote-dashboard.d.ts +3 -1
- package/dist/tools/project/promote-dashboard.js +4 -2
- package/dist/tools/project/reader-content.d.ts +3 -0
- package/dist/tools/project/reader-content.js +6 -0
- package/dist/tools/project/reader-execution.d.ts +2 -0
- package/dist/tools/project/reader-execution.js +5 -0
- package/dist/tools/project/reader-export-chart-image.d.ts +1 -0
- package/dist/tools/project/reader-export-chart-image.js +4 -0
- package/dist/tools/project/schedulers.d.ts +2 -0
- package/dist/tools/project/schedulers.js +5 -0
- package/dist/tools/project/spaces.d.ts +2 -0
- package/dist/tools/project/spaces.js +5 -0
- package/dist/tools/query/lifecycle.d.ts +2 -0
- package/dist/tools/query/lifecycle.js +5 -0
- package/dist/tools/query/run-metric-query.d.ts +1 -0
- package/dist/tools/query/run-metric-query.js +4 -0
- package/dist/tools/registry.d.ts +5 -284
- package/dist/tools/registry.js +9 -137
- package/dist/tools/registry.test.js +36 -0
- package/dist/tools/semantic/explores.d.ts +5 -1
- package/dist/tools/semantic/explores.js +8 -1
- package/dist/tools/semantic/metrics.d.ts +3 -1
- package/dist/tools/semantic/metrics.js +6 -1
- package/dist/tools/semantic/query.d.ts +2 -1
- package/dist/tools/semantic/query.js +11 -3
- package/dist/tools/semantic/query.test.d.ts +4 -0
- package/dist/tools/semantic/query.test.js +134 -0
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +2 -2
- package/dist/tools/space/access.d.ts +2 -0
- package/dist/tools/space/access.js +5 -0
- package/dist/tools/types.d.ts +18 -0
- package/dist/tools/types.js +29 -0
- package/dist/tools/types.test.js +50 -0
- package/package.json +6 -6
- package/dist/index.test.js +0 -9
- package/dist/profiles/profile.membership.test.js +0 -36
- package/dist/tools/index.d.ts +0 -4
- package/dist/tools/index.js +0 -8
- package/dist/tools/index.test.js +0 -78
- /package/dist/{index.test.d.ts → cli-help.test.d.ts} +0 -0
- /package/dist/{profiles/profile.membership.test.d.ts → tools/registry.test.d.ts} +0 -0
- /package/dist/tools/{index.test.d.ts → types.test.d.ts} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* compile_query registration and exploreName injection tests.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const server_profile_js_1 = require("../../audit/server-profile.js");
|
|
8
|
+
const query_js_1 = require("./query.js");
|
|
9
|
+
const PROJECT = '550e8400-e29b-41d4-a716-446655440000';
|
|
10
|
+
function createCompileHandler(compileQuery) {
|
|
11
|
+
const contextProvider = {
|
|
12
|
+
getContext: async () => ({
|
|
13
|
+
lightdashClient: { v1: { query: { compileQuery } } },
|
|
14
|
+
auth: { mode: 'none' },
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
const mockServer = { registerTool: vitest_1.vi.fn() };
|
|
18
|
+
(0, server_profile_js_1.bindServerProfile)(mockServer, 'semantic-layer');
|
|
19
|
+
(0, query_js_1.registerCompileQuery)(mockServer, contextProvider);
|
|
20
|
+
const [toolName, , handler] = mockServer.registerTool.mock.calls[0];
|
|
21
|
+
return { toolName, handler, compileQuery };
|
|
22
|
+
}
|
|
23
|
+
(0, vitest_1.describe)('registerCompileQuery', () => {
|
|
24
|
+
(0, vitest_1.beforeEach)(() => {
|
|
25
|
+
vitest_1.vi.restoreAllMocks();
|
|
26
|
+
});
|
|
27
|
+
(0, vitest_1.it)('sets exploreName from exploreId when metricQuery omits it', async () => {
|
|
28
|
+
const compileQuery = vitest_1.vi.fn().mockResolvedValue({
|
|
29
|
+
query: 'SELECT `orders`.status AS `orders_status` FROM orders',
|
|
30
|
+
});
|
|
31
|
+
const { toolName, handler } = createCompileHandler(compileQuery);
|
|
32
|
+
(0, vitest_1.expect)(toolName).toBe('lightdash_compile_query');
|
|
33
|
+
const result = await handler({
|
|
34
|
+
projectUuid: PROJECT,
|
|
35
|
+
exploreId: 'orders',
|
|
36
|
+
metricQuery: {
|
|
37
|
+
dimensions: ['orders_status'],
|
|
38
|
+
metrics: [],
|
|
39
|
+
filters: {},
|
|
40
|
+
sorts: [],
|
|
41
|
+
limit: 50,
|
|
42
|
+
tableCalculations: [],
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
(0, vitest_1.expect)(result.isError).toBeUndefined();
|
|
46
|
+
(0, vitest_1.expect)(compileQuery).toHaveBeenCalledWith(PROJECT, 'orders', vitest_1.expect.objectContaining({
|
|
47
|
+
exploreName: 'orders',
|
|
48
|
+
dimensions: ['orders_status'],
|
|
49
|
+
}));
|
|
50
|
+
});
|
|
51
|
+
(0, vitest_1.it)('overwrites mismatched exploreName with exploreId', async () => {
|
|
52
|
+
const compileQuery = vitest_1.vi.fn().mockResolvedValue({
|
|
53
|
+
query: 'SELECT 1 AS `orders_status`',
|
|
54
|
+
});
|
|
55
|
+
const { handler } = createCompileHandler(compileQuery);
|
|
56
|
+
await handler({
|
|
57
|
+
projectUuid: PROJECT,
|
|
58
|
+
exploreId: 'orders',
|
|
59
|
+
metricQuery: {
|
|
60
|
+
exploreName: 'customers',
|
|
61
|
+
dimensions: ['orders_status'],
|
|
62
|
+
metrics: [],
|
|
63
|
+
filters: {},
|
|
64
|
+
sorts: [],
|
|
65
|
+
limit: 50,
|
|
66
|
+
tableCalculations: [],
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.expect)(compileQuery).toHaveBeenCalledWith(PROJECT, 'orders', vitest_1.expect.objectContaining({ exploreName: 'orders' }));
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.it)('returns isError when compiled SQL has an empty SELECT', async () => {
|
|
72
|
+
const compileQuery = vitest_1.vi.fn().mockResolvedValue({
|
|
73
|
+
query: 'SELECT FROM orders',
|
|
74
|
+
});
|
|
75
|
+
const { handler } = createCompileHandler(compileQuery);
|
|
76
|
+
const result = await handler({
|
|
77
|
+
projectUuid: PROJECT,
|
|
78
|
+
exploreId: 'orders',
|
|
79
|
+
metricQuery: {
|
|
80
|
+
dimensions: ['bad_id'],
|
|
81
|
+
metrics: [],
|
|
82
|
+
filters: {},
|
|
83
|
+
sorts: [],
|
|
84
|
+
limit: 50,
|
|
85
|
+
tableCalculations: [],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
(0, vitest_1.expect)(result.isError).toBe(true);
|
|
89
|
+
(0, vitest_1.expect)(result.content[0].text).toContain('empty SELECT');
|
|
90
|
+
});
|
|
91
|
+
(0, vitest_1.it)('defaults missing tableCalculations to []', async () => {
|
|
92
|
+
const compileQuery = vitest_1.vi.fn().mockResolvedValue({
|
|
93
|
+
query: 'SELECT `orders`.status AS `orders_status` FROM orders',
|
|
94
|
+
});
|
|
95
|
+
const { handler } = createCompileHandler(compileQuery);
|
|
96
|
+
await handler({
|
|
97
|
+
projectUuid: PROJECT,
|
|
98
|
+
exploreId: 'orders',
|
|
99
|
+
metricQuery: {
|
|
100
|
+
dimensions: ['orders_status'],
|
|
101
|
+
metrics: [],
|
|
102
|
+
filters: {},
|
|
103
|
+
sorts: [],
|
|
104
|
+
limit: 50,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
(0, vitest_1.expect)(compileQuery).toHaveBeenCalledWith(PROJECT, 'orders', vitest_1.expect.objectContaining({
|
|
108
|
+
exploreName: 'orders',
|
|
109
|
+
tableCalculations: [],
|
|
110
|
+
}));
|
|
111
|
+
});
|
|
112
|
+
(0, vitest_1.it)('preserves explicit tableCalculations', async () => {
|
|
113
|
+
const tableCalculations = [
|
|
114
|
+
{ name: 'ratio', displayName: 'Ratio', sql: '${orders_sum_order_amount} / 100' },
|
|
115
|
+
];
|
|
116
|
+
const compileQuery = vitest_1.vi.fn().mockResolvedValue({
|
|
117
|
+
query: 'SELECT 1 AS `orders_status`',
|
|
118
|
+
});
|
|
119
|
+
const { handler } = createCompileHandler(compileQuery);
|
|
120
|
+
await handler({
|
|
121
|
+
projectUuid: PROJECT,
|
|
122
|
+
exploreId: 'orders',
|
|
123
|
+
metricQuery: {
|
|
124
|
+
dimensions: ['orders_status'],
|
|
125
|
+
metrics: [],
|
|
126
|
+
filters: {},
|
|
127
|
+
sorts: [],
|
|
128
|
+
limit: 50,
|
|
129
|
+
tableCalculations,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
(0, vitest_1.expect)(compileQuery).toHaveBeenCalledWith(PROJECT, 'orders', vitest_1.expect.objectContaining({ tableCalculations }));
|
|
133
|
+
});
|
|
134
|
+
});
|
package/dist/tools/shared.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* 3. Input validation — rejects invalid resource IDs (control chars, ?, #, %, path traversal).
|
|
8
8
|
* 4. Raw handler — the actual tool implementation.
|
|
9
9
|
*
|
|
10
|
-
* Capability surface is the
|
|
10
|
+
* Capability surface is the profile's tools array, not process safety mode.
|
|
11
11
|
*/
|
|
12
12
|
import type { McpContextProvider } from '../server/request-context.js';
|
|
13
13
|
import type { LightdashClient } from '@lightdash-tools/client';
|
package/dist/tools/shared.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 3. Input validation — rejects invalid resource IDs (control chars, ?, #, %, path traversal).
|
|
9
9
|
* 4. Raw handler — the actual tool implementation.
|
|
10
10
|
*
|
|
11
|
-
* Capability surface is the
|
|
11
|
+
* Capability surface is the profile's tools array, not process safety mode.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.READ_ONLY_DEFAULT = exports.TOOL_PREFIX = void 0;
|
|
@@ -180,7 +180,7 @@ function registerToolSafe(server, shortName, options, handler) {
|
|
|
180
180
|
};
|
|
181
181
|
// ── Audit log wrapper ─────────────────────────────────────────────────────
|
|
182
182
|
// Outermost layer: records timing and outcome for every call.
|
|
183
|
-
// profileId is fixed at registration (bindServerProfile before
|
|
183
|
+
// profileId is fixed at registration (bindServerProfile before registerTools).
|
|
184
184
|
const profileId = typeof server === 'object' && server !== null ? (0, server_profile_js_1.getServerProfile)(server) : undefined;
|
|
185
185
|
const auditedInner = finalHandler;
|
|
186
186
|
finalHandler = async (args, extra) => {
|
|
@@ -64,3 +64,5 @@ export declare function composeEffectiveAccessRecords(input: {
|
|
|
64
64
|
}): EffectiveAccessRecord[];
|
|
65
65
|
export declare function registerListSpaceAccess(server: McpServer, contextProvider: McpContextProvider): void;
|
|
66
66
|
export declare function registerResolveEffectiveAccess(server: McpServer, contextProvider: McpContextProvider): void;
|
|
67
|
+
export declare const listSpaceAccessTool: import("../types.js").ToolModule;
|
|
68
|
+
export declare const resolveEffectiveAccessTool: import("../types.js").ToolModule;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Space access and effective-access composition tools.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveEffectiveAccessTool = exports.listSpaceAccessTool = void 0;
|
|
6
7
|
exports.buildSpaceAccessRows = buildSpaceAccessRows;
|
|
7
8
|
exports.composeEffectiveAccessRecords = composeEffectiveAccessRecords;
|
|
8
9
|
exports.registerListSpaceAccess = registerListSpaceAccess;
|
|
@@ -19,6 +20,7 @@ const register_org_audit_js_1 = require("../lib/register-org-audit.js");
|
|
|
19
20
|
const schema_fields_js_1 = require("../lib/schema-fields.js");
|
|
20
21
|
const binding_js_1 = require("../organization/binding.js");
|
|
21
22
|
const shared_js_1 = require("../shared.js");
|
|
23
|
+
const types_js_1 = require("../types.js");
|
|
22
24
|
const SPACE_FETCH_CONCURRENCY = 5;
|
|
23
25
|
const MAX_SPACES_PER_PROJECT = 100;
|
|
24
26
|
/** Maps space ACL payloads into audit rows; optionally drops inherited-only users. */
|
|
@@ -320,3 +322,6 @@ function registerResolveEffectiveAccess(server, contextProvider) {
|
|
|
320
322
|
}));
|
|
321
323
|
}
|
|
322
324
|
/* eslint-enable max-params, sonarjs/cognitive-complexity, sonarjs/cyclomatic-complexity */
|
|
325
|
+
// ToolModule exports (profile mounts)
|
|
326
|
+
exports.listSpaceAccessTool = (0, types_js_1.defineTool)('list_space_access', registerListSpaceAccess);
|
|
327
|
+
exports.resolveEffectiveAccessTool = (0, types_js_1.defineTool)('resolve_effective_access', registerResolveEffectiveAccess);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal self-describing MCP tool module (profile mounts import these).
|
|
3
|
+
*/
|
|
4
|
+
import type { McpContextProvider } from '../server/request-context.js';
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
|
+
export type ToolModule = {
|
|
7
|
+
/** Short id (sans `lightdash_` prefix); wire name = `lightdash_` + id */
|
|
8
|
+
id: string;
|
|
9
|
+
register: (server: McpServer, contextProvider: McpContextProvider) => void;
|
|
10
|
+
};
|
|
11
|
+
/** Build a ToolModule; throws if the same id is defined twice in this process. */
|
|
12
|
+
export declare function defineTool(id: string, register: ToolModule['register']): ToolModule;
|
|
13
|
+
/**
|
|
14
|
+
* Same wire id, different register implementations for different profile mounts.
|
|
15
|
+
* Use when profiles need distinct registration (e.g. capability envelopes) but one tools/list name.
|
|
16
|
+
* Do not mix with {@link defineTool} for the same id.
|
|
17
|
+
*/
|
|
18
|
+
export declare function defineToolVariant(id: string, register: ToolModule['register']): ToolModule;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal self-describing MCP tool module (profile mounts import these).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defineTool = defineTool;
|
|
7
|
+
exports.defineToolVariant = defineToolVariant;
|
|
8
|
+
const registeredIds = new Set();
|
|
9
|
+
const variantIds = new Set();
|
|
10
|
+
/** Build a ToolModule; throws if the same id is defined twice in this process. */
|
|
11
|
+
function defineTool(id, register) {
|
|
12
|
+
if (registeredIds.has(id) || variantIds.has(id)) {
|
|
13
|
+
throw new Error(`Duplicate MCP tool id '${id}'`);
|
|
14
|
+
}
|
|
15
|
+
registeredIds.add(id);
|
|
16
|
+
return { id, register };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Same wire id, different register implementations for different profile mounts.
|
|
20
|
+
* Use when profiles need distinct registration (e.g. capability envelopes) but one tools/list name.
|
|
21
|
+
* Do not mix with {@link defineTool} for the same id.
|
|
22
|
+
*/
|
|
23
|
+
function defineToolVariant(id, register) {
|
|
24
|
+
if (registeredIds.has(id)) {
|
|
25
|
+
throw new Error(`Cannot variant MCP tool id '${id}' after defineTool`);
|
|
26
|
+
}
|
|
27
|
+
variantIds.add(id);
|
|
28
|
+
return { id, register };
|
|
29
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const vitest_1 = require("vitest");
|
|
37
|
+
const types_js_1 = require("./types.js");
|
|
38
|
+
(0, vitest_1.describe)('defineTool', () => {
|
|
39
|
+
(0, vitest_1.it)('throws when registering a duplicate tool id', async () => {
|
|
40
|
+
// Load one real ToolModule so `list_projects` is already defined.
|
|
41
|
+
await Promise.resolve().then(() => __importStar(require('./project/projects.js')));
|
|
42
|
+
(0, vitest_1.expect)(() => (0, types_js_1.defineTool)('list_projects', () => undefined)).toThrow(/Duplicate MCP tool id 'list_projects'/);
|
|
43
|
+
});
|
|
44
|
+
(0, vitest_1.it)('allows intentional same-id variants after defineToolVariant', async () => {
|
|
45
|
+
await Promise.resolve().then(() => __importStar(require('./project/projects.js')));
|
|
46
|
+
(0, vitest_1.expect)(() => (0, types_js_1.defineTool)('get_project', () => undefined)).toThrow(/Duplicate MCP tool id 'get_project'/);
|
|
47
|
+
// Additional variants of an already-variant id are allowed.
|
|
48
|
+
(0, vitest_1.expect)(() => (0, types_js_1.defineToolVariant)('get_project', () => undefined)).not.toThrow();
|
|
49
|
+
});
|
|
50
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash-tools/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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": {
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"@modelcontextprotocol/node": "2.0.0",
|
|
23
23
|
"@modelcontextprotocol/server": "2.0.0",
|
|
24
24
|
"commander": "^15.0.0",
|
|
25
|
-
"hono": "^4.
|
|
25
|
+
"hono": "^4.13.0",
|
|
26
26
|
"zod": "^4.4.3",
|
|
27
|
-
"@lightdash-tools/client": "0.
|
|
28
|
-
"@lightdash-tools/common": "0.
|
|
27
|
+
"@lightdash-tools/client": "0.13.0",
|
|
28
|
+
"@lightdash-tools/common": "0.13.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@modelcontextprotocol/client": "2.0.0",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "rm -rf dist && tsc && for p in semantic-layer organization-audit content-reader content-developer content-governance ai-agent-ops data-analyst; do mkdir -p dist/profiles/$p/v1/resources/playbooks && cp -R src/profiles/$p/v1/resources/playbooks/. dist/profiles/$p/v1/resources/playbooks/; done",
|
|
39
|
-
"start": "node dist/
|
|
40
|
-
"start:
|
|
39
|
+
"start:http": "node dist/bin.js http",
|
|
40
|
+
"start:stdio": "node dist/bin.js stdio --profile semantic-layer",
|
|
41
41
|
"test": "pnpm --dir ../.. exec vitest run packages/mcp/src"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/dist/index.test.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
const tools_1 = require("./tools");
|
|
5
|
-
(0, vitest_1.describe)('tools barrel', () => {
|
|
6
|
-
(0, vitest_1.it)('exports registerToolsByIds', () => {
|
|
7
|
-
(0, vitest_1.expect)(typeof tools_1.registerToolsByIds).toBe('function');
|
|
8
|
-
});
|
|
9
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
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("./index.js");
|
|
6
|
-
(0, vitest_1.describe)('profile catalog membership', () => {
|
|
7
|
-
(0, vitest_1.it)('ships exactly the catalog PROFILE_IDS', () => {
|
|
8
|
-
(0, vitest_1.expect)(Object.keys(index_js_1.PROFILES).sort()).toEqual([...common_1.PROFILE_IDS].sort());
|
|
9
|
-
});
|
|
10
|
-
(0, vitest_1.it)('every shipped profile exposes at least one MCP tool from the catalog', () => {
|
|
11
|
-
for (const id of common_1.PROFILE_IDS) {
|
|
12
|
-
(0, vitest_1.expect)((0, common_1.listMcpToolNamesByProfile)(id).length).toBeGreaterThan(0);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
(0, vitest_1.it)('every exposed MCP tool is tagged with at least one serving profile', () => {
|
|
16
|
-
var _a;
|
|
17
|
-
const exposed = new Set((0, common_1.listExposedMcpToolNames)());
|
|
18
|
-
for (const operation of (0, common_1.listOperations)()) {
|
|
19
|
-
if (((_a = operation.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed) !== true) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
(0, vitest_1.expect)(operation.profiles.length).toBeGreaterThan(0);
|
|
23
|
-
(0, vitest_1.expect)(exposed.has(operation.mcp.toolName)).toBe(true);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
(0, vitest_1.it)('listMcpToolNamesByProfile matches only exposed tools for each profile', () => {
|
|
27
|
-
var _a;
|
|
28
|
-
for (const id of common_1.PROFILE_IDS) {
|
|
29
|
-
for (const toolName of (0, common_1.listMcpToolNamesByProfile)(id)) {
|
|
30
|
-
const op = (0, common_1.listOperations)().find((o) => { var _a; return ((_a = o.mcp) === null || _a === void 0 ? void 0 : _a.toolName) === toolName; });
|
|
31
|
-
(0, vitest_1.expect)((_a = op === null || op === void 0 ? void 0 : op.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed).toBe(true);
|
|
32
|
-
(0, vitest_1.expect)(op === null || op === void 0 ? void 0 : op.profiles).toContain(id);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
package/dist/tools/index.d.ts
DELETED
package/dist/tools/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Tool registration: shared registry only (profiles select via registerToolsByIds).
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.registerToolsByIds = void 0;
|
|
7
|
-
var registry_js_1 = require("./registry.js");
|
|
8
|
-
Object.defineProperty(exports, "registerToolsByIds", { enumerable: true, get: function () { return registry_js_1.registerToolsByIds; } });
|
package/dist/tools/index.test.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const common_1 = require("@lightdash-tools/common");
|
|
37
|
-
const vitest_1 = require("vitest");
|
|
38
|
-
const server_profile_js_1 = require("../audit/server-profile.js");
|
|
39
|
-
const index_js_1 = require("../profiles/index.js");
|
|
40
|
-
const registry_js_1 = require("./registry.js");
|
|
41
|
-
const shared_js_1 = require("./shared.js");
|
|
42
|
-
vitest_1.vi.mock('@lightdash-tools/common', async (importOriginal) => {
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
const actual = await importOriginal();
|
|
45
|
-
return Object.assign(Object.assign({}, actual), { getSessionId: () => 'test-session', logAuditEntry: vitest_1.vi.fn(), initAuditLog: vitest_1.vi.fn() });
|
|
46
|
-
});
|
|
47
|
-
(0, vitest_1.describe)('registerToolsByIds', () => {
|
|
48
|
-
const registeredTools = [];
|
|
49
|
-
const mockServer = {
|
|
50
|
-
registerTool: vitest_1.vi.fn((name, options) => {
|
|
51
|
-
registeredTools.push({ name, description: options.description });
|
|
52
|
-
}),
|
|
53
|
-
registerResource: vitest_1.vi.fn(),
|
|
54
|
-
};
|
|
55
|
-
(0, vitest_1.beforeEach)(() => {
|
|
56
|
-
registeredTools.length = 0;
|
|
57
|
-
mockServer.registerTool.mockClear();
|
|
58
|
-
});
|
|
59
|
-
(0, vitest_1.it)('registers only the profile catalog tools with lightdash_ prefix', () => {
|
|
60
|
-
const mockContextProvider = { getContext: async () => ({ lightdashClient: {} }) };
|
|
61
|
-
const profile = (0, index_js_1.getDefaultProfile)();
|
|
62
|
-
const toolIds = (0, common_1.listMcpToolNamesByProfile)(profile.id);
|
|
63
|
-
(0, server_profile_js_1.bindServerProfile)(mockServer, profile.id);
|
|
64
|
-
(0, registry_js_1.registerToolsByIds)(mockServer, mockContextProvider, toolIds);
|
|
65
|
-
(0, vitest_1.expect)(registeredTools).toHaveLength(toolIds.length);
|
|
66
|
-
(0, vitest_1.expect)(registeredTools.every((t) => t.name.startsWith(shared_js_1.TOOL_PREFIX))).toBe(true);
|
|
67
|
-
const names = registeredTools.map((t) => t.name);
|
|
68
|
-
(0, vitest_1.expect)(names).toEqual(toolIds.map((id) => `${shared_js_1.TOOL_PREFIX}${id}`));
|
|
69
|
-
});
|
|
70
|
-
(0, vitest_1.it)('covers every registry tool id via some profile membership', async () => {
|
|
71
|
-
const { PROFILES } = await Promise.resolve().then(() => __importStar(require('../profiles/index.js')));
|
|
72
|
-
const { toolRegistry } = await Promise.resolve().then(() => __importStar(require('./registry.js')));
|
|
73
|
-
const covered = new Set(Object.keys(PROFILES).flatMap((id) => (0, common_1.listMcpToolNamesByProfile)(id)));
|
|
74
|
-
for (const id of Object.keys(toolRegistry)) {
|
|
75
|
-
(0, vitest_1.expect)(covered.has(id), `uncovered tool ${id}`).toBe(true);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|