@lightdash-tools/mcp 0.9.0 → 0.11.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 +5 -5
- 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
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const node_http_1 = require("node:http");
|
|
4
4
|
const client_1 = require("@lightdash-tools/client");
|
|
5
|
+
const server_1 = require("@modelcontextprotocol/server");
|
|
5
6
|
const vitest_1 = require("vitest");
|
|
6
7
|
const oauth_protected_resource_js_1 = require("./auth/resource-server/oauth-protected-resource.js");
|
|
7
|
-
const client_capabilities_cache_js_1 = require("./governance/client-capabilities-cache.js");
|
|
8
8
|
const streamable_http_js_1 = require("./transports/streamable-http.js");
|
|
9
9
|
const TOKEN_A = scopedAccessToken('mcp:read mcp:write', 'token-a');
|
|
10
10
|
const TOKEN_B = scopedAccessToken('mcp:read mcp:write', 'token-b');
|
|
@@ -171,7 +171,6 @@ function parseSseOrJsonToolText(raw) {
|
|
|
171
171
|
(0, vitest_1.afterEach)(async () => {
|
|
172
172
|
await mcpServer.close();
|
|
173
173
|
await mockLightdash.close();
|
|
174
|
-
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
175
174
|
vitest_1.vi.restoreAllMocks();
|
|
176
175
|
});
|
|
177
176
|
(0, vitest_1.it)('returns 401 with WWW-Authenticate resource_metadata when OAuth token is missing', async () => {
|
|
@@ -263,7 +262,7 @@ function parseSseOrJsonToolText(raw) {
|
|
|
263
262
|
const metadata = await response.json();
|
|
264
263
|
(0, vitest_1.expect)(metadata.resource).toBe(`${mcpServer.baseUrl}/content-governance/v1/mcp`);
|
|
265
264
|
});
|
|
266
|
-
(0, vitest_1.it)('returns 401 with organization-audit resource_metadata on that
|
|
265
|
+
(0, vitest_1.it)('returns 401 with organization-audit resource_metadata on that profile path', async () => {
|
|
267
266
|
const response = await fetch(`${mcpServer.baseUrl}/organization-audit/v1/mcp`, {
|
|
268
267
|
method: 'POST',
|
|
269
268
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
@@ -274,7 +273,7 @@ function parseSseOrJsonToolText(raw) {
|
|
|
274
273
|
(0, vitest_1.expect)(wwwAuthenticate).toContain(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/organization-audit/v1/mcp`);
|
|
275
274
|
(0, vitest_1.expect)(wwwAuthenticate).not.toContain('semantic-layer/v1/mcp');
|
|
276
275
|
});
|
|
277
|
-
(0, vitest_1.it)('returns 401 with content-reader resource_metadata on that
|
|
276
|
+
(0, vitest_1.it)('returns 401 with content-reader resource_metadata on that profile path', async () => {
|
|
278
277
|
const response = await fetch(`${mcpServer.baseUrl}/content-reader/v1/mcp`, {
|
|
279
278
|
method: 'POST',
|
|
280
279
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
@@ -285,7 +284,7 @@ function parseSseOrJsonToolText(raw) {
|
|
|
285
284
|
(0, vitest_1.expect)(wwwAuthenticate).toContain(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/content-reader/v1/mcp`);
|
|
286
285
|
(0, vitest_1.expect)(wwwAuthenticate).not.toContain('semantic-layer/v1/mcp');
|
|
287
286
|
});
|
|
288
|
-
(0, vitest_1.it)('returns 401 with content-governance resource_metadata on that
|
|
287
|
+
(0, vitest_1.it)('returns 401 with content-governance resource_metadata on that profile path', async () => {
|
|
289
288
|
const response = await fetch(`${mcpServer.baseUrl}/content-governance/v1/mcp`, {
|
|
290
289
|
method: 'POST',
|
|
291
290
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
@@ -304,10 +303,8 @@ function parseSseOrJsonToolText(raw) {
|
|
|
304
303
|
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
|
|
305
304
|
(0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_B}`);
|
|
306
305
|
});
|
|
307
|
-
(0, vitest_1.it)('
|
|
306
|
+
(0, vitest_1.it)('accepts form-elicitation caps from per-request _meta on content-governance tools/call', async () => {
|
|
308
307
|
const governancePath = '/content-governance/v1/mcp';
|
|
309
|
-
const init = await postMcp(mcpServer.baseUrl, Object.assign(Object.assign({}, INITIALIZE_BODY), { params: Object.assign(Object.assign({}, INITIALIZE_BODY.params), { capabilities: { elicitation: { form: {} } } }) }), { token: TOKEN_A, path: governancePath });
|
|
310
|
-
(0, vitest_1.expect)(init.status).toBe(200);
|
|
311
308
|
const call = await postMcp(mcpServer.baseUrl, {
|
|
312
309
|
jsonrpc: '2.0',
|
|
313
310
|
method: 'tools/call',
|
|
@@ -317,12 +314,15 @@ function parseSseOrJsonToolText(raw) {
|
|
|
317
314
|
projectUuid: '11111111-1111-4111-8111-111111111111',
|
|
318
315
|
chartUuidOrSlug: '22222222-2222-4222-8222-222222222222',
|
|
319
316
|
},
|
|
317
|
+
_meta: {
|
|
318
|
+
[server_1.CLIENT_CAPABILITIES_META_KEY]: { elicitation: { form: {} } },
|
|
319
|
+
},
|
|
320
320
|
},
|
|
321
321
|
id: 2,
|
|
322
322
|
}, { token: TOKEN_A, path: governancePath });
|
|
323
323
|
(0, vitest_1.expect)(call.status).toBe(200);
|
|
324
324
|
const text = parseSseOrJsonToolText(await call.text());
|
|
325
|
-
//
|
|
325
|
+
// Per-request envelope caps: past ELICITATION_REQUIRED into chart resolve (mock has no chart).
|
|
326
326
|
(0, vitest_1.expect)(text).not.toContain('ELICITATION_REQUIRED');
|
|
327
327
|
(0, vitest_1.expect)(text).toContain('CONTENT_NOT_FOUND');
|
|
328
328
|
});
|
|
@@ -370,7 +370,6 @@ function parseSseOrJsonToolText(raw) {
|
|
|
370
370
|
(0, vitest_1.afterEach)(async () => {
|
|
371
371
|
await mcpServer.close();
|
|
372
372
|
await mockLightdash.close();
|
|
373
|
-
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
374
373
|
vitest_1.vi.restoreAllMocks();
|
|
375
374
|
});
|
|
376
375
|
(0, vitest_1.it)('protected-resource metadata authorization_servers points at MCP broker AS metadata', async () => {
|
|
@@ -428,7 +427,6 @@ function parseSseOrJsonToolText(raw) {
|
|
|
428
427
|
(0, vitest_1.afterEach)(async () => {
|
|
429
428
|
await mcpServer.close();
|
|
430
429
|
await mockLightdash.close();
|
|
431
|
-
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
432
430
|
vitest_1.vi.restoreAllMocks();
|
|
433
431
|
});
|
|
434
432
|
(0, vitest_1.it)('sets CORS headers for allowed origins on metadata', async () => {
|
|
@@ -472,7 +470,6 @@ function parseSseOrJsonToolText(raw) {
|
|
|
472
470
|
(0, vitest_1.afterEach)(async () => {
|
|
473
471
|
await mcpServer.close();
|
|
474
472
|
await mockLightdash.close();
|
|
475
|
-
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
476
473
|
vitest_1.vi.restoreAllMocks();
|
|
477
474
|
});
|
|
478
475
|
(0, vitest_1.it)('returns 413 for oversized JSON body after OAuth authentication', async () => {
|
|
@@ -489,7 +486,7 @@ function parseSseOrJsonToolText(raw) {
|
|
|
489
486
|
(0, vitest_1.expect)(response.status).toBe(413);
|
|
490
487
|
(0, vitest_1.expect)(await response.json()).toEqual({ error: 'Payload Too Large' });
|
|
491
488
|
});
|
|
492
|
-
(0, vitest_1.it)('returns 405 for GET on
|
|
489
|
+
(0, vitest_1.it)('returns 405 for GET on profile endpoint (sessionless, no persistent streams)', async () => {
|
|
493
490
|
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
494
491
|
method: 'GET',
|
|
495
492
|
headers: {
|
|
@@ -499,7 +496,7 @@ function parseSseOrJsonToolText(raw) {
|
|
|
499
496
|
});
|
|
500
497
|
(0, vitest_1.expect)(response.status).toBe(405);
|
|
501
498
|
});
|
|
502
|
-
(0, vitest_1.it)('returns 405 for DELETE on
|
|
499
|
+
(0, vitest_1.it)('returns 405 for DELETE on profile endpoint (sessionless, no sessions to close)', async () => {
|
|
503
500
|
const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
|
|
504
501
|
method: 'DELETE',
|
|
505
502
|
headers: {
|
|
@@ -535,7 +532,6 @@ function parseSseOrJsonToolText(raw) {
|
|
|
535
532
|
(0, vitest_1.afterEach)(async () => {
|
|
536
533
|
await mcpServer.close();
|
|
537
534
|
process.env = Object.assign({}, originalEnv);
|
|
538
|
-
(0, client_capabilities_cache_js_1.resetClientCapabilitiesCacheForTests)();
|
|
539
535
|
vitest_1.vi.restoreAllMocks();
|
|
540
536
|
});
|
|
541
537
|
(0, vitest_1.it)('requires shared key on MCP endpoint', async () => {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* MCP server entrypoint (Stdio). Use LIGHTDASH_URL and LIGHTDASH_API_KEY.
|
|
3
3
|
* Logging: stderr only (stdout is JSON-RPC).
|
|
4
4
|
*
|
|
5
|
-
* Optional
|
|
5
|
+
* Optional profile via LIGHTDASH_TOOLS_MCP_STDIO_PROFILE (set by bin subcommands).
|
|
6
|
+
*
|
|
7
|
+
* Uses SDK `serveStdio` so the process speaks 2026-07-28 (and legacy initialize
|
|
8
|
+
* via `legacy: 'serve'`). Hand-wiring `StdioServerTransport` + `connect()` stays
|
|
9
|
+
* on the 2025-era wire only.
|
|
6
10
|
*/
|
|
7
11
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -3,39 +3,52 @@
|
|
|
3
3
|
* MCP server entrypoint (Stdio). Use LIGHTDASH_URL and LIGHTDASH_API_KEY.
|
|
4
4
|
* Logging: stderr only (stdout is JSON-RPC).
|
|
5
5
|
*
|
|
6
|
-
* Optional
|
|
6
|
+
* Optional profile via LIGHTDASH_TOOLS_MCP_STDIO_PROFILE (set by bin subcommands).
|
|
7
|
+
*
|
|
8
|
+
* Uses SDK `serveStdio` so the process speaks 2026-07-28 (and legacy initialize
|
|
9
|
+
* via `legacy: 'serve'`). Hand-wiring `StdioServerTransport` + `connect()` stays
|
|
10
|
+
* on the 2025-era wire only.
|
|
7
11
|
*/
|
|
8
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const common_1 = require("@lightdash-tools/common");
|
|
9
14
|
const stdio_1 = require("@modelcontextprotocol/server/stdio");
|
|
10
15
|
const audit_js_1 = require("./audit/audit.js");
|
|
11
16
|
const env_context_provider_js_1 = require("./auth/providers/env-context-provider.js");
|
|
17
|
+
const obsolete_env_js_1 = require("./config/obsolete-env.js");
|
|
12
18
|
const runtime_js_1 = require("./config/runtime.js");
|
|
13
19
|
const available_projects_js_1 = require("./governance/available-projects.js");
|
|
14
|
-
const index_js_1 = require("./
|
|
20
|
+
const index_js_1 = require("./profiles/index.js");
|
|
15
21
|
const server_js_1 = require("./server/server.js");
|
|
16
|
-
function
|
|
17
|
-
const raw = process.env.
|
|
22
|
+
function resolveStdioProfile() {
|
|
23
|
+
const raw = process.env.LIGHTDASH_TOOLS_MCP_STDIO_PROFILE;
|
|
18
24
|
if (!raw) {
|
|
19
|
-
return (0, index_js_1.
|
|
25
|
+
return (0, index_js_1.getDefaultProfile)();
|
|
20
26
|
}
|
|
21
|
-
const id = (0, index_js_1.
|
|
27
|
+
const id = (0, index_js_1.parseProfileId)(raw);
|
|
22
28
|
if (!id) {
|
|
23
|
-
throw new Error(`Invalid
|
|
29
|
+
throw new Error(`Invalid LIGHTDASH_TOOLS_MCP_STDIO_PROFILE='${raw}'. Expected one of: ${common_1.PROFILE_IDS.join(', ')}.`);
|
|
24
30
|
}
|
|
25
|
-
return (0, index_js_1.
|
|
31
|
+
return (0, index_js_1.getProfile)(id);
|
|
26
32
|
}
|
|
27
|
-
|
|
33
|
+
function main() {
|
|
34
|
+
(0, obsolete_env_js_1.assertObsoleteEnvRejected)(process.env);
|
|
28
35
|
(0, runtime_js_1.warnIgnoredCliGuardrailEnvVars)();
|
|
29
36
|
(0, available_projects_js_1.validateAvailableProjectsConfig)();
|
|
30
37
|
(0, audit_js_1.initAuditLog)((0, runtime_js_1.getAuditLogPath)());
|
|
31
|
-
const
|
|
38
|
+
const profile = resolveStdioProfile();
|
|
32
39
|
const contextProvider = new env_context_provider_js_1.EnvContextProvider();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
(0, stdio_1.serveStdio)(() => (0, server_js_1.createLightdashMcpServer)(contextProvider, { profile }), {
|
|
41
|
+
legacy: 'serve',
|
|
42
|
+
onerror: (error) => {
|
|
43
|
+
console.error('MCP stdio error:', error);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
console.error(`Lightdash MCP server (${profile.id}) running on stdio`);
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
main();
|
|
37
50
|
}
|
|
38
|
-
|
|
51
|
+
catch (err) {
|
|
39
52
|
console.error('Fatal:', err);
|
|
40
53
|
process.exit(1);
|
|
41
|
-
}
|
|
54
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Content-reader safety policy and registration helper (ADR-0012).
|
|
2
|
+
* Content-reader / bounded-query safety policy and registration helper (ADR-0012 / ADR-0020).
|
|
3
3
|
*/
|
|
4
4
|
import type { ToolHandler, ToolOptions } from '../tools/shared.js';
|
|
5
|
-
import type { ToolAnnotations } from '@lightdash-tools/common';
|
|
5
|
+
import type { ProfileId, ToolAnnotations } from '@lightdash-tools/common';
|
|
6
6
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
7
7
|
export type ReaderOperationSafety = {
|
|
8
8
|
mutability: 'none' | 'transient';
|
|
@@ -17,12 +17,17 @@ export declare const SAVED_EXECUTION_ANNOTATIONS: ToolAnnotations;
|
|
|
17
17
|
export declare const IMAGE_SNAPSHOT_ANNOTATIONS: ToolAnnotations;
|
|
18
18
|
export declare const METADATA_SAFETY: ReaderOperationSafety;
|
|
19
19
|
export declare const SAVED_EXECUTION_SAFETY: ReaderOperationSafety;
|
|
20
|
+
/** Unsaved explore metric-query execution (ADR-0020 data-analyst). */
|
|
21
|
+
export declare const METRIC_QUERY_SAFETY: ReaderOperationSafety;
|
|
20
22
|
/** Single saved-chart PNG snapshot via headless export (ADR-0012 carve-out). */
|
|
21
23
|
export declare const IMAGE_SNAPSHOT_SAFETY: ReaderOperationSafety;
|
|
22
|
-
/** Throws when a tool violates content-reader capability policy. */
|
|
24
|
+
/** Throws when a tool violates content-reader / bounded-query capability policy. */
|
|
23
25
|
export declare function assertContentReaderSafe(safety: ReaderOperationSafety): void;
|
|
24
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Register a content-reader-family / bounded-query tool after safety asserts.
|
|
28
|
+
* Fail-closed: requires bindServerProfile on the server (serving profile for envelopes/audit).
|
|
29
|
+
*/
|
|
25
30
|
export declare function registerContentReaderTool(server: McpServer, shortName: string, options: Omit<ToolOptions, 'annotations'> & {
|
|
26
31
|
annotations?: ToolOptions['annotations'];
|
|
27
32
|
safety: ReaderOperationSafety;
|
|
28
|
-
},
|
|
33
|
+
}, createHandler: (profile: ProfileId) => ToolHandler): void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Content-reader safety policy and registration helper (ADR-0012).
|
|
3
|
+
* Content-reader / bounded-query safety policy and registration helper (ADR-0012 / ADR-0020).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.IMAGE_SNAPSHOT_SAFETY = exports.SAVED_EXECUTION_SAFETY = exports.METADATA_SAFETY = exports.IMAGE_SNAPSHOT_ANNOTATIONS = exports.SAVED_EXECUTION_ANNOTATIONS = void 0;
|
|
6
|
+
exports.IMAGE_SNAPSHOT_SAFETY = exports.METRIC_QUERY_SAFETY = exports.SAVED_EXECUTION_SAFETY = exports.METADATA_SAFETY = exports.IMAGE_SNAPSHOT_ANNOTATIONS = exports.SAVED_EXECUTION_ANNOTATIONS = void 0;
|
|
7
7
|
exports.assertContentReaderSafe = assertContentReaderSafe;
|
|
8
8
|
exports.registerContentReaderTool = registerContentReaderTool;
|
|
9
9
|
const common_1 = require("@lightdash-tools/common");
|
|
10
|
+
const server_profile_js_1 = require("../audit/server-profile.js");
|
|
10
11
|
const shared_js_1 = require("../tools/shared.js");
|
|
11
12
|
/** Computational read-only (warehouse run) but not idempotent — run/cancel/poll. */
|
|
12
13
|
exports.SAVED_EXECUTION_ANNOTATIONS = common_1.READ_ONLY_TRANSIENT;
|
|
@@ -26,6 +27,14 @@ exports.SAVED_EXECUTION_SAFETY = {
|
|
|
26
27
|
usesWarehouse: true,
|
|
27
28
|
agentExposure: 'agent',
|
|
28
29
|
};
|
|
30
|
+
/** Unsaved explore metric-query execution (ADR-0020 data-analyst). */
|
|
31
|
+
exports.METRIC_QUERY_SAFETY = {
|
|
32
|
+
mutability: 'transient',
|
|
33
|
+
queryCapability: 'arbitrary_semantic',
|
|
34
|
+
resultCapability: 'bounded_aggregate_rows',
|
|
35
|
+
usesWarehouse: true,
|
|
36
|
+
agentExposure: 'agent',
|
|
37
|
+
};
|
|
29
38
|
/** Single saved-chart PNG snapshot via headless export (ADR-0012 carve-out). */
|
|
30
39
|
exports.IMAGE_SNAPSHOT_SAFETY = {
|
|
31
40
|
mutability: 'none',
|
|
@@ -34,13 +43,14 @@ exports.IMAGE_SNAPSHOT_SAFETY = {
|
|
|
34
43
|
usesWarehouse: true,
|
|
35
44
|
agentExposure: 'agent',
|
|
36
45
|
};
|
|
37
|
-
|
|
46
|
+
const ALLOWED_QUERY_CAPABILITIES = new Set(['none', 'saved_content', 'arbitrary_semantic']);
|
|
47
|
+
/** Throws when a tool violates content-reader / bounded-query capability policy. */
|
|
38
48
|
function assertContentReaderSafe(safety) {
|
|
39
49
|
if (safety.mutability !== 'none' && safety.mutability !== 'transient') {
|
|
40
50
|
throw new Error('Persisted mutation is forbidden');
|
|
41
51
|
}
|
|
42
|
-
if (
|
|
43
|
-
throw new Error('Only saved-content queries are allowed');
|
|
52
|
+
if (!ALLOWED_QUERY_CAPABILITIES.has(safety.queryCapability)) {
|
|
53
|
+
throw new Error('Only saved-content or arbitrary-semantic queries are allowed');
|
|
44
54
|
}
|
|
45
55
|
if (safety.resultCapability !== 'metadata' &&
|
|
46
56
|
safety.resultCapability !== 'bounded_aggregate_rows' &&
|
|
@@ -51,10 +61,14 @@ function assertContentReaderSafe(safety) {
|
|
|
51
61
|
throw new Error('Operation is client-only');
|
|
52
62
|
}
|
|
53
63
|
}
|
|
54
|
-
/**
|
|
55
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Register a content-reader-family / bounded-query tool after safety asserts.
|
|
66
|
+
* Fail-closed: requires bindServerProfile on the server (serving profile for envelopes/audit).
|
|
67
|
+
*/
|
|
68
|
+
function registerContentReaderTool(server, shortName, options, createHandler) {
|
|
56
69
|
var _a;
|
|
57
|
-
const
|
|
70
|
+
const profile = (0, server_profile_js_1.requireServerProfile)(server, shortName);
|
|
71
|
+
const annotations = (_a = options.annotations) !== null && _a !== void 0 ? _a : (options.safety === exports.SAVED_EXECUTION_SAFETY || options.safety === exports.METRIC_QUERY_SAFETY
|
|
58
72
|
? exports.SAVED_EXECUTION_ANNOTATIONS
|
|
59
73
|
: options.safety === exports.IMAGE_SNAPSHOT_SAFETY
|
|
60
74
|
? exports.IMAGE_SNAPSHOT_ANNOTATIONS
|
|
@@ -63,5 +77,5 @@ function registerContentReaderTool(server, shortName, options, handler) {
|
|
|
63
77
|
if (annotations.readOnlyHint !== true) {
|
|
64
78
|
throw new Error(`content-reader requires readOnlyHint for '${shortName}'`);
|
|
65
79
|
}
|
|
66
|
-
(0, shared_js_1.registerToolSafe)(server, shortName, Object.assign(Object.assign({}, options), { annotations }),
|
|
80
|
+
(0, shared_js_1.registerToolSafe)(server, shortName, Object.assign(Object.assign({}, options), { annotations }), createHandler(profile));
|
|
67
81
|
}
|
|
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const vitest_1 = require("vitest");
|
|
7
7
|
const content_reader_js_1 = require("./content-reader.js");
|
|
8
8
|
(0, vitest_1.describe)('assertContentReaderSafe', () => {
|
|
9
|
-
(0, vitest_1.it)('accepts metadata, saved-execution, and image-snapshot presets', () => {
|
|
9
|
+
(0, vitest_1.it)('accepts metadata, saved-execution, metric-query, and image-snapshot presets', () => {
|
|
10
10
|
(0, vitest_1.expect)(() => (0, content_reader_js_1.assertContentReaderSafe)(content_reader_js_1.METADATA_SAFETY)).not.toThrow();
|
|
11
11
|
(0, vitest_1.expect)(() => (0, content_reader_js_1.assertContentReaderSafe)(content_reader_js_1.SAVED_EXECUTION_SAFETY)).not.toThrow();
|
|
12
|
+
(0, vitest_1.expect)(() => (0, content_reader_js_1.assertContentReaderSafe)(content_reader_js_1.METRIC_QUERY_SAFETY)).not.toThrow();
|
|
12
13
|
(0, vitest_1.expect)(() => (0, content_reader_js_1.assertContentReaderSafe)(content_reader_js_1.IMAGE_SNAPSHOT_SAFETY)).not.toThrow();
|
|
13
14
|
});
|
|
14
|
-
(0, vitest_1.it)('rejects
|
|
15
|
-
(0, vitest_1.expect)(() => (0, content_reader_js_1.assertContentReaderSafe)(Object.assign(Object.assign({}, content_reader_js_1.METADATA_SAFETY), { queryCapability: 'raw_sql' }))).toThrow(/saved-content/);
|
|
15
|
+
(0, vitest_1.it)('rejects raw SQL query capability', () => {
|
|
16
|
+
(0, vitest_1.expect)(() => (0, content_reader_js_1.assertContentReaderSafe)(Object.assign(Object.assign({}, content_reader_js_1.METADATA_SAFETY), { queryCapability: 'raw_sql' }))).toThrow(/saved-content or arbitrary-semantic/);
|
|
16
17
|
});
|
|
17
18
|
(0, vitest_1.it)('rejects row-level results', () => {
|
|
18
19
|
(0, vitest_1.expect)(() => (0, content_reader_js_1.assertContentReaderSafe)(Object.assign(Object.assign({}, content_reader_js_1.SAVED_EXECUTION_SAFETY), { resultCapability: 'row_level' }))).toThrow(/Row-level/);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Content
|
|
2
|
+
* Content response envelope helpers (RFC §10 / ADR-0006).
|
|
3
3
|
*/
|
|
4
|
+
import type { ProfileId } from '@lightdash-tools/common';
|
|
4
5
|
export type ContentReaderWarningCode = 'CACHE_STALE' | 'FILTER_IGNORED' | 'PARAMETER_DEFAULTED' | 'PARTIAL_RESULT' | 'QUERY_RUNNING' | 'QUERY_TIMEOUT' | 'REDACTED' | 'SQL_EXECUTION_DISABLED' | 'STALE_CONTENT' | 'TRUNCATED' | 'UNSUPPORTED_TILE' | 'UNVERIFIED_CONTENT';
|
|
5
6
|
export type ContentReaderWarning = {
|
|
6
7
|
code: ContentReaderWarningCode;
|
|
@@ -9,7 +10,7 @@ export type ContentReaderWarning = {
|
|
|
9
10
|
export type ContentReaderEnvelope<T> = {
|
|
10
11
|
data: T;
|
|
11
12
|
context: {
|
|
12
|
-
|
|
13
|
+
profile: ProfileId;
|
|
13
14
|
projectUuid: string;
|
|
14
15
|
projectPinned: boolean;
|
|
15
16
|
observedAt: string;
|
|
@@ -22,6 +23,7 @@ export type ContentReaderEnvelope<T> = {
|
|
|
22
23
|
warnings: ContentReaderWarning[];
|
|
23
24
|
};
|
|
24
25
|
export declare function contentReaderEnvelope<T>(data: T, opts: {
|
|
26
|
+
profile: ProfileId;
|
|
25
27
|
projectUuid: string;
|
|
26
28
|
projectPinned: boolean;
|
|
27
29
|
complete?: boolean;
|
package/dist/policy/envelope.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Content
|
|
3
|
+
* Content response envelope helpers (RFC §10 / ADR-0006).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.contentReaderEnvelope = contentReaderEnvelope;
|
|
@@ -9,7 +9,7 @@ function contentReaderEnvelope(data, opts) {
|
|
|
9
9
|
return {
|
|
10
10
|
data,
|
|
11
11
|
context: {
|
|
12
|
-
|
|
12
|
+
profile: opts.profile,
|
|
13
13
|
projectUuid: opts.projectUuid,
|
|
14
14
|
projectPinned: opts.projectPinned,
|
|
15
15
|
observedAt: new Date().toISOString(),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const envelope_js_1 = require("./envelope.js");
|
|
5
|
+
(0, vitest_1.describe)('contentReaderEnvelope', () => {
|
|
6
|
+
const baseOpts = {
|
|
7
|
+
projectUuid: '3dda11cb-aac8-42f7-82f1-26fa6b1afa80',
|
|
8
|
+
projectPinned: false,
|
|
9
|
+
};
|
|
10
|
+
(0, vitest_1.it)('stamps the required profile onto context', () => {
|
|
11
|
+
const reader = (0, envelope_js_1.contentReaderEnvelope)({ ok: true }, Object.assign(Object.assign({}, baseOpts), { profile: 'content-reader' }));
|
|
12
|
+
(0, vitest_1.expect)(reader.context.profile).toBe('content-reader');
|
|
13
|
+
(0, vitest_1.expect)(reader.context.projectUuid).toBe(baseOpts.projectUuid);
|
|
14
|
+
(0, vitest_1.expect)(reader.context.projectPinned).toBe(false);
|
|
15
|
+
(0, vitest_1.expect)(reader.data).toEqual({ ok: true });
|
|
16
|
+
const developer = (0, envelope_js_1.contentReaderEnvelope)({ ok: true }, Object.assign(Object.assign({}, baseOpts), { profile: 'content-developer' }));
|
|
17
|
+
(0, vitest_1.expect)(developer.context.profile).toBe('content-developer');
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.it)('preserves coverage and warnings options', () => {
|
|
20
|
+
const result = (0, envelope_js_1.contentReaderEnvelope)({ items: [] }, Object.assign(Object.assign({}, baseOpts), { profile: 'content-reader', complete: false, truncated: true, inaccessibleResources: ['x'], warnings: [{ code: 'TRUNCATED', message: 'cut' }] }));
|
|
21
|
+
(0, vitest_1.expect)(result.coverage).toEqual({
|
|
22
|
+
complete: false,
|
|
23
|
+
truncated: true,
|
|
24
|
+
inaccessibleResources: ['x'],
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.expect)(result.warnings).toEqual([{ code: 'TRUNCATED', message: 'cut' }]);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI agent-ops profile: thin Lightdash AI-agent API surface (ADR-0018).
|
|
3
|
+
*/
|
|
4
|
+
import type { ProfileDefinition } from '../../types.js';
|
|
5
|
+
export declare const AI_AGENT_OPS_PROFILE_PATH: "/ai-agent-ops/v1/mcp";
|
|
6
|
+
export declare const aiAgentOpsProfile: ProfileDefinition;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AI agent-ops profile: thin Lightdash AI-agent API surface (ADR-0018).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.aiAgentOpsProfile = exports.AI_AGENT_OPS_PROFILE_PATH = void 0;
|
|
7
|
+
const prompts_js_1 = require("./prompts.js");
|
|
8
|
+
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
9
|
+
exports.AI_AGENT_OPS_PROFILE_PATH = '/ai-agent-ops/v1/mcp';
|
|
10
|
+
exports.aiAgentOpsProfile = {
|
|
11
|
+
id: 'ai-agent-ops',
|
|
12
|
+
path: exports.AI_AGENT_OPS_PROFILE_PATH,
|
|
13
|
+
serverName: 'lightdash-mcp-aops',
|
|
14
|
+
registerPrompts: (server) => {
|
|
15
|
+
(0, prompts_js_1.registerAiAgentOpsPrompts)(server);
|
|
16
|
+
},
|
|
17
|
+
registerResources: (server) => {
|
|
18
|
+
(0, playbooks_js_1.registerAiAgentOpsPlaybook)(server);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerAiAgentOpsPrompts = registerAiAgentOpsPrompts;
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-deprecated -- matches other
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-deprecated -- matches other profile prompt registration */
|
|
8
8
|
const zod_1 = require("zod");
|
|
9
9
|
const playbook_resources_js_1 = require("../../lib/playbook-resources.js");
|
|
10
10
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
@@ -84,7 +84,7 @@ Prefer metadata fixes before instruction patches.`, 'loop-engineering'));
|
|
|
84
84
|
${playbooks_js_1.AI_AGENT_OPS_HARD_BANS}
|
|
85
85
|
|
|
86
86
|
Max iterations: ${maxIterations !== null && maxIterations !== void 0 ? maxIterations : '3'}.
|
|
87
|
-
Use MCP for inspect/eval runs; CLI agentops for bundle apply and gates; other
|
|
87
|
+
Use MCP for inspect/eval runs; CLI agentops for bundle apply and gates; other profiles for semantic/content when available.
|
|
88
88
|
Implementation changes happen outside agent CRUD on this server.
|
|
89
89
|
Stop when gates pass, no safe intervention remains, or the budget is exhausted.`, 'loop-engineering'));
|
|
90
90
|
server.registerPrompt('review_agent_access_and_scope', {
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* AI agent-ops prompt/playbook invariants.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const common_1 = require("@lightdash-tools/common");
|
|
6
7
|
const vitest_1 = require("vitest");
|
|
7
8
|
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
8
|
-
const index_js_1 = require("./index.js");
|
|
9
9
|
(0, vitest_1.describe)('ai-agent-ops prompts/playbook', () => {
|
|
10
10
|
(0, vitest_1.it)('playbook references only registered tool short ids', () => {
|
|
11
11
|
const md = (0, playbooks_js_1.getAllPlaybookMarkdown)();
|
|
12
|
-
for (const id of
|
|
12
|
+
for (const id of (0, common_1.listMcpToolNamesByProfile)('ai-agent-ops')) {
|
|
13
13
|
(0, vitest_1.expect)(md.includes(id) || md.includes(`lightdash_${id}`)).toBe(true);
|
|
14
14
|
}
|
|
15
15
|
(0, vitest_1.expect)(md).not.toMatch(/\bldt__/);
|
|
@@ -36,4 +36,4 @@ Never silently substitute readiness for an evaluation run.
|
|
|
36
36
|
1. MCP for Lightdash API evidence and product eval runs.
|
|
37
37
|
2. Host synthesizes failures and chooses interventions.
|
|
38
38
|
3. CLI `agentops` for bundles, drift, and gates.
|
|
39
|
-
4. Optional other MCP
|
|
39
|
+
4. Optional other MCP profiles (`semantic-layer`, `content-reader`) for metadata/content fixes.
|
|
@@ -7,7 +7,7 @@ URI: `lightdash://playbooks/ai-agent-ops/loop-engineering`
|
|
|
7
7
|
1. Snapshot intent: record agent UUID + version from `get_project_agent`
|
|
8
8
|
2. Baseline: product evaluation run via MCP
|
|
9
9
|
3. Analyze failures in the host (instruction vs tags vs semantic metadata vs access)
|
|
10
|
-
4. Intervene outside this
|
|
10
|
+
4. Intervene outside this profile:
|
|
11
11
|
- Semantic / AI hints → optional `semantic-layer` MCP or out-of-band
|
|
12
12
|
- Content → optional `content-reader` / developer workflows
|
|
13
13
|
- Agent config / eval suites as Git → CLI `agentops plan|apply`
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.AI_AGENT_OPS_TOPIC_PLAYBOOKS = exports.AI_AGENT_OPS_CORE_PLAYBOOK = exports.getAllPlaybookMarkdown = exports.AI_AGENT_OPS_HARD_BANS = void 0;
|
|
7
7
|
exports.registerAiAgentOpsPlaybook = registerAiAgentOpsPlaybook;
|
|
8
8
|
const playbook_resources_js_1 = require("../../../lib/playbook-resources.js");
|
|
9
|
-
const playbooks = (0, playbook_resources_js_1.
|
|
10
|
-
|
|
9
|
+
const playbooks = (0, playbook_resources_js_1.defineProfilePlaybooks)({
|
|
10
|
+
profileId: 'ai-agent-ops',
|
|
11
11
|
moduleDir: __dirname,
|
|
12
|
-
hardBans: 'Do not create/update/delete agents on this server, start or continue threads, mutate users/roles/semantic models/charts, run local offline scorers, write Git eval artifact stores via MCP, invent recommend_* or analyze_* mega-tools, or claim a CLI promotion gate passed from MCP run results alone. Those capabilities are not available as MCP mega-tools here — use CLI agentops / other
|
|
12
|
+
hardBans: 'Do not create/update/delete agents on this server, start or continue threads, mutate users/roles/semantic models/charts, run local offline scorers, write Git eval artifact stores via MCP, invent recommend_* or analyze_* mega-tools, or claim a CLI promotion gate passed from MCP run results alone. Those capabilities are not available as MCP mega-tools here — use CLI agentops / other profiles / the host.',
|
|
13
13
|
coreDescription: 'Hard bans, tool catalog, truth labels, and distributed loop rules',
|
|
14
14
|
topics: [
|
|
15
15
|
{
|
|
@@ -21,7 +21,7 @@ const playbooks = (0, playbook_resources_js_1.definePersonaPlaybooks)({
|
|
|
21
21
|
{
|
|
22
22
|
id: 'loop-engineering',
|
|
23
23
|
title: 'AI agent-ops loop-engineering playbook',
|
|
24
|
-
description: 'Host-driven improve loop across MCP, CLI, and other
|
|
24
|
+
description: 'Host-driven improve loop across MCP, CLI, and other profiles',
|
|
25
25
|
file: 'loop-engineering.md',
|
|
26
26
|
},
|
|
27
27
|
{
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-developer profile: project-scoped chart/dashboard authoring (ADR-0014).
|
|
3
|
+
* Hybrid authoring behind a hard preview -> validate -> apply gate; no SQL, no delete,
|
|
4
|
+
* no space create/update (spaces are Terraform / out-of-band).
|
|
5
|
+
*/
|
|
6
|
+
import type { ProfileDefinition } from '../../types.js';
|
|
7
|
+
export declare const CONTENT_DEVELOPER_PROFILE_PATH: "/content-developer/v1/mcp";
|
|
8
|
+
export declare const contentDeveloperProfile: ProfileDefinition;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Content-developer profile: project-scoped chart/dashboard authoring (ADR-0014).
|
|
4
|
+
* Hybrid authoring behind a hard preview -> validate -> apply gate; no SQL, no delete,
|
|
5
|
+
* no space create/update (spaces are Terraform / out-of-band).
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.contentDeveloperProfile = exports.CONTENT_DEVELOPER_PROFILE_PATH = void 0;
|
|
9
|
+
const prompts_js_1 = require("./prompts.js");
|
|
10
|
+
const playbooks_js_1 = require("./resources/playbooks.js");
|
|
11
|
+
exports.CONTENT_DEVELOPER_PROFILE_PATH = '/content-developer/v1/mcp';
|
|
12
|
+
exports.contentDeveloperProfile = {
|
|
13
|
+
id: 'content-developer',
|
|
14
|
+
path: exports.CONTENT_DEVELOPER_PROFILE_PATH,
|
|
15
|
+
serverName: 'lightdash-mcp-cdev',
|
|
16
|
+
registerPrompts: (server) => {
|
|
17
|
+
(0, prompts_js_1.registerContentDeveloperPrompts)(server);
|
|
18
|
+
},
|
|
19
|
+
registerResources: (server) => {
|
|
20
|
+
(0, playbooks_js_1.registerContentDeveloperPlaybook)(server);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -53,8 +53,8 @@ Chart hints: ${chartReferences !== null && chartReferences !== void 0 ? chartRef
|
|
|
53
53
|
|
|
54
54
|
1. If the goal is vague on audience / decisions / what to understand: ask **2–4 clarifying questions** before a Spec (do not invent a viz-type checklist).
|
|
55
55
|
2. Read-only discovery only (project/space/seeds).
|
|
56
|
-
3. ${DESIGN_SPEC_STOP} Multi-viz / all chart types only if the user explicitly asked (see dashboards + chart-types playbooks).
|
|
57
|
-
4. After approval: follow embedded playbooks (preview→confirm→apply).
|
|
56
|
+
3. ${DESIGN_SPEC_STOP} Multi-viz / all chart types only if the user explicitly asked (see dashboards + chart-types playbooks). For explicit all-types work, keep primary insights decision-oriented and place redundant required forms in a labeled validation appendix; never weaken semantic field requirements.
|
|
57
|
+
4. After approval: follow embedded playbooks (preview→confirm→apply; reuse the **exact** preview payload on apply — do not tidy description/name between confirm and create).
|
|
58
58
|
5. Report dashboard UUID/slug, tiles, filters, chart UUIDs — reject space-only orphans or untiled dashboard-owned charts.`, DASHBOARD_CHART_TOPIC_IDS));
|
|
59
59
|
server.registerPrompt('improve_dashboard', {
|
|
60
60
|
title: 'Improve dashboard',
|
|
@@ -75,7 +75,7 @@ ${playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS}
|
|
|
75
75
|
1. Inspect with lightdash_get_dashboard first (tile x/y/w/h may be missing — rebuild layout intentionally).
|
|
76
76
|
2. If the improvement goal is vague on decisions / insights: ask **2–4 clarifying questions** before a Spec delta.
|
|
77
77
|
3. For material layout/tile/filter changes (including professionalize): ${DESIGN_SPEC_STOP} Use the **Improve / professionalize Spec delta** (keep / drop / rename + cull) in dashboard-design. Trivial one-shot renames the user already specified may skip the stop. Multi-viz / all chart types only if the user explicitly asked.
|
|
78
|
-
4. After approval: follow embedded playbooks. New charts: get_chart_as_code + dashboardSlug, then tile. Rename tile titles and chart names when stripping demo prefixes.
|
|
78
|
+
4. After approval: follow embedded playbooks (reuse the **exact** preview payload on apply). New charts: get_chart_as_code + dashboardSlug, then tile. Rename tile titles and chart names when stripping demo prefixes.
|
|
79
79
|
Report what changed (tiles, filters, chart UUIDs), any untiled dashboard-owned leftovers (content-governance for soft-delete), and validation warnings.`, DASHBOARD_CHART_TOPIC_IDS));
|
|
80
80
|
server.registerPrompt('refactor_dashboard', {
|
|
81
81
|
title: 'Refactor dashboard',
|
|
@@ -116,7 +116,7 @@ ${playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS}
|
|
|
116
116
|
|
|
117
117
|
Follow core + chart-types (clone via get_chart_as_code; preview with top-level slug; keep customDimensions when needed; tile if dashboardSlug set).
|
|
118
118
|
When dashboardSlug is set, the chart must serve a **board insight** from the approved Design Spec — do not invent a viz type for its own sake.
|
|
119
|
-
Report UUID/slug from charts[0].data; note this
|
|
119
|
+
Report UUID/slug from charts[0].data; note this profile cannot run_chart / prove UI render.`, TOPIC_CHART_TYPES));
|
|
120
120
|
server.registerPrompt('move_content', {
|
|
121
121
|
title: 'Move content',
|
|
122
122
|
description: 'Move charts/dashboards into an existing space (no space create/update)',
|
|
@@ -151,7 +151,7 @@ Project UUID: ${projectUuid !== null && projectUuid !== void 0 ? projectUuid : P
|
|
|
151
151
|
|
|
152
152
|
${playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS}
|
|
153
153
|
|
|
154
|
-
Done checklist: markdown/description states the **Objective**; tiles map to approved insight questions; every saved filter matches each tile explore or has explicit tileTargets exclude/remap; dashboardSlug on new charts + tiles present; cartesian encode intact; no invented fieldIds. Report untiled dashboard-owned leftovers (soft-delete via content-governance). Follow embedded playbooks for encode/map/filter detail. UI runtime not verified on this
|
|
155
|
-
Optionally validate_* (schema/health only). Promote is content-governance, not this
|
|
154
|
+
Done checklist: markdown/description states the **Objective**; tiles map to approved insight questions; every saved filter matches each tile explore or has explicit tileTargets exclude/remap; dashboardSlug on new charts + tiles present; cartesian encode intact; no invented fieldIds. Report untiled dashboard-owned leftovers (soft-delete via content-governance). Follow embedded playbooks for encode/map/filter detail. UI runtime not verified on this profile.
|
|
155
|
+
Optionally validate_* (schema/health only). Promote is content-governance, not this profile.`, DASHBOARD_PUBLISH_TOPIC_IDS));
|
|
156
156
|
}
|
|
157
157
|
/* eslint-enable @typescript-eslint/no-deprecated */
|