You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document run_sql MCP tool and add warehouse security guidance
- Add Query execution section to MCP docs covering run_metric_query and run_sql tools
- Add custom instructions guidance for when to use run_sql vs run_metric_query
- Add warning about ensuring read-only warehouse credentials
- Update AI overview to mention SQL query capability
- Update FAQ to reflect query execution capabilities
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: references/integrations/lightdash-mcp.mdx
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,6 +245,12 @@ Since MCP provides raw tools without built-in intelligence, your AI assistant ne
245
245
- Search for business terms (e.g., "basket total", "partner name") not technical field names
246
246
- Use multiple search queries in one call to find related fields efficiently
247
247
- Look for both dimensions (for grouping) and metrics (for aggregation)
248
+
249
+
### When to Use run_sql vs run_metric_query
250
+
- **Prefer `run_metric_query`** for standard analysis using defined metrics and dimensions — it leverages the semantic layer and ensures consistent definitions
251
+
- **Use `run_sql`** for ad-hoc queries, cross-table joins not modeled in explores, or when the user explicitly requests raw SQL
252
+
- `run_sql` defaults to 500 rows (max 5000) — use the `limit` parameter to control result size
253
+
- Use the SQL dialect appropriate for the connected warehouse (e.g., PostgreSQL, BigQuery, Snowflake)
248
254
```
249
255
250
256
<Info>
@@ -279,6 +285,19 @@ MCP provides AI assistants with powerful tools to interact with your Lightdash d
279
285
-**Find dashboards** - Locate existing dashboards by name or content
280
286
-**Find charts** - Search through saved charts and visualizations
281
287
288
+
#### Query execution
289
+
290
+
-**Run metric query** - Execute queries using your semantic layer's metrics and dimensions
291
+
-**Run SQL** - Execute arbitrary SQL queries directly against the project's data warehouse. Useful for ad-hoc analysis or queries that don't fit the explore-based model. Returns up to 500 rows by default (configurable up to 5,000).
292
+
293
+
<Info>
294
+
**Run SQL** requires the `manage SqlRunner` permission. The SQL is executed directly against your warehouse, so use the appropriate SQL dialect for your connection (e.g., PostgreSQL, BigQuery, Snowflake).
295
+
</Info>
296
+
297
+
<Warning>
298
+
**Security best practice:** Ensure the database credentials configured in your Lightdash connection have **read-only (viewer) access** to your warehouse. Since `run_sql` executes arbitrary SQL, a connection with write permissions could allow AI agents to modify or delete warehouse data.
299
+
</Warning>
300
+
282
301
### Example conversations
283
302
284
303
Here are some examples of how you can interact with AI assistants using MCP:
@@ -389,7 +408,7 @@ A: Yes, each team member can set up their own MCP connection with their individu
389
408
390
409
**Q: Can MCP modify my data or dashboards?**
391
410
392
-
A: No, MCP has read-only access. It can search and explore your data models but cannot make any modifications to your Lightdash configuration or underlying data.
411
+
A: No, MCP cannot modify your Lightdash configuration, dashboards, or underlying data. It can search, explore your data models, run metric queries, and execute SQL SELECT queries — but all operations are read-only.
393
412
394
413
**Q: Claude returns data as text but no visual chart is displayed. What's wrong?**
0 commit comments