@lightdash-tools/mcp 0.9.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -22
- package/dist/audit/server-profile.d.ts +13 -0
- package/dist/audit/server-profile.js +28 -0
- package/dist/audit/server-profile.test.js +21 -0
- package/dist/auth/oauth-broker/pending-store.test.d.ts +1 -1
- package/dist/auth/oauth-broker/pending-store.test.js +1 -1
- package/dist/auth/request-state-key.d.ts +2 -2
- package/dist/auth/request-state-key.js +2 -2
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +1 -1
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +1 -1
- package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +14 -14
- package/dist/auth/resource-server/oauth-protected-resource.d.ts +6 -6
- package/dist/auth/resource-server/oauth-protected-resource.js +8 -8
- package/dist/auth/resource-server/token-scopes.d.ts +1 -1
- package/dist/auth/resource-server/token-scopes.js +1 -1
- package/dist/auth/resource-server/www-authenticate.test.js +11 -11
- package/dist/bin.js +54 -58
- package/dist/config/env.d.ts +3 -1
- package/dist/config/env.js +4 -2
- package/dist/config/load-mcp-config.js +8 -36
- package/dist/config/load-mcp-config.test.js +8 -2
- package/dist/config/normalize-url.d.ts +1 -1
- package/dist/config/normalize-url.js +1 -1
- package/dist/config/normalize-url.test.js +16 -16
- package/dist/config/obsolete-env.d.ts +5 -0
- package/dist/config/obsolete-env.js +48 -0
- package/dist/config/obsolete-env.test.js +22 -0
- package/dist/config/runtime.js +1 -1
- package/dist/governance/available-projects.d.ts +1 -1
- package/dist/governance/available-projects.js +1 -1
- package/dist/governance/mcp-post-factory-context.d.ts +15 -0
- package/dist/governance/mcp-post-factory-context.js +22 -0
- package/dist/governance/mcp-post-factory-context.test.js +34 -0
- package/dist/http.integration.test.js +11 -15
- package/dist/index.d.ts +5 -1
- package/dist/index.js +29 -16
- package/dist/policy/content-reader.d.ts +10 -5
- package/dist/policy/content-reader.js +23 -9
- package/dist/policy/content-reader.test.js +4 -3
- package/dist/policy/envelope.d.ts +4 -2
- package/dist/policy/envelope.js +2 -2
- package/dist/policy/envelope.test.d.ts +1 -0
- package/dist/policy/envelope.test.js +28 -0
- package/dist/profiles/ai-agent-ops/v1/index.d.ts +6 -0
- package/dist/profiles/ai-agent-ops/v1/index.js +20 -0
- package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.js +2 -2
- package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/core.md +1 -1
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +1 -1
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/release-gate.md +1 -1
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks.js +4 -4
- package/dist/profiles/content-developer/v1/index.d.ts +8 -0
- package/dist/profiles/content-developer/v1/index.js +22 -0
- package/dist/{personas → profiles}/content-developer/v1/prompts.js +6 -6
- package/dist/{personas → profiles}/content-developer/v1/prompts.test.js +61 -6
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/chart-types.md +31 -16
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/core.md +9 -5
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/dashboard-design.md +3 -3
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/dashboards.md +12 -7
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks.js +4 -2
- package/dist/profiles/content-governance/v1/index.d.ts +7 -0
- package/dist/profiles/content-governance/v1/index.js +21 -0
- package/dist/{personas → profiles}/content-governance/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/core.md +2 -2
- package/dist/{personas → profiles}/content-governance/v1/resources/playbooks.js +4 -4
- package/dist/profiles/content-reader/v1/index.d.ts +6 -0
- package/dist/profiles/content-reader/v1/index.js +20 -0
- package/dist/{personas → profiles}/content-reader/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/core.md +1 -1
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/discover.md +1 -1
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.js +2 -2
- package/dist/profiles/data-analyst/v1/index.d.ts +6 -0
- package/dist/profiles/data-analyst/v1/index.js +20 -0
- package/dist/profiles/data-analyst/v1/prompts.d.ts +5 -0
- package/dist/profiles/data-analyst/v1/prompts.js +41 -0
- package/dist/profiles/data-analyst/v1/prompts.test.d.ts +4 -0
- package/dist/profiles/data-analyst/v1/prompts.test.js +26 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks/core.md +41 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks/explore.md +26 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks/index.md +8 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks.d.ts +10 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks.js +33 -0
- package/dist/profiles/index.d.ts +24 -0
- package/dist/profiles/index.js +73 -0
- package/dist/profiles/index.test.d.ts +1 -0
- package/dist/profiles/index.test.js +121 -0
- package/dist/{personas → profiles}/lib/playbook-resources.d.ts +8 -7
- package/dist/{personas → profiles}/lib/playbook-resources.js +15 -15
- package/dist/profiles/organization-audit/v1/index.d.ts +6 -0
- package/dist/profiles/organization-audit/v1/index.js +20 -0
- package/dist/{personas → profiles}/organization-audit/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.js +2 -2
- package/dist/profiles/profile.membership.test.d.ts +1 -0
- package/dist/profiles/profile.membership.test.js +36 -0
- package/dist/profiles/semantic-layer/v1/index.d.ts +6 -0
- package/dist/profiles/semantic-layer/v1/index.js +19 -0
- package/dist/{personas → profiles}/semantic-layer/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.js +2 -2
- package/dist/profiles/types.d.ts +18 -0
- package/dist/{personas → profiles}/types.js +1 -1
- package/dist/protocol-contract.test.js +48 -3
- package/dist/server/capabilities.d.ts +6 -6
- package/dist/server/capabilities.js +11 -10
- package/dist/server/capabilities.test.js +8 -9
- package/dist/server/server.js +7 -7
- package/dist/stdio.process.test.js +61 -7
- package/dist/tools/ai-agents/agents.d.ts +1 -1
- package/dist/tools/ai-agents/agents.js +1 -1
- package/dist/tools/ai-agents/evaluations.d.ts +1 -1
- package/dist/tools/ai-agents/evaluations.js +1 -1
- package/dist/tools/ai-agents/helpers.d.ts +2 -3
- package/dist/tools/ai-agents/helpers.js +2 -4
- package/dist/tools/ai-agents/threads.d.ts +1 -1
- package/dist/tools/ai-agents/threads.js +1 -1
- package/dist/tools/composition/explain-content.js +3 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.test.js +16 -10
- package/dist/tools/lib/schema-fields.d.ts +2 -0
- package/dist/tools/lib/schema-fields.js +4 -1
- package/dist/tools/lib/stable-stringify.d.ts +1 -1
- package/dist/tools/lib/stable-stringify.js +1 -1
- package/dist/tools/organization/invariants.test.d.ts +1 -1
- package/dist/tools/organization/invariants.test.js +5 -5
- package/dist/tools/project/developer-content-preview.d.ts +1 -1
- package/dist/tools/project/developer-content-preview.js +1 -1
- package/dist/tools/project/developer-content-shared.d.ts +1 -1
- package/dist/tools/project/developer-content-shared.js +1 -1
- package/dist/tools/project/developer-get-chart-as-code.test.js +1 -1
- package/dist/tools/project/invariants.test.d.ts +1 -1
- package/dist/tools/project/invariants.test.js +8 -8
- package/dist/tools/project/parameters.js +8 -3
- package/dist/tools/project/projects.d.ts +1 -4
- package/dist/tools/project/projects.js +32 -12
- package/dist/tools/project/projects.test.js +30 -7
- package/dist/tools/project/reader-content.js +6 -3
- package/dist/tools/project/reader-execution.js +4 -2
- package/dist/tools/project/reader-export-chart-image.js +1 -1
- package/dist/tools/project/reader-export-chart-image.test.js +2 -2
- package/dist/tools/project/spaces.js +12 -4
- package/dist/tools/project/spaces.test.d.ts +1 -0
- package/dist/tools/project/spaces.test.js +47 -0
- package/dist/tools/query/bounded-saved-query.d.ts +4 -3
- package/dist/tools/query/bounded-saved-query.js +3 -5
- package/dist/tools/query/lifecycle.js +10 -8
- package/dist/tools/query/query-ledger.d.ts +2 -1
- package/dist/tools/query/reader-tool-helpers.d.ts +4 -2
- package/dist/tools/query/reader-tool-helpers.js +7 -2
- package/dist/tools/query/run-metric-query.d.ts +6 -0
- package/dist/tools/query/run-metric-query.js +94 -0
- package/dist/tools/query/run-metric-query.test.d.ts +4 -0
- package/dist/tools/query/run-metric-query.test.js +116 -0
- package/dist/tools/registry.d.ts +8 -8
- package/dist/tools/registry.js +10 -6
- package/dist/tools/semantic/explores.js +43 -17
- package/dist/tools/semantic/metrics.js +22 -8
- package/dist/tools/semantic/query.js +25 -17
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +5 -5
- package/dist/tools/shared.test.js +4 -4
- package/dist/transports/streamable-http.js +46 -36
- package/dist/transports/streamable-http.test.js +9 -9
- package/package.json +6 -6
- package/dist/audit/server-persona.d.ts +0 -10
- package/dist/audit/server-persona.js +0 -19
- package/dist/governance/client-capabilities-cache.d.ts +0 -44
- package/dist/governance/client-capabilities-cache.js +0 -142
- package/dist/governance/client-capabilities-cache.test.js +0 -148
- package/dist/personas/ai-agent-ops/v1/index.d.ts +0 -8
- package/dist/personas/ai-agent-ops/v1/index.js +0 -41
- package/dist/personas/content-developer/v1/index.d.ts +0 -10
- package/dist/personas/content-developer/v1/index.js +0 -52
- package/dist/personas/content-governance/v1/index.d.ts +0 -9
- package/dist/personas/content-governance/v1/index.js +0 -29
- package/dist/personas/content-reader/v1/index.d.ts +0 -8
- package/dist/personas/content-reader/v1/index.js +0 -38
- package/dist/personas/index.d.ts +0 -23
- package/dist/personas/index.js +0 -78
- package/dist/personas/index.test.js +0 -124
- package/dist/personas/organization-audit/v1/index.d.ts +0 -8
- package/dist/personas/organization-audit/v1/index.js +0 -42
- package/dist/personas/persona.parity.test.js +0 -30
- package/dist/personas/semantic-layer/v1/index.d.ts +0 -8
- package/dist/personas/semantic-layer/v1/index.js +0 -32
- package/dist/personas/types.d.ts +0 -19
- /package/dist/{governance/client-capabilities-cache.test.d.ts → audit/server-profile.test.d.ts} +0 -0
- /package/dist/{personas/index.test.d.ts → config/obsolete-env.test.d.ts} +0 -0
- /package/dist/{personas/persona.parity.test.d.ts → governance/mcp-post-factory-context.test.d.ts} +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/evaluation.md +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/content-move.md +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/charts.md +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/dashboards.md +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/compare.md +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/explain-run.md +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/access.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/content.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/core.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/deliveries.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/compose-compile.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/core.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/explore.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.d.ts +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile packaging types (tools from the operation catalog, ADR-0006).
|
|
3
|
+
*/
|
|
4
|
+
import type { ProfileId } from '@lightdash-tools/common';
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
6
|
+
export type { ProfileId };
|
|
7
|
+
export type ProfileDefinition = {
|
|
8
|
+
id: ProfileId;
|
|
9
|
+
/** Fixed Streamable HTTP MCP endpoint path for this profile. */
|
|
10
|
+
path: `/${string}`;
|
|
11
|
+
/**
|
|
12
|
+
* MCP server display name. Defaults to `lightdash-mcp-${id}`.
|
|
13
|
+
* Use a shorter name when combined with `lightdash_*` tools would exceed ~60 chars.
|
|
14
|
+
*/
|
|
15
|
+
serverName?: string;
|
|
16
|
+
registerPrompts: (server: McpServer) => void;
|
|
17
|
+
registerResources: (server: McpServer) => void;
|
|
18
|
+
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Protocol contract: legacy (InMemoryTransport / initialize) and modern
|
|
5
|
+
* (createMcpHandler + StreamableHTTPClientTransport with versionNegotiation).
|
|
5
6
|
* No Lightdash network calls — stub McpContextProvider only.
|
|
6
7
|
*/
|
|
8
|
+
const common_1 = require("@lightdash-tools/common");
|
|
7
9
|
const client_1 = require("@modelcontextprotocol/client");
|
|
8
10
|
const server_1 = require("@modelcontextprotocol/server");
|
|
9
11
|
const vitest_1 = require("vitest");
|
|
10
12
|
const server_js_1 = require("./server/server.js");
|
|
11
13
|
const shared_js_1 = require("./tools/shared.js");
|
|
14
|
+
const EXPECTED_TOOL_COUNT = (0, common_1.listMcpToolNamesByProfile)('semantic-layer').length;
|
|
12
15
|
function createStubContextProvider() {
|
|
13
16
|
return {
|
|
14
17
|
getContext: async () => ({
|
|
@@ -17,7 +20,13 @@ function createStubContextProvider() {
|
|
|
17
20
|
}),
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
async function connectViaHandlerFetch(handler, client) {
|
|
24
|
+
const transport = new client_1.StreamableHTTPClientTransport(new URL('http://test.local/mcp'), {
|
|
25
|
+
fetch: (url, init) => handler.fetch(new Request(url, init)),
|
|
26
|
+
});
|
|
27
|
+
await client.connect(transport);
|
|
28
|
+
}
|
|
29
|
+
(0, vitest_1.describe)('MCP protocol contract (legacy InMemoryTransport)', () => {
|
|
21
30
|
let server;
|
|
22
31
|
let mcpClient;
|
|
23
32
|
(0, vitest_1.afterEach)(async () => {
|
|
@@ -34,9 +43,45 @@ function createStubContextProvider() {
|
|
|
34
43
|
mcpClient = new client_1.Client({ name: 'protocol-contract-test', version: '0.0.0' });
|
|
35
44
|
await mcpClient.connect(clientTransport);
|
|
36
45
|
const { tools } = await mcpClient.listTools();
|
|
37
|
-
(0, vitest_1.expect)(tools).toHaveLength(
|
|
46
|
+
(0, vitest_1.expect)(tools).toHaveLength(EXPECTED_TOOL_COUNT);
|
|
38
47
|
(0, vitest_1.expect)(tools.every((t) => t.name.startsWith(shared_js_1.TOOL_PREFIX))).toBe(true);
|
|
39
48
|
(0, vitest_1.expect)(tools.some((t) => t.name === `${shared_js_1.TOOL_PREFIX}list_projects`)).toBe(true);
|
|
40
49
|
(0, vitest_1.expect)(tools.some((t) => t.name === `${shared_js_1.TOOL_PREFIX}compile_query`)).toBe(true);
|
|
41
50
|
});
|
|
42
51
|
});
|
|
52
|
+
(0, vitest_1.describe)('MCP protocol contract (modern createMcpHandler)', () => {
|
|
53
|
+
let handler;
|
|
54
|
+
let mcpClient;
|
|
55
|
+
(0, vitest_1.afterEach)(async () => {
|
|
56
|
+
await (mcpClient === null || mcpClient === void 0 ? void 0 : mcpClient.close().catch(() => undefined));
|
|
57
|
+
await (handler === null || handler === void 0 ? void 0 : handler.close().catch(() => undefined));
|
|
58
|
+
mcpClient = undefined;
|
|
59
|
+
handler = undefined;
|
|
60
|
+
});
|
|
61
|
+
(0, vitest_1.it)('discovers 2026-07-28 then tools/list via handler.fetch', async () => {
|
|
62
|
+
const contextProvider = createStubContextProvider();
|
|
63
|
+
handler = (0, server_1.createMcpHandler)(() => (0, server_js_1.createLightdashMcpServer)(contextProvider), {
|
|
64
|
+
legacy: 'stateless',
|
|
65
|
+
});
|
|
66
|
+
mcpClient = new client_1.Client({ name: 'protocol-contract-modern', version: '0.0.0' }, { versionNegotiation: { mode: { pin: '2026-07-28' } } });
|
|
67
|
+
await connectViaHandlerFetch(handler, mcpClient);
|
|
68
|
+
(0, vitest_1.expect)(mcpClient.getProtocolEra()).toBe('modern');
|
|
69
|
+
const { tools } = await mcpClient.listTools();
|
|
70
|
+
(0, vitest_1.expect)(tools).toHaveLength(EXPECTED_TOOL_COUNT);
|
|
71
|
+
(0, vitest_1.expect)(tools.every((t) => t.name.startsWith(shared_js_1.TOOL_PREFIX))).toBe(true);
|
|
72
|
+
(0, vitest_1.expect)(tools.some((t) => t.name === `${shared_js_1.TOOL_PREFIX}list_projects`)).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
(0, vitest_1.it)('legacy:stateless still serves initialize clients on the same factory', async () => {
|
|
75
|
+
const contextProvider = createStubContextProvider();
|
|
76
|
+
handler = (0, server_1.createMcpHandler)(() => (0, server_js_1.createLightdashMcpServer)(contextProvider), {
|
|
77
|
+
legacy: 'stateless',
|
|
78
|
+
});
|
|
79
|
+
// Default Client connects legacy (initialize handshake).
|
|
80
|
+
mcpClient = new client_1.Client({ name: 'protocol-contract-legacy-http', version: '0.0.0' });
|
|
81
|
+
await connectViaHandlerFetch(handler, mcpClient);
|
|
82
|
+
(0, vitest_1.expect)(mcpClient.getProtocolEra()).toBe('legacy');
|
|
83
|
+
const { tools } = await mcpClient.listTools();
|
|
84
|
+
(0, vitest_1.expect)(tools).toHaveLength(EXPECTED_TOOL_COUNT);
|
|
85
|
+
(0, vitest_1.expect)(tools.some((t) => t.name === `${shared_js_1.TOOL_PREFIX}list_projects`)).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Register tools / prompts / resources for a
|
|
2
|
+
* Register tools / prompts / resources for a profile.
|
|
3
3
|
*/
|
|
4
4
|
import type { McpContextProvider } from './request-context.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ProfileDefinition } from '../profiles/types.js';
|
|
6
6
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
7
7
|
export type RegisterCapabilitiesOptions = {
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/** Profile to register (defaults to {@link getDefaultProfile}). */
|
|
9
|
+
profile?: ProfileDefinition;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* Registers MCP capabilities for the given
|
|
13
|
-
* Tools come from the
|
|
12
|
+
* Registers MCP capabilities for the given profile.
|
|
13
|
+
* Tools come from the operation catalog via listMcpToolNamesByProfile (ADR-0006).
|
|
14
14
|
*/
|
|
15
15
|
export declare function registerCapabilities(server: McpServer, contextProvider: McpContextProvider, options?: RegisterCapabilitiesOptions): void;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Register tools / prompts / resources for a
|
|
3
|
+
* Register tools / prompts / resources for a profile.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerCapabilities = registerCapabilities;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const common_1 = require("@lightdash-tools/common");
|
|
8
|
+
const server_profile_js_1 = require("../audit/server-profile.js");
|
|
9
|
+
const index_js_1 = require("../profiles/index.js");
|
|
9
10
|
const registry_js_1 = require("../tools/registry.js");
|
|
10
11
|
/**
|
|
11
|
-
* Registers MCP capabilities for the given
|
|
12
|
-
* Tools come from the
|
|
12
|
+
* Registers MCP capabilities for the given profile.
|
|
13
|
+
* Tools come from the operation catalog via listMcpToolNamesByProfile (ADR-0006).
|
|
13
14
|
*/
|
|
14
15
|
function registerCapabilities(server, contextProvider, options) {
|
|
15
16
|
var _a;
|
|
16
|
-
const
|
|
17
|
-
(0,
|
|
18
|
-
(0, registry_js_1.registerToolsByIds)(server, contextProvider,
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const profile = (_a = options === null || options === void 0 ? void 0 : options.profile) !== null && _a !== void 0 ? _a : (0, index_js_1.getDefaultProfile)();
|
|
18
|
+
(0, server_profile_js_1.bindServerProfile)(server, profile.id);
|
|
19
|
+
(0, registry_js_1.registerToolsByIds)(server, contextProvider, (0, common_1.listMcpToolNamesByProfile)(profile.id));
|
|
20
|
+
profile.registerPrompts(server);
|
|
21
|
+
profile.registerResources(server);
|
|
21
22
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_1 = require("@lightdash-tools/common");
|
|
3
4
|
const server_1 = require("@modelcontextprotocol/server");
|
|
4
5
|
const vitest_1 = require("vitest");
|
|
5
|
-
const
|
|
6
|
-
const index_js_1 = require("../
|
|
6
|
+
const server_profile_js_1 = require("../audit/server-profile.js");
|
|
7
|
+
const index_js_1 = require("../profiles/index.js");
|
|
7
8
|
const registry_js_1 = require("../tools/registry.js");
|
|
8
9
|
const capabilities_js_1 = require("./capabilities.js");
|
|
9
10
|
vitest_1.vi.mock('../tools/registry.js', async (importOriginal) => {
|
|
@@ -30,13 +31,11 @@ function createMockContextProvider(lightdashClient = {}) {
|
|
|
30
31
|
registerResourceSpy = vitest_1.vi.spyOn(server, 'registerResource');
|
|
31
32
|
vitest_1.vi.mocked(registry_js_1.registerToolsByIds).mockClear();
|
|
32
33
|
});
|
|
33
|
-
(0, vitest_1.it)('registers
|
|
34
|
-
const
|
|
35
|
-
(0, capabilities_js_1.registerCapabilities)(server, mockContextProvider, {
|
|
36
|
-
(0, vitest_1.expect)((0,
|
|
37
|
-
(0, vitest_1.expect)(registry_js_1.registerToolsByIds).toHaveBeenCalledWith(server, mockContextProvider,
|
|
38
|
-
personaId: persona.id,
|
|
39
|
-
});
|
|
34
|
+
(0, vitest_1.it)('registers catalog tools and prompts/resources for the profile', () => {
|
|
35
|
+
const profile = (0, index_js_1.getDefaultProfile)();
|
|
36
|
+
(0, capabilities_js_1.registerCapabilities)(server, mockContextProvider, { profile });
|
|
37
|
+
(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));
|
|
40
39
|
(0, vitest_1.expect)(registerPromptSpy).toHaveBeenCalled();
|
|
41
40
|
(0, vitest_1.expect)(registerResourceSpy).toHaveBeenCalled();
|
|
42
41
|
});
|
package/dist/server/server.js
CHANGED
|
@@ -4,19 +4,19 @@ exports.createLightdashMcpServer = createLightdashMcpServer;
|
|
|
4
4
|
const server_1 = require("@modelcontextprotocol/server");
|
|
5
5
|
const request_state_key_js_1 = require("../auth/request-state-key.js");
|
|
6
6
|
const request_state_js_1 = require("../destructive/request-state.js");
|
|
7
|
-
const index_js_1 = require("../
|
|
7
|
+
const index_js_1 = require("../profiles/index.js");
|
|
8
8
|
const capabilities_js_1 = require("./capabilities.js");
|
|
9
9
|
const version_js_1 = require("./version.js");
|
|
10
10
|
function createLightdashMcpServer(contextProvider, options) {
|
|
11
11
|
var _a;
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
12
|
+
const profile = (_a = options === null || options === void 0 ? void 0 : options.profile) !== null && _a !== void 0 ? _a : (0, index_js_1.getDefaultProfile)();
|
|
13
|
+
if (profile.id === 'content-governance') {
|
|
14
14
|
(0, request_state_key_js_1.assertRequestStateKeyConfigured)(request_state_key_js_1.DESTRUCTIVE_REQUEST_STATE_KEY_PURPOSE);
|
|
15
15
|
}
|
|
16
|
-
else if (
|
|
16
|
+
else if (profile.id === 'content-developer') {
|
|
17
17
|
(0, request_state_key_js_1.assertRequestStateKeyConfigured)(request_state_key_js_1.PREVIEW_TOKEN_KEY_PURPOSE);
|
|
18
18
|
}
|
|
19
|
-
const serverOptions =
|
|
19
|
+
const serverOptions = profile.id === 'content-governance'
|
|
20
20
|
? {
|
|
21
21
|
requestState: {
|
|
22
22
|
verify: (state, ctx) => (0, request_state_js_1.getDestructiveRequestStateCodec)().verify(state, ctx),
|
|
@@ -24,9 +24,9 @@ function createLightdashMcpServer(contextProvider, options) {
|
|
|
24
24
|
}
|
|
25
25
|
: undefined;
|
|
26
26
|
const server = new server_1.McpServer({
|
|
27
|
-
name: (0, index_js_1.
|
|
27
|
+
name: (0, index_js_1.getProfileServerName)(profile),
|
|
28
28
|
version: version_js_1.PACKAGE_VERSION,
|
|
29
29
|
}, serverOptions);
|
|
30
|
-
(0, capabilities_js_1.registerCapabilities)(server, contextProvider, Object.assign(Object.assign({}, options), {
|
|
30
|
+
(0, capabilities_js_1.registerCapabilities)(server, contextProvider, Object.assign(Object.assign({}, options), { profile }));
|
|
31
31
|
return server;
|
|
32
32
|
}
|
|
@@ -9,11 +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
|
+
const server_1 = require("@modelcontextprotocol/server");
|
|
12
14
|
const vitest_1 = require("vitest");
|
|
15
|
+
const shared_js_1 = require("./tools/shared.js");
|
|
13
16
|
/** Vitest runs from the monorepo root (`vitest.config.ts`). */
|
|
14
17
|
const repoRoot = process.cwd();
|
|
15
18
|
const binPath = node_path_1.default.join(repoRoot, 'packages/mcp/dist/bin.js');
|
|
16
19
|
const INIT_TIMEOUT_MS = 5000;
|
|
20
|
+
const SEMANTIC_LAYER_TOOL_COUNT = (0, common_1.listMcpToolNamesByProfile)('semantic-layer').length;
|
|
17
21
|
function writeLine(child, message) {
|
|
18
22
|
child.stdin.write(`${JSON.stringify(message)}\n`);
|
|
19
23
|
}
|
|
@@ -73,12 +77,62 @@ function killChild(child) {
|
|
|
73
77
|
killChild(child);
|
|
74
78
|
child = undefined;
|
|
75
79
|
});
|
|
80
|
+
(0, vitest_1.it)('server/discover then tools/list over stdio (modern era)', async () => {
|
|
81
|
+
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
|
+
});
|
|
92
|
+
const modernMeta = {
|
|
93
|
+
[server_1.PROTOCOL_VERSION_META_KEY]: '2026-07-28',
|
|
94
|
+
[server_1.CLIENT_INFO_META_KEY]: {
|
|
95
|
+
name: 'stdio-process-smoke-modern',
|
|
96
|
+
version: '0.0.0',
|
|
97
|
+
},
|
|
98
|
+
[server_1.CLIENT_CAPABILITIES_META_KEY]: {},
|
|
99
|
+
};
|
|
100
|
+
writeLine(child, {
|
|
101
|
+
jsonrpc: '2.0',
|
|
102
|
+
id: 1,
|
|
103
|
+
method: 'server/discover',
|
|
104
|
+
params: { _meta: modernMeta },
|
|
105
|
+
});
|
|
106
|
+
const discoverResponse = await readJsonRpcResponse(child, 1, INIT_TIMEOUT_MS, () => stderr);
|
|
107
|
+
(0, vitest_1.expect)(discoverResponse.error).toBeUndefined();
|
|
108
|
+
(0, vitest_1.expect)(discoverResponse.result).toBeDefined();
|
|
109
|
+
const discoverResult = discoverResponse.result;
|
|
110
|
+
(0, vitest_1.expect)(discoverResult.supportedVersions).toContain('2026-07-28');
|
|
111
|
+
(0, vitest_1.expect)((_a = discoverResult.capabilities) === null || _a === void 0 ? void 0 : _a.tools).toBeDefined();
|
|
112
|
+
writeLine(child, {
|
|
113
|
+
jsonrpc: '2.0',
|
|
114
|
+
id: 2,
|
|
115
|
+
method: 'tools/list',
|
|
116
|
+
params: { _meta: modernMeta },
|
|
117
|
+
});
|
|
118
|
+
const listResponse = await readJsonRpcResponse(child, 2, INIT_TIMEOUT_MS, () => stderr);
|
|
119
|
+
(0, vitest_1.expect)(listResponse.error).toBeUndefined();
|
|
120
|
+
(0, vitest_1.expect)(listResponse.result).toMatchObject({
|
|
121
|
+
tools: vitest_1.expect.arrayContaining([
|
|
122
|
+
vitest_1.expect.objectContaining({ name: `${shared_js_1.TOOL_PREFIX}list_projects` }),
|
|
123
|
+
]),
|
|
124
|
+
});
|
|
125
|
+
const listResult = listResponse.result;
|
|
126
|
+
(0, vitest_1.expect)(listResult.tools).toHaveLength(SEMANTIC_LAYER_TOOL_COUNT);
|
|
127
|
+
killChild(child);
|
|
128
|
+
child = undefined;
|
|
129
|
+
});
|
|
76
130
|
(0, vitest_1.it)('initialize then tools/list over stdio', async () => {
|
|
77
131
|
var _a;
|
|
78
132
|
let stderr = '';
|
|
79
133
|
child = (0, node_child_process_1.spawn)(process.execPath, [binPath], {
|
|
80
134
|
cwd: repoRoot,
|
|
81
|
-
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke',
|
|
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',
|
|
82
136
|
// Avoid inheriting real credentials or network-affecting settings.
|
|
83
137
|
LIGHTDASH_TOOLS_AUDIT_LOG: undefined }),
|
|
84
138
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
@@ -123,12 +177,12 @@ function killChild(child) {
|
|
|
123
177
|
killChild(child);
|
|
124
178
|
child = undefined;
|
|
125
179
|
});
|
|
126
|
-
(0, vitest_1.it)('initialize then tools/list for content-reader
|
|
180
|
+
(0, vitest_1.it)('initialize then tools/list for content-reader profile', async () => {
|
|
127
181
|
var _a;
|
|
128
182
|
let stderr = '';
|
|
129
183
|
child = (0, node_child_process_1.spawn)(process.execPath, [binPath, 'content-reader'], {
|
|
130
184
|
cwd: repoRoot,
|
|
131
|
-
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke',
|
|
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 }),
|
|
132
186
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
133
187
|
});
|
|
134
188
|
child.stderr.setEncoding('utf8');
|
|
@@ -172,12 +226,12 @@ function killChild(child) {
|
|
|
172
226
|
killChild(child);
|
|
173
227
|
child = undefined;
|
|
174
228
|
});
|
|
175
|
-
(0, vitest_1.it)('initialize then tools/list for content-governance
|
|
229
|
+
(0, vitest_1.it)('initialize then tools/list for content-governance profile', async () => {
|
|
176
230
|
var _a;
|
|
177
231
|
let stderr = '';
|
|
178
232
|
child = (0, node_child_process_1.spawn)(process.execPath, [binPath, 'content-governance'], {
|
|
179
233
|
cwd: repoRoot,
|
|
180
|
-
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke',
|
|
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 }),
|
|
181
235
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
182
236
|
});
|
|
183
237
|
child.stderr.setEncoding('utf8');
|
|
@@ -224,12 +278,12 @@ function killChild(child) {
|
|
|
224
278
|
killChild(child);
|
|
225
279
|
child = undefined;
|
|
226
280
|
});
|
|
227
|
-
(0, vitest_1.it)('initialize then tools/list for content-developer
|
|
281
|
+
(0, vitest_1.it)('initialize then tools/list for content-developer profile', async () => {
|
|
228
282
|
var _a;
|
|
229
283
|
let stderr = '';
|
|
230
284
|
child = (0, node_child_process_1.spawn)(process.execPath, [binPath, 'content-developer'], {
|
|
231
285
|
cwd: repoRoot,
|
|
232
|
-
env: Object.assign(Object.assign({}, process.env), { LIGHTDASH_URL: 'https://app.lightdash.cloud', LIGHTDASH_API_KEY: 'dummy-key-for-stdio-smoke',
|
|
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 }),
|
|
233
287
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
234
288
|
});
|
|
235
289
|
child.stderr.setEncoding('utf8');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Project AI agent inventory tools (ai-agent-ops
|
|
2
|
+
* Project AI agent inventory tools (ai-agent-ops profile).
|
|
3
3
|
*/
|
|
4
4
|
import type { McpContextProvider } from '../../server/request-context.js';
|
|
5
5
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Project AI agent inventory tools (ai-agent-ops
|
|
3
|
+
* Project AI agent inventory tools (ai-agent-ops profile).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerListProjectAgents = registerListProjectAgents;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AI agent evaluation suite/run tools (ai-agent-ops
|
|
2
|
+
* AI agent evaluation suite/run tools (ai-agent-ops profile).
|
|
3
3
|
*/
|
|
4
4
|
import type { McpContextProvider } from '../../server/request-context.js';
|
|
5
5
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* AI agent evaluation suite/run tools (ai-agent-ops
|
|
3
|
+
* AI agent evaluation suite/run tools (ai-agent-ops profile).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerListAgentEvaluations = registerListAgentEvaluations;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Shared helpers for ai-agent-ops MCP tools (ADR-0018).
|
|
3
3
|
*/
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
+
import { optionalProjectUuidField } from '../lib/schema-fields.js';
|
|
5
6
|
import type { ResolvedProjectScope } from '../../governance/project-scope.js';
|
|
6
7
|
import type { TextContent } from '../shared.js';
|
|
8
|
+
export { optionalProjectUuidField };
|
|
7
9
|
export declare const agentUuidField: () => z.ZodString;
|
|
8
10
|
export declare const evalUuidField: () => z.ZodString;
|
|
9
11
|
export declare const runUuidField: () => z.ZodString;
|
|
10
12
|
export declare const threadUuidField: () => z.ZodString;
|
|
11
|
-
/** Optional projectUuid when pin can resolve scope. */
|
|
12
|
-
export declare const optionalProjectUuidField: () => z.ZodOptional<z.ZodString>;
|
|
13
13
|
declare const evaluationPromptSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
14
14
|
prompt: z.ZodString;
|
|
15
15
|
expectedResponse: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -61,4 +61,3 @@ export declare function redactEvalRunResults(run: unknown, includePromptText: bo
|
|
|
61
61
|
data: unknown;
|
|
62
62
|
warnings: RedactionWarning[];
|
|
63
63
|
};
|
|
64
|
-
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Shared helpers for ai-agent-ops MCP tools (ADR-0018).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PROMPT_REDACTED_WARNING = exports.CONVERSATION_REDACTED_WARNING = exports.includePromptTextField = exports.includeMessageTextField = exports.evaluationPromptsField = exports.
|
|
6
|
+
exports.PROMPT_REDACTED_WARNING = exports.CONVERSATION_REDACTED_WARNING = exports.includePromptTextField = exports.includeMessageTextField = exports.evaluationPromptsField = exports.threadUuidField = exports.runUuidField = exports.evalUuidField = exports.agentUuidField = exports.optionalProjectUuidField = void 0;
|
|
7
7
|
exports.withAgentOpsScope = withAgentOpsScope;
|
|
8
8
|
exports.redactThreadMessages = redactThreadMessages;
|
|
9
9
|
exports.redactThreadSummaries = redactThreadSummaries;
|
|
@@ -12,6 +12,7 @@ exports.redactEvalRunResults = redactEvalRunResults;
|
|
|
12
12
|
const zod_1 = require("zod");
|
|
13
13
|
const project_scope_js_1 = require("../../governance/project-scope.js");
|
|
14
14
|
const schema_fields_js_1 = require("../lib/schema-fields.js");
|
|
15
|
+
Object.defineProperty(exports, "optionalProjectUuidField", { enumerable: true, get: function () { return schema_fields_js_1.optionalProjectUuidField; } });
|
|
15
16
|
const reader_tool_helpers_js_1 = require("../query/reader-tool-helpers.js");
|
|
16
17
|
const shared_js_1 = require("../shared.js");
|
|
17
18
|
const agentUuidField = () => zod_1.z.string().describe('AI agent UUID');
|
|
@@ -22,9 +23,6 @@ const runUuidField = () => zod_1.z.string().describe('Evaluation run UUID');
|
|
|
22
23
|
exports.runUuidField = runUuidField;
|
|
23
24
|
const threadUuidField = () => zod_1.z.string().describe('Thread UUID');
|
|
24
25
|
exports.threadUuidField = threadUuidField;
|
|
25
|
-
/** Optional projectUuid when pin can resolve scope. */
|
|
26
|
-
const optionalProjectUuidField = () => (0, schema_fields_js_1.projectUuidField)().optional();
|
|
27
|
-
exports.optionalProjectUuidField = optionalProjectUuidField;
|
|
28
26
|
const evaluationPromptSchema = zod_1.z.union([
|
|
29
27
|
zod_1.z.object({
|
|
30
28
|
prompt: zod_1.z.string().min(1),
|
|
@@ -26,7 +26,7 @@ function registerExplainContent(server, contextProvider) {
|
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
28
|
/* eslint-disable sonarjs/cognitive-complexity, sonarjs/cyclomatic-complexity -- explain branches */
|
|
29
|
-
(0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
|
|
29
|
+
(profile) => (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
|
|
30
30
|
var _a;
|
|
31
31
|
try {
|
|
32
32
|
const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
|
|
@@ -67,6 +67,7 @@ function registerExplainContent(server, contextProvider) {
|
|
|
67
67
|
: ['Not executable on content-reader v1'],
|
|
68
68
|
};
|
|
69
69
|
return (0, shared_js_1.jsonToolResult)((0, envelope_js_1.contentReaderEnvelope)(explanation, {
|
|
70
|
+
profile,
|
|
70
71
|
projectUuid: scope.projectUuid,
|
|
71
72
|
projectPinned: scope.projectPinned,
|
|
72
73
|
}));
|
|
@@ -97,6 +98,7 @@ function registerExplainContent(server, contextProvider) {
|
|
|
97
98
|
],
|
|
98
99
|
};
|
|
99
100
|
return (0, shared_js_1.jsonToolResult)((0, envelope_js_1.contentReaderEnvelope)(explanation, {
|
|
101
|
+
profile,
|
|
100
102
|
projectUuid: scope.projectUuid,
|
|
101
103
|
projectPinned: scope.projectPinned,
|
|
102
104
|
}));
|
package/dist/tools/index.d.ts
CHANGED
package/dist/tools/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Tool registration: shared registry only (
|
|
3
|
+
* Tool registration: shared registry only (profiles select via registerToolsByIds).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerToolsByIds = void 0;
|
package/dist/tools/index.test.js
CHANGED
|
@@ -33,8 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const common_1 = require("@lightdash-tools/common");
|
|
36
37
|
const vitest_1 = require("vitest");
|
|
37
|
-
const
|
|
38
|
+
const server_profile_js_1 = require("../audit/server-profile.js");
|
|
39
|
+
const index_js_1 = require("../profiles/index.js");
|
|
38
40
|
const registry_js_1 = require("./registry.js");
|
|
39
41
|
const shared_js_1 = require("./shared.js");
|
|
40
42
|
vitest_1.vi.mock('@lightdash-tools/common', async (importOriginal) => {
|
|
@@ -54,19 +56,23 @@ vitest_1.vi.mock('@lightdash-tools/common', async (importOriginal) => {
|
|
|
54
56
|
registeredTools.length = 0;
|
|
55
57
|
mockServer.registerTool.mockClear();
|
|
56
58
|
});
|
|
57
|
-
(0, vitest_1.it)('registers only the
|
|
59
|
+
(0, vitest_1.it)('registers only the profile catalog tools with lightdash_ prefix', () => {
|
|
58
60
|
const mockContextProvider = { getContext: async () => ({ lightdashClient: {} }) };
|
|
59
|
-
const
|
|
60
|
-
(0,
|
|
61
|
-
(0,
|
|
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);
|
|
62
66
|
(0, vitest_1.expect)(registeredTools.every((t) => t.name.startsWith(shared_js_1.TOOL_PREFIX))).toBe(true);
|
|
63
67
|
const names = registeredTools.map((t) => t.name);
|
|
64
|
-
(0, vitest_1.expect)(names).toEqual(
|
|
68
|
+
(0, vitest_1.expect)(names).toEqual(toolIds.map((id) => `${shared_js_1.TOOL_PREFIX}${id}`));
|
|
65
69
|
});
|
|
66
|
-
(0, vitest_1.it)('covers every registry tool id via some
|
|
67
|
-
const {
|
|
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')));
|
|
68
72
|
const { toolRegistry } = await Promise.resolve().then(() => __importStar(require('./registry.js')));
|
|
69
|
-
const covered = new Set(Object.
|
|
70
|
-
(
|
|
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
|
+
}
|
|
71
77
|
});
|
|
72
78
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const PROJECT_UUID_DESC = "Project UUID";
|
|
3
3
|
export declare const projectUuidField: () => z.ZodString;
|
|
4
|
+
/** Optional projectUuid when HTTP pin (`X-Lightdash-Project`) can resolve scope. */
|
|
5
|
+
export declare const optionalProjectUuidField: () => z.ZodOptional<z.ZodString>;
|
|
4
6
|
/** OpenAPI UuidOrSlug field (dashboard/chart identifiers). */
|
|
5
7
|
export declare const uuidOrSlugField: (description?: string) => z.ZodString;
|
|
6
8
|
/** Opt-in full email addresses in MCP responses (default redacted). */
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.allowedEmailDomainsField = exports.includeEmailField = exports.uuidOrSlugField = exports.projectUuidField = exports.PROJECT_UUID_DESC = void 0;
|
|
3
|
+
exports.allowedEmailDomainsField = exports.includeEmailField = exports.uuidOrSlugField = exports.optionalProjectUuidField = exports.projectUuidField = exports.PROJECT_UUID_DESC = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.PROJECT_UUID_DESC = 'Project UUID';
|
|
6
6
|
const projectUuidField = () => zod_1.z.string().describe(exports.PROJECT_UUID_DESC);
|
|
7
7
|
exports.projectUuidField = projectUuidField;
|
|
8
|
+
/** Optional projectUuid when HTTP pin (`X-Lightdash-Project`) can resolve scope. */
|
|
9
|
+
const optionalProjectUuidField = () => (0, exports.projectUuidField)().optional();
|
|
10
|
+
exports.optionalProjectUuidField = optionalProjectUuidField;
|
|
8
11
|
/** OpenAPI UuidOrSlug field (dashboard/chart identifiers). */
|
|
9
12
|
const uuidOrSlugField = (description = 'UUID or slug') => zod_1.z.string().describe(description);
|
|
10
13
|
exports.uuidOrSlugField = uuidOrSlugField;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Deterministic JSON stringify for digests and diffs (
|
|
2
|
+
* Deterministic JSON stringify for digests and diffs (profile-neutral).
|
|
3
3
|
*/
|
|
4
4
|
/** True for plain objects (not null, not arrays). */
|
|
5
5
|
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Deterministic JSON stringify for digests and diffs (
|
|
3
|
+
* Deterministic JSON stringify for digests and diffs (profile-neutral).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isRecord = isRecord;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Profile safety invariant: all org-audit tools register as read-only GET.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const common_1 = require("@lightdash-tools/common");
|
|
7
7
|
const vitest_1 = require("vitest");
|
|
8
|
-
const index_js_1 = require("../../personas/organization-audit/v1/index.js");
|
|
9
8
|
const registry_js_1 = require("../registry.js");
|
|
10
9
|
const shared_js_1 = require("../shared.js");
|
|
11
10
|
(0, vitest_1.describe)('organization-audit safety invariants', () => {
|
|
@@ -17,9 +16,10 @@ const shared_js_1 = require("../shared.js");
|
|
|
17
16
|
}),
|
|
18
17
|
};
|
|
19
18
|
const mockCtx = { getContext: async () => ({ lightdashClient: {} }) };
|
|
20
|
-
(0,
|
|
21
|
-
(0,
|
|
22
|
-
|
|
19
|
+
const toolIds = (0, common_1.listMcpToolNamesByProfile)('organization-audit');
|
|
20
|
+
(0, registry_js_1.registerToolsByIds)(mockServer, mockCtx, toolIds);
|
|
21
|
+
(0, vitest_1.expect)(annotationsByName.size).toBe(toolIds.length);
|
|
22
|
+
for (const id of toolIds) {
|
|
23
23
|
const annotations = annotationsByName.get(`${shared_js_1.TOOL_PREFIX}${id}`);
|
|
24
24
|
(0, vitest_1.expect)(annotations === null || annotations === void 0 ? void 0 : annotations.readOnlyHint).toBe(true);
|
|
25
25
|
(0, vitest_1.expect)(annotations).toMatchObject(common_1.READ_ONLY_DEFAULT);
|