@lightdash-tools/mcp 0.16.1 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +13 -3
  2. package/dist/auth/oauth-broker/as-metadata.d.ts +6 -2
  3. package/dist/auth/oauth-broker/as-metadata.js +8 -4
  4. package/dist/auth/oauth-broker/invoke-origins.d.ts +16 -0
  5. package/dist/auth/oauth-broker/invoke-origins.js +112 -0
  6. package/dist/auth/oauth-broker/invoke-origins.test.d.ts +1 -0
  7. package/dist/auth/oauth-broker/invoke-origins.test.js +82 -0
  8. package/dist/auth/oauth-broker/routes.js +33 -9
  9. package/dist/auth/oauth-broker/routes.test.js +110 -3
  10. package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +1 -1
  11. package/dist/auth/resource-server/lightdash-oauth-middleware.js +8 -5
  12. package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +36 -2
  13. package/dist/auth/resource-server/oauth-protected-resource.d.ts +2 -2
  14. package/dist/auth/resource-server/oauth-protected-resource.js +8 -11
  15. package/dist/auth/resource-server/www-authenticate.test.js +3 -3
  16. package/dist/config/env.d.ts +5 -0
  17. package/dist/config/env.js +6 -1
  18. package/dist/config/load-mcp-config.d.ts +2 -0
  19. package/dist/config/load-mcp-config.js +18 -0
  20. package/dist/config/load-mcp-config.test.js +29 -0
  21. package/dist/config/test-mcp-http-config.js +1 -1
  22. package/dist/http.integration.helpers.d.ts +50 -0
  23. package/dist/http.integration.helpers.js +190 -0
  24. package/dist/http.integration.test.js +57 -198
  25. package/dist/http.invoke-origin.integration.test.d.ts +1 -0
  26. package/dist/http.invoke-origin.integration.test.js +108 -0
  27. package/dist/policy/envelope.d.ts +1 -1
  28. package/dist/profiles/content-reader/v1/invariants.d.ts +1 -1
  29. package/dist/profiles/content-reader/v1/invariants.js +1 -1
  30. package/dist/profiles/content-reader/v1/resources/playbooks/compare.md +1 -1
  31. package/dist/profiles/content-reader/v1/resources/playbooks/core.md +2 -2
  32. package/dist/profiles/content-reader/v1/resources/playbooks/discover.md +1 -1
  33. package/dist/profiles/content-reader/v1/resources/playbooks/explain-run.md +13 -11
  34. package/dist/tools/project/projects.js +1 -0
  35. package/dist/tools/project/projects.test.js +1 -0
  36. package/dist/tools/project/reader-content.d.ts +40 -0
  37. package/dist/tools/project/reader-content.js +18 -2
  38. package/dist/tools/project/reader-content.test.d.ts +1 -1
  39. package/dist/tools/project/reader-content.test.js +77 -1
  40. package/dist/tools/project/reader-execution.d.ts +1 -1
  41. package/dist/tools/project/reader-execution.js +127 -68
  42. package/dist/tools/project/reader-execution.test.d.ts +4 -0
  43. package/dist/tools/project/reader-execution.test.js +246 -0
  44. package/dist/tools/query/filter-overrides.d.ts +1 -1
  45. package/dist/transports/streamable-http.js +3 -1
  46. package/dist/transports/streamable-http.test.js +8 -3
  47. package/package.json +3 -3
@@ -4,152 +4,11 @@ const node_http_1 = require("node:http");
4
4
  const client_1 = require("@lightdash-tools/client");
5
5
  const server_1 = require("@modelcontextprotocol/server");
6
6
  const vitest_1 = require("vitest");
7
- const mcp_access_token_js_1 = require("./auth/oauth-broker/mcp-access-token.js");
8
7
  const oauth_protected_resource_js_1 = require("./auth/resource-server/oauth-protected-resource.js");
9
8
  const enabled_profiles_js_1 = require("./config/enabled-profiles.js");
10
9
  const test_mcp_http_config_js_1 = require("./config/test-mcp-http-config.js");
10
+ const http_integration_helpers_js_1 = require("./http.integration.helpers.js");
11
11
  const streamable_http_js_1 = require("./transports/streamable-http.js");
12
- // These constants model downstream Lightdash credentials only. MCP clients never send
13
- // them directly after ADR-0026; tests wrap them in broker-issued MCP access tokens.
14
- const TOKEN_A = scopedAccessToken('mcp:read mcp:write', 'token-a');
15
- const TOKEN_B = scopedAccessToken('mcp:read mcp:write', 'token-b');
16
- const TOKEN_READ_ONLY = scopedAccessToken('mcp:read', 'token-read-only');
17
- const OPAQUE_TOKEN_A = 'opaque-token-user-a';
18
- const USER_A = { userUuid: 'user-a-uuid', email: 'a@example.com', organizationUuid: 'org-a-uuid' };
19
- const USER_B = { userUuid: 'user-b-uuid', email: 'b@example.com', organizationUuid: 'org-b-uuid' };
20
- function scopedAccessToken(scope, subject) {
21
- const header = Buffer.from(JSON.stringify({ alg: 'none', typ: 'JWT' })).toString('base64url');
22
- const payload = Buffer.from(JSON.stringify({ scope, sub: subject })).toString('base64url');
23
- return `${header}.${payload}.signature`;
24
- }
25
- const INITIALIZE_BODY = {
26
- jsonrpc: '2.0',
27
- method: 'initialize',
28
- params: {
29
- protocolVersion: '2024-11-05',
30
- capabilities: {},
31
- clientInfo: { name: 'integration-test', version: '1.0.0' },
32
- },
33
- id: 1,
34
- };
35
- function listen(server, port, host) {
36
- return new Promise((resolve, reject) => {
37
- server.once('error', reject);
38
- server.listen(port, host, () => {
39
- server.removeListener('error', reject);
40
- resolve();
41
- });
42
- });
43
- }
44
- async function startMockLightdashServer() {
45
- const authorizationHeaders = [];
46
- const users = {
47
- [TOKEN_A]: USER_A,
48
- [TOKEN_B]: USER_B,
49
- [TOKEN_READ_ONLY]: USER_A,
50
- [OPAQUE_TOKEN_A]: USER_A,
51
- };
52
- let issuerBaseUrl = '';
53
- const server = (0, node_http_1.createServer)((req, res) => {
54
- var _a;
55
- const authHeader = req.headers.authorization;
56
- const auth = typeof authHeader === 'string' ? authHeader : ((_a = authHeader === null || authHeader === void 0 ? void 0 : authHeader[0]) !== null && _a !== void 0 ? _a : '');
57
- authorizationHeaders.push(auth);
58
- if (req.method === 'GET' && req.url === '/.well-known/oauth-authorization-server') {
59
- res.writeHead(200, { 'Content-Type': 'application/json' }).end(JSON.stringify({
60
- issuer: issuerBaseUrl,
61
- authorization_endpoint: `${issuerBaseUrl}/api/v1/oauth/authorize`,
62
- token_endpoint: `${issuerBaseUrl}/api/v1/oauth/token`,
63
- revocation_endpoint: `${issuerBaseUrl}/api/v1/oauth/revoke`,
64
- registration_endpoint: `${issuerBaseUrl}/api/v1/oauth/register`,
65
- userinfo_endpoint: `${issuerBaseUrl}/api/v1/oauth/userinfo`,
66
- }));
67
- return;
68
- }
69
- if (req.method === 'GET' && req.url === '/api/v1/user') {
70
- const token = auth.startsWith('Bearer ') ? auth.slice('Bearer '.length).trim() : '';
71
- const user = users[token];
72
- if (!user) {
73
- res.writeHead(401, { 'Content-Type': 'application/json' }).end(JSON.stringify({
74
- status: 'error',
75
- error: { statusCode: 401, name: 'Unauthorized', message: 'Invalid token' },
76
- }));
77
- return;
78
- }
79
- res
80
- .writeHead(200, { 'Content-Type': 'application/json' })
81
- .end(JSON.stringify({ status: 'ok', results: user }));
82
- return;
83
- }
84
- if (req.method === 'GET' && req.url === '/api/v1/org/projects') {
85
- const token = auth.startsWith('Bearer ') ? auth.slice('Bearer '.length).trim() : '';
86
- if (!users[token]) {
87
- res.writeHead(401, { 'Content-Type': 'application/json' }).end(JSON.stringify({
88
- status: 'error',
89
- error: { statusCode: 401, name: 'Unauthorized', message: 'Invalid token' },
90
- }));
91
- return;
92
- }
93
- res.writeHead(200, { 'Content-Type': 'application/json' }).end(JSON.stringify({
94
- status: 'ok',
95
- results: [
96
- {
97
- projectUuid: 'project-a-uuid',
98
- name: 'Project A',
99
- type: 'DEFAULT',
100
- },
101
- ],
102
- }));
103
- return;
104
- }
105
- res.writeHead(404).end();
106
- });
107
- await listen(server, 0, '127.0.0.1');
108
- const address = server.address();
109
- issuerBaseUrl = `http://127.0.0.1:${address.port}`;
110
- return {
111
- baseUrl: issuerBaseUrl,
112
- authorizationHeaders,
113
- close: () => new Promise((resolve, reject) => {
114
- server.close((err) => {
115
- if (err)
116
- reject(err);
117
- else
118
- resolve();
119
- });
120
- }),
121
- };
122
- }
123
- function baseOAuthConfig(lightdashUrl, overrides) {
124
- return (0, test_mcp_http_config_js_1.makeTestMcpHttpConfig)(Object.assign({ lightdashUrl, port: 0, publicUrl: 'http://127.0.0.1:0', oauthClientId: 'test-client-id', oauthClientSecret: new client_1.SecretString('test-client-secret'), maxBodyBytes: 1024 * 1024, requiredScopes: [], scopesSupported: [] }, overrides));
125
- }
126
- function brokerAccessToken(mcpBaseUrl, lightdashAccessToken, options = {}) {
127
- var _a;
128
- const path = (_a = options.path) !== null && _a !== void 0 ? _a : '/semantic-layer/v1/mcp';
129
- return (0, mcp_access_token_js_1.mintMcpAccessToken)(baseOAuthConfig('https://lightdash.invalid'), {
130
- lightdashAccessToken,
131
- clientId: 'integration-test-client',
132
- resource: `${mcpBaseUrl}${path}`,
133
- scope: options.scope,
134
- expiresAtMs: Date.now() + 60000,
135
- }).accessToken;
136
- }
137
- async function postMcp(baseUrl, body, options) {
138
- var _a;
139
- const headers = {
140
- 'Content-Type': 'application/json',
141
- Accept: 'application/json, text/event-stream',
142
- };
143
- if (options === null || options === void 0 ? void 0 : options.token) {
144
- headers.Authorization = `Bearer ${options.token}`;
145
- }
146
- const path = (_a = options === null || options === void 0 ? void 0 : options.path) !== null && _a !== void 0 ? _a : '/semantic-layer/v1/mcp';
147
- return fetch(`${baseUrl}${path}`, {
148
- method: 'POST',
149
- headers,
150
- body: JSON.stringify(body),
151
- });
152
- }
153
12
  function parseSseOrJsonToolText(raw) {
154
13
  if (raw.includes('data:')) {
155
14
  const lines = raw
@@ -166,8 +25,8 @@ function parseSseOrJsonToolText(raw) {
166
25
  (0, vitest_1.beforeEach)(async () => {
167
26
  vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
168
27
  vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
169
- mockLightdash = await startMockLightdashServer();
170
- mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, baseOAuthConfig(mockLightdash.baseUrl)));
28
+ mockLightdash = await (0, http_integration_helpers_js_1.startMockLightdashServer)();
29
+ mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, (0, http_integration_helpers_js_1.baseOAuthConfig)(mockLightdash.baseUrl)));
171
30
  });
172
31
  (0, vitest_1.afterEach)(async () => {
173
32
  await mcpServer.close();
@@ -175,7 +34,7 @@ function parseSseOrJsonToolText(raw) {
175
34
  vitest_1.vi.restoreAllMocks();
176
35
  });
177
36
  (0, vitest_1.it)('returns 401 with WWW-Authenticate resource_metadata when OAuth token is missing', async () => {
178
- const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY);
37
+ const response = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY);
179
38
  (0, vitest_1.expect)(response.status).toBe(401);
180
39
  const wwwAuthenticate = response.headers.get('www-authenticate');
181
40
  (0, vitest_1.expect)(wwwAuthenticate).toContain('resource_metadata=');
@@ -183,20 +42,20 @@ function parseSseOrJsonToolText(raw) {
183
42
  });
184
43
  (0, vitest_1.it)('returns 401 without echoing invalid bearer token in response body', async () => {
185
44
  const invalidToken = 'not-a-valid-token';
186
- const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: invalidToken });
45
+ const response = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, { token: invalidToken });
187
46
  (0, vitest_1.expect)(response.status).toBe(401);
188
47
  const body = await response.text();
189
48
  (0, vitest_1.expect)(body).not.toContain(invalidToken);
190
49
  (0, vitest_1.expect)(response.headers.get('www-authenticate')).toContain('invalid_token');
191
50
  });
192
51
  (0, vitest_1.it)('handles initialize with an MCP bearer and validates the downstream Lightdash bearer', async () => {
193
- const mcpToken = brokerAccessToken(mcpServer.baseUrl, TOKEN_A);
194
- const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: mcpToken });
52
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_A);
53
+ const response = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, { token: mcpToken });
195
54
  (0, vitest_1.expect)(response.status).toBe(200);
196
55
  // Sessionless: no session-id header is set.
197
56
  (0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeFalsy();
198
- (0, vitest_1.expect)(mcpToken).not.toBe(TOKEN_A);
199
- (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
57
+ (0, vitest_1.expect)(mcpToken).not.toBe(http_integration_helpers_js_1.TOKEN_A);
58
+ (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${http_integration_helpers_js_1.TOKEN_A}`);
200
59
  (0, vitest_1.expect)(mockLightdash.authorizationHeaders).not.toContain(`Bearer ${mcpToken}`);
201
60
  });
202
61
  (0, vitest_1.it)('returns 401 before parsing malformed JSON when OAuth token is missing', async () => {
@@ -212,14 +71,14 @@ function parseSseOrJsonToolText(raw) {
212
71
  (0, vitest_1.expect)(response.headers.get('www-authenticate')).toContain('resource_metadata=');
213
72
  });
214
73
  (0, vitest_1.it)('returns 401 invalid_token for invalid bearer before accepting valid JSON', async () => {
215
- const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
74
+ const response = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, {
216
75
  token: 'not-a-valid-token',
217
76
  });
218
77
  (0, vitest_1.expect)(response.status).toBe(401);
219
78
  (0, vitest_1.expect)(response.headers.get('www-authenticate')).toContain('invalid_token');
220
79
  });
221
80
  (0, vitest_1.it)('returns 400 for malformed JSON only after successful OAuth authentication', async () => {
222
- const mcpToken = brokerAccessToken(mcpServer.baseUrl, TOKEN_A);
81
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_A);
223
82
  const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
224
83
  method: 'POST',
225
84
  headers: {
@@ -271,7 +130,7 @@ function parseSseOrJsonToolText(raw) {
271
130
  const response = await fetch(`${mcpServer.baseUrl}/organization-audit/v1/mcp`, {
272
131
  method: 'POST',
273
132
  headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
274
- body: JSON.stringify(INITIALIZE_BODY),
133
+ body: JSON.stringify(http_integration_helpers_js_1.INITIALIZE_BODY),
275
134
  });
276
135
  (0, vitest_1.expect)(response.status).toBe(401);
277
136
  const wwwAuthenticate = response.headers.get('www-authenticate');
@@ -282,7 +141,7 @@ function parseSseOrJsonToolText(raw) {
282
141
  const response = await fetch(`${mcpServer.baseUrl}/content-reader/v1/mcp`, {
283
142
  method: 'POST',
284
143
  headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
285
- body: JSON.stringify(INITIALIZE_BODY),
144
+ body: JSON.stringify(http_integration_helpers_js_1.INITIALIZE_BODY),
286
145
  });
287
146
  (0, vitest_1.expect)(response.status).toBe(401);
288
147
  const wwwAuthenticate = response.headers.get('www-authenticate');
@@ -293,7 +152,7 @@ function parseSseOrJsonToolText(raw) {
293
152
  const response = await fetch(`${mcpServer.baseUrl}/content-governance/v1/mcp`, {
294
153
  method: 'POST',
295
154
  headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
296
- body: JSON.stringify(INITIALIZE_BODY),
155
+ body: JSON.stringify(http_integration_helpers_js_1.INITIALIZE_BODY),
297
156
  });
298
157
  (0, vitest_1.expect)(response.status).toBe(401);
299
158
  const wwwAuthenticate = response.headers.get('www-authenticate');
@@ -301,21 +160,21 @@ function parseSseOrJsonToolText(raw) {
301
160
  (0, vitest_1.expect)(wwwAuthenticate).not.toContain('semantic-layer/v1/mcp');
302
161
  });
303
162
  (0, vitest_1.it)('maps two MCP tokens to distinct authenticated users upstream', async () => {
304
- const mcpTokenA = brokerAccessToken(mcpServer.baseUrl, TOKEN_A);
305
- const mcpTokenB = brokerAccessToken(mcpServer.baseUrl, TOKEN_B);
306
- const responseA = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: mcpTokenA });
307
- const responseB = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: mcpTokenB });
163
+ const mcpTokenA = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_A);
164
+ const mcpTokenB = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_B);
165
+ const responseA = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, { token: mcpTokenA });
166
+ const responseB = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, { token: mcpTokenB });
308
167
  (0, vitest_1.expect)(responseA.status).toBe(200);
309
168
  (0, vitest_1.expect)(responseB.status).toBe(200);
310
- (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
311
- (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_B}`);
169
+ (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${http_integration_helpers_js_1.TOKEN_A}`);
170
+ (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${http_integration_helpers_js_1.TOKEN_B}`);
312
171
  (0, vitest_1.expect)(mockLightdash.authorizationHeaders).not.toContain(`Bearer ${mcpTokenA}`);
313
172
  (0, vitest_1.expect)(mockLightdash.authorizationHeaders).not.toContain(`Bearer ${mcpTokenB}`);
314
173
  });
315
174
  (0, vitest_1.it)('accepts form-elicitation caps from per-request _meta on content-governance tools/call', async () => {
316
175
  const governancePath = '/content-governance/v1/mcp';
317
- const mcpToken = brokerAccessToken(mcpServer.baseUrl, TOKEN_A, { path: governancePath });
318
- const call = await postMcp(mcpServer.baseUrl, {
176
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_A, { path: governancePath });
177
+ const call = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, {
319
178
  jsonrpc: '2.0',
320
179
  method: 'tools/call',
321
180
  params: {
@@ -343,13 +202,13 @@ function parseSseOrJsonToolText(raw) {
343
202
  error: { statusCode: 503, name: 'ServiceUnavailable', message: 'Down' },
344
203
  }));
345
204
  });
346
- await listen(unavailableServer, 0, '127.0.0.1');
205
+ await (0, http_integration_helpers_js_1.listen)(unavailableServer, 0, '127.0.0.1');
347
206
  const unavailableAddress = unavailableServer.address();
348
207
  const unavailableUrl = `http://127.0.0.1:${unavailableAddress.port}`;
349
- const downServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, baseOAuthConfig(unavailableUrl)));
208
+ const downServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, (0, http_integration_helpers_js_1.baseOAuthConfig)(unavailableUrl)));
350
209
  try {
351
- const mcpToken = brokerAccessToken(downServer.baseUrl, TOKEN_A);
352
- const response = await postMcp(downServer.baseUrl, INITIALIZE_BODY, { token: mcpToken });
210
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(downServer.baseUrl, http_integration_helpers_js_1.TOKEN_A);
211
+ const response = await (0, http_integration_helpers_js_1.postMcp)(downServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, { token: mcpToken });
353
212
  (0, vitest_1.expect)(response.status).toBe(503);
354
213
  (0, vitest_1.expect)(await response.json()).toEqual({
355
214
  error: 'temporarily_unavailable',
@@ -375,8 +234,8 @@ function parseSseOrJsonToolText(raw) {
375
234
  (0, vitest_1.beforeEach)(async () => {
376
235
  vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
377
236
  vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
378
- mockLightdash = await startMockLightdashServer();
379
- mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, baseOAuthConfig(mockLightdash.baseUrl)));
237
+ mockLightdash = await (0, http_integration_helpers_js_1.startMockLightdashServer)();
238
+ mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, (0, http_integration_helpers_js_1.baseOAuthConfig)(mockLightdash.baseUrl)));
380
239
  });
381
240
  (0, vitest_1.afterEach)(async () => {
382
241
  await mcpServer.close();
@@ -398,38 +257,38 @@ function parseSseOrJsonToolText(raw) {
398
257
  (0, vitest_1.expect)(asMetadata.registration_endpoint).toBe(`${mcpServer.baseUrl}/oauth/register`);
399
258
  });
400
259
  (0, vitest_1.it)('handles initialize when the downstream Lightdash credential is opaque', async () => {
401
- const mcpToken = brokerAccessToken(mcpServer.baseUrl, OPAQUE_TOKEN_A);
402
- const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: mcpToken });
260
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.OPAQUE_TOKEN_A);
261
+ const response = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, { token: mcpToken });
403
262
  (0, vitest_1.expect)(response.status).toBe(200);
404
263
  (0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeFalsy();
405
- (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${OPAQUE_TOKEN_A}`);
264
+ (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${http_integration_helpers_js_1.OPAQUE_TOKEN_A}`);
406
265
  (0, vitest_1.expect)(mockLightdash.authorizationHeaders).not.toContain(`Bearer ${mcpToken}`);
407
266
  });
408
267
  (0, vitest_1.it)('accepts an MCP token carrying mcp:read scope on initialize', async () => {
409
- const mcpToken = brokerAccessToken(mcpServer.baseUrl, TOKEN_READ_ONLY, { scope: 'mcp:read' });
410
- const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
268
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_READ_ONLY, { scope: 'mcp:read' });
269
+ const response = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, {
411
270
  token: mcpToken,
412
271
  });
413
272
  (0, vitest_1.expect)(response.status).toBe(200);
414
- (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_READ_ONLY}`);
273
+ (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${http_integration_helpers_js_1.TOKEN_READ_ONLY}`);
415
274
  });
416
275
  (0, vitest_1.it)('accepts an MCP token carrying mcp:read mcp:write scope on initialize', async () => {
417
- const mcpToken = brokerAccessToken(mcpServer.baseUrl, TOKEN_A, {
276
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_A, {
418
277
  scope: 'mcp:read mcp:write',
419
278
  });
420
- const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
279
+ const response = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, {
421
280
  token: mcpToken,
422
281
  });
423
282
  (0, vitest_1.expect)(response.status).toBe(200);
424
- (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${TOKEN_A}`);
283
+ (0, vitest_1.expect)(mockLightdash.authorizationHeaders).toContain(`Bearer ${http_integration_helpers_js_1.TOKEN_A}`);
425
284
  });
426
285
  (0, vitest_1.it)('forwards only the decrypted downstream bearer to Lightdash', async () => {
427
- const mcpToken = brokerAccessToken(mcpServer.baseUrl, OPAQUE_TOKEN_A);
428
- const response = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
286
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.OPAQUE_TOKEN_A);
287
+ const response = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, {
429
288
  token: mcpToken,
430
289
  });
431
290
  (0, vitest_1.expect)(response.status).toBe(200);
432
- const downstreamHeaders = mockLightdash.authorizationHeaders.filter((header) => header === `Bearer ${OPAQUE_TOKEN_A}`);
291
+ const downstreamHeaders = mockLightdash.authorizationHeaders.filter((header) => header === `Bearer ${http_integration_helpers_js_1.OPAQUE_TOKEN_A}`);
433
292
  (0, vitest_1.expect)(downstreamHeaders.length).toBeGreaterThan(0);
434
293
  (0, vitest_1.expect)(mockLightdash.authorizationHeaders).not.toContain(`Bearer ${mcpToken}`);
435
294
  });
@@ -440,8 +299,8 @@ function parseSseOrJsonToolText(raw) {
440
299
  (0, vitest_1.beforeEach)(async () => {
441
300
  vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
442
301
  vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
443
- mockLightdash = await startMockLightdashServer();
444
- mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign(Object.assign({}, baseOAuthConfig(mockLightdash.baseUrl)), { allowedOrigins: ['https://app.example.com'] }));
302
+ mockLightdash = await (0, http_integration_helpers_js_1.startMockLightdashServer)();
303
+ mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign(Object.assign({}, (0, http_integration_helpers_js_1.baseOAuthConfig)(mockLightdash.baseUrl)), { allowedOrigins: ['https://app.example.com'] }));
445
304
  });
446
305
  (0, vitest_1.afterEach)(async () => {
447
306
  await mcpServer.close();
@@ -483,8 +342,8 @@ function parseSseOrJsonToolText(raw) {
483
342
  (0, vitest_1.beforeEach)(async () => {
484
343
  vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
485
344
  vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
486
- mockLightdash = await startMockLightdashServer();
487
- mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign(Object.assign({}, baseOAuthConfig(mockLightdash.baseUrl)), { maxBodyBytes: 512 }));
345
+ mockLightdash = await (0, http_integration_helpers_js_1.startMockLightdashServer)();
346
+ mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign(Object.assign({}, (0, http_integration_helpers_js_1.baseOAuthConfig)(mockLightdash.baseUrl)), { maxBodyBytes: 512 }));
488
347
  });
489
348
  (0, vitest_1.afterEach)(async () => {
490
349
  await mcpServer.close();
@@ -492,8 +351,8 @@ function parseSseOrJsonToolText(raw) {
492
351
  vitest_1.vi.restoreAllMocks();
493
352
  });
494
353
  (0, vitest_1.it)('returns 413 for oversized JSON body after OAuth authentication', async () => {
495
- const hugeBody = JSON.stringify(Object.assign(Object.assign({}, INITIALIZE_BODY), { params: Object.assign(Object.assign({}, INITIALIZE_BODY.params), { padding: 'x'.repeat(1024) }) }));
496
- const mcpToken = brokerAccessToken(mcpServer.baseUrl, TOKEN_A);
354
+ const hugeBody = JSON.stringify(Object.assign(Object.assign({}, http_integration_helpers_js_1.INITIALIZE_BODY), { params: Object.assign(Object.assign({}, http_integration_helpers_js_1.INITIALIZE_BODY.params), { padding: 'x'.repeat(1024) }) }));
355
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_A);
497
356
  const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
498
357
  method: 'POST',
499
358
  headers: {
@@ -511,7 +370,7 @@ function parseSseOrJsonToolText(raw) {
511
370
  method: 'GET',
512
371
  headers: {
513
372
  Accept: 'application/json, text/event-stream',
514
- Authorization: `Bearer ${TOKEN_A}`,
373
+ Authorization: `Bearer ${http_integration_helpers_js_1.TOKEN_A}`,
515
374
  },
516
375
  });
517
376
  (0, vitest_1.expect)(response.status).toBe(405);
@@ -520,7 +379,7 @@ function parseSseOrJsonToolText(raw) {
520
379
  const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
521
380
  method: 'DELETE',
522
381
  headers: {
523
- Authorization: `Bearer ${TOKEN_A}`,
382
+ Authorization: `Bearer ${http_integration_helpers_js_1.TOKEN_A}`,
524
383
  },
525
384
  });
526
385
  (0, vitest_1.expect)(response.status).toBe(405);
@@ -532,8 +391,8 @@ function parseSseOrJsonToolText(raw) {
532
391
  (0, vitest_1.beforeEach)(async () => {
533
392
  vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
534
393
  vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
535
- mockLightdash = await startMockLightdashServer();
536
- mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(baseOAuthConfig(mockLightdash.baseUrl, {
394
+ mockLightdash = await (0, http_integration_helpers_js_1.startMockLightdashServer)();
395
+ mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)((0, http_integration_helpers_js_1.baseOAuthConfig)(mockLightdash.baseUrl, {
537
396
  enabledProfiles: (0, enabled_profiles_js_1.parseEnabledProfiles)('content-reader'),
538
397
  }));
539
398
  });
@@ -543,15 +402,15 @@ function parseSseOrJsonToolText(raw) {
543
402
  vitest_1.vi.restoreAllMocks();
544
403
  });
545
404
  (0, vitest_1.it)('404s disabled profile MCP paths and their path-specific PRM', async () => {
546
- const mcpResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, { token: TOKEN_A });
405
+ const mcpResponse = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, { token: http_integration_helpers_js_1.TOKEN_A });
547
406
  (0, vitest_1.expect)(mcpResponse.status).toBe(404);
548
407
  const prmResponse = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource/semantic-layer/v1/mcp`);
549
408
  (0, vitest_1.expect)(prmResponse.status).toBe(404);
550
409
  });
551
410
  (0, vitest_1.it)('keeps enabled profile MCP and PRM reachable', async () => {
552
411
  const contentReaderPath = '/content-reader/v1/mcp';
553
- const mcpToken = brokerAccessToken(mcpServer.baseUrl, TOKEN_A, { path: contentReaderPath });
554
- const mcpResponse = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
412
+ const mcpToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_A, { path: contentReaderPath });
413
+ const mcpResponse = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, {
555
414
  token: mcpToken,
556
415
  path: contentReaderPath,
557
416
  });
@@ -593,9 +452,9 @@ function parseSseOrJsonToolText(raw) {
593
452
  vitest_1.vi.restoreAllMocks();
594
453
  });
595
454
  (0, vitest_1.it)('requires shared key on MCP endpoint', async () => {
596
- const unauthorized = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY);
455
+ const unauthorized = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY);
597
456
  (0, vitest_1.expect)(unauthorized.status).toBe(401);
598
- const authorized = await postMcp(mcpServer.baseUrl, INITIALIZE_BODY, {
457
+ const authorized = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, {
599
458
  token: 'shared-secret',
600
459
  });
601
460
  (0, vitest_1.expect)(authorized.status).toBe(200);
@@ -603,7 +462,7 @@ function parseSseOrJsonToolText(raw) {
603
462
  (0, vitest_1.expect)(authorized.headers.get('mcp-session-id')).toBeFalsy();
604
463
  });
605
464
  (0, vitest_1.it)('returns 401 before reading oversized bodies when shared key is missing', async () => {
606
- const hugeBody = JSON.stringify(Object.assign(Object.assign({}, INITIALIZE_BODY), { params: Object.assign(Object.assign({}, INITIALIZE_BODY.params), { padding: 'x'.repeat(2048) }) }));
465
+ const hugeBody = JSON.stringify(Object.assign(Object.assign({}, http_integration_helpers_js_1.INITIALIZE_BODY), { params: Object.assign(Object.assign({}, http_integration_helpers_js_1.INITIALIZE_BODY.params), { padding: 'x'.repeat(2048) }) }));
607
466
  const response = await fetch(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`, {
608
467
  method: 'POST',
609
468
  headers: {
@@ -623,7 +482,7 @@ function parseSseOrJsonToolText(raw) {
623
482
  Accept: 'application/json, text/event-stream',
624
483
  'X-API-Key': 'shared-secret',
625
484
  },
626
- body: JSON.stringify(INITIALIZE_BODY),
485
+ body: JSON.stringify(http_integration_helpers_js_1.INITIALIZE_BODY),
627
486
  });
628
487
  (0, vitest_1.expect)(response.status).toBe(200);
629
488
  (0, vitest_1.expect)(response.headers.get('mcp-session-id')).toBeFalsy();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const http_integration_helpers_js_1 = require("./http.integration.helpers.js");
5
+ const streamable_http_js_1 = require("./transports/streamable-http.js");
6
+ (0, vitest_1.describe)('MCP HTTP extra invoke-origin OAuth', () => {
7
+ const invokeHost = 'mcp.ilb.internal';
8
+ const invokeOrigin = `http://${invokeHost}`;
9
+ let mockLightdash;
10
+ let mcpServer;
11
+ (0, vitest_1.beforeEach)(async () => {
12
+ vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
13
+ vitest_1.vi.spyOn(console, 'error').mockImplementation(() => undefined);
14
+ mockLightdash = await (0, http_integration_helpers_js_1.startMockLightdashServer)();
15
+ mcpServer = await (0, streamable_http_js_1.createStreamableHttpServer)(Object.assign({}, (0, http_integration_helpers_js_1.baseOAuthConfig)(mockLightdash.baseUrl, {
16
+ invokeOrigins: [new URL(invokeOrigin)],
17
+ })));
18
+ });
19
+ (0, vitest_1.afterEach)(async () => {
20
+ await mcpServer.close();
21
+ await mockLightdash.close();
22
+ vitest_1.vi.restoreAllMocks();
23
+ });
24
+ (0, vitest_1.it)('keeps public PRM and AS metadata on the listen Host', async () => {
25
+ const prm = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-protected-resource`);
26
+ (0, vitest_1.expect)(prm.status).toBe(200);
27
+ const prmBody = (await prm.json());
28
+ (0, vitest_1.expect)(prmBody.authorization_servers).toEqual([mcpServer.baseUrl]);
29
+ (0, vitest_1.expect)(prmBody.resource).toBe(`${mcpServer.baseUrl}/semantic-layer/v1/mcp`);
30
+ const asRes = await fetch(`${mcpServer.baseUrl}/.well-known/oauth-authorization-server`);
31
+ const asBody = (await asRes.json());
32
+ (0, vitest_1.expect)(asBody.issuer).toBe(mcpServer.baseUrl);
33
+ (0, vitest_1.expect)(asBody.token_endpoint).toBe(`${mcpServer.baseUrl}/oauth/token`);
34
+ });
35
+ (0, vitest_1.it)('advertises invoke-origin PRM and token/DCR when Host matches', async () => {
36
+ const headers = { host: invokeHost, 'x-forwarded-proto': 'http' };
37
+ const prm = await (0, http_integration_helpers_js_1.nodeRequest)({
38
+ baseUrl: mcpServer.baseUrl,
39
+ path: '/.well-known/oauth-protected-resource',
40
+ headers,
41
+ });
42
+ (0, vitest_1.expect)(prm.status).toBe(200);
43
+ (0, vitest_1.expect)(prm.json).toEqual({
44
+ resource: `${invokeOrigin}/semantic-layer/v1/mcp`,
45
+ authorization_servers: [invokeOrigin],
46
+ bearer_methods_supported: ['header'],
47
+ scopes_supported: [],
48
+ });
49
+ const asRes = await (0, http_integration_helpers_js_1.nodeRequest)({
50
+ baseUrl: mcpServer.baseUrl,
51
+ path: '/.well-known/oauth-authorization-server',
52
+ headers,
53
+ });
54
+ (0, vitest_1.expect)(asRes.status).toBe(200);
55
+ const asBody = asRes.json;
56
+ (0, vitest_1.expect)(asBody.issuer).toBe(mcpServer.baseUrl);
57
+ (0, vitest_1.expect)(asBody.authorization_endpoint).toBe(`${mcpServer.baseUrl}/oauth/authorize`);
58
+ (0, vitest_1.expect)(asBody.token_endpoint).toBe(`${invokeOrigin}/oauth/token`);
59
+ (0, vitest_1.expect)(asBody.registration_endpoint).toBe(`${invokeOrigin}/oauth/register`);
60
+ });
61
+ (0, vitest_1.it)('does not inherit invoke metadata for the same hostname on another port', async () => {
62
+ const prm = await (0, http_integration_helpers_js_1.nodeRequest)({
63
+ baseUrl: mcpServer.baseUrl,
64
+ path: '/.well-known/oauth-protected-resource',
65
+ headers: { host: `${invokeHost}:9999`, 'x-forwarded-proto': 'http' },
66
+ });
67
+ (0, vitest_1.expect)(prm.status).toBe(200);
68
+ const body = prm.json;
69
+ (0, vitest_1.expect)(body.authorization_servers).toEqual([mcpServer.baseUrl]);
70
+ });
71
+ (0, vitest_1.it)('verifies an invoke-origin token only when Host matches that origin', async () => {
72
+ const invokeToken = (0, http_integration_helpers_js_1.brokerAccessToken)(invokeOrigin, http_integration_helpers_js_1.TOKEN_A);
73
+ const invokeHeaders = {
74
+ host: invokeHost,
75
+ 'x-forwarded-proto': 'http',
76
+ 'content-type': 'application/json',
77
+ accept: 'application/json, text/event-stream',
78
+ authorization: `Bearer ${invokeToken}`,
79
+ };
80
+ const ok = await (0, http_integration_helpers_js_1.nodeRequest)({
81
+ baseUrl: mcpServer.baseUrl,
82
+ path: '/semantic-layer/v1/mcp',
83
+ method: 'POST',
84
+ headers: invokeHeaders,
85
+ body: JSON.stringify(http_integration_helpers_js_1.INITIALIZE_BODY),
86
+ });
87
+ (0, vitest_1.expect)(ok.status).toBe(200);
88
+ const mismatch = await (0, http_integration_helpers_js_1.postMcp)(mcpServer.baseUrl, http_integration_helpers_js_1.INITIALIZE_BODY, { token: invokeToken });
89
+ (0, vitest_1.expect)(mismatch.status).toBe(401);
90
+ });
91
+ (0, vitest_1.it)('rejects a public-audience token when Host is the extra invoke origin', async () => {
92
+ const publicToken = (0, http_integration_helpers_js_1.brokerAccessToken)(mcpServer.baseUrl, http_integration_helpers_js_1.TOKEN_A);
93
+ const res = await (0, http_integration_helpers_js_1.nodeRequest)({
94
+ baseUrl: mcpServer.baseUrl,
95
+ path: '/semantic-layer/v1/mcp',
96
+ method: 'POST',
97
+ headers: {
98
+ host: invokeHost,
99
+ 'x-forwarded-proto': 'http',
100
+ 'content-type': 'application/json',
101
+ accept: 'application/json, text/event-stream',
102
+ authorization: `Bearer ${publicToken}`,
103
+ },
104
+ body: JSON.stringify(http_integration_helpers_js_1.INITIALIZE_BODY),
105
+ });
106
+ (0, vitest_1.expect)(res.status).toBe(401);
107
+ });
108
+ });
@@ -2,7 +2,7 @@
2
2
  * Content response envelope helpers (RFC §10 / ADR-0006).
3
3
  */
4
4
  import type { ProfileId } from '@lightdash-tools/common';
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
+ export type ContentReaderWarningCode = 'CACHE_STALE' | 'DATE_ZOOM_IGNORED' | 'FILTER_IGNORED' | 'PARAMETER_DEFAULTED' | 'PARTIAL_RESULT' | 'QUERY_RUNNING' | 'QUERY_TIMEOUT' | 'REDACTED' | 'SQL_EXECUTION_DISABLED' | 'SQL_RESULT_MAY_BE_ROW_LEVEL' | 'STALE_CONTENT' | 'TRUNCATED' | 'UNSUPPORTED_TILE' | 'UNVERIFIED_CONTENT';
6
6
  export type ContentReaderWarning = {
7
7
  code: ContentReaderWarningCode;
8
8
  message: string;
@@ -12,7 +12,7 @@ export declare const CONTENT_READER_INVARIANTS: readonly [{
12
12
  readonly short: "Do not download or bulk-export results.";
13
13
  }, {
14
14
  readonly id: "no-sql-chart-execution";
15
- readonly short: "Do not execute saved SQL charts (disabled by default on content-reader).";
15
+ readonly short: "Do not execute ad-hoc SQL or standalone SQL charts; saved dashboard SQL tiles are allowed.";
16
16
  }, {
17
17
  readonly id: "no-override-semantics";
18
18
  readonly short: "Do not override filter targets, operators, required-filter behavior, fields, metrics, dimensions, SQL, table calculations, or sorts.";
@@ -20,7 +20,7 @@ exports.CONTENT_READER_INVARIANTS = [
20
20
  },
21
21
  {
22
22
  id: 'no-sql-chart-execution',
23
- short: 'Do not execute saved SQL charts (disabled by default on content-reader).',
23
+ short: 'Do not execute ad-hoc SQL or standalone SQL charts; saved dashboard SQL tiles are allowed.',
24
24
  },
25
25
  {
26
26
  id: 'no-override-semantics',
@@ -22,7 +22,7 @@ Compare **definitions before values**. Matching titles/labels ≠ same metric, g
22
22
 
23
23
  Execute **only** if sides are structurally comparable **or** the user asked about value differences. Use equivalent valid context (same overrides if any). Cap at **≤2** executions unless the user expands scope.
24
24
 
25
- Skip execution when either side is SQL / non-executable — report that as a confirmed blocker.
25
+ Skip execution when either side is a **standalone** SQL chart (`run_chart` / `source=sql`) or otherwise non-executable — report that as a confirmed blocker. Dashboard `sql_chart` tiles may be executed via `run_dashboard_tile`.
26
26
 
27
27
  ## Report causes
28
28
 
@@ -11,7 +11,7 @@ Discover, explain, and **optionally execute** saved Lightdash charts/dashboards
11
11
  - Do not mutate Lightdash resources (create/update/delete/move/promote).
12
12
  - Do not execute arbitrary metric queries, raw SQL, SQL runner, or underlying-data downloads.
13
13
  - Do not bulk-export or page endlessly through result sets.
14
- - Do not execute saved SQL charts (`source=sql` / `chartType=sql`); default capability is off (`canExecuteSqlCharts=false`).
14
+ - Do not execute ad-hoc SQL, SQL runner, or standalone SQL charts (`source=sql` / `chartType=sql`; `canExecuteSqlCharts=false`). Saved dashboard SQL tiles (`sql_chart`, `canExecuteDashboardSqlTiles=true`) may be executed via `run_dashboard_tile`.
15
15
  - Do not override filter **targets/operators**, required-filter behavior, fields, metrics, dimensions, SQL, table calculations, or sorts — only allowed **value** overrides on existing filter ids / known parameters.
16
16
  - Do not execute content outside the resolved project.
17
17
  - Do not present truncated / incomplete coverage as a full answer.
@@ -57,7 +57,7 @@ Record budget / pagination / truncation stops in the answer.
57
57
  ## Phase 0 — Resolve project
58
58
 
59
59
  1. Always pass **`projectUuid`** (or rely on HTTP `X-Lightdash-Project` pin). Without either → `PROJECT_SCOPE_REQUIRED`; stop.
60
- 2. Call `get_project`. Record UUID, name, `context.projectPinned`, and `readerCapabilities` (`canExecuteSavedCharts`, `canExecuteSqlCharts`, `canExecuteDashboardTiles`).
60
+ 2. Call `get_project`. Record UUID, name, `context.projectPinned`, and `readerCapabilities` (`canExecuteSavedCharts`, `canExecuteSqlCharts`, `canExecuteDashboardTiles`, `canExecuteDashboardSqlTiles`).
61
61
  3. There is **no** org-wide project list on this profile — never invent one.
62
62
 
63
63
  ## Answer shape