Skip to content

Commit b9e0203

Browse files
charliedowlerclaude
andcommitted
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>
1 parent b439459 commit b9e0203

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

guides/ai-overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) lets you co
5050
**Key features:**
5151
- Connect Claude, ChatGPT, or custom agents to your Lightdash instance
5252
- Browse and query your data models
53+
- Run arbitrary SQL queries against your data warehouse for ad-hoc analysis
5354
- OAuth authentication with existing permissions
54-
- Read-only access for security
5555

5656
<Card title="Lightdash Data MCP documentation" icon="plug" href="/references/integrations/lightdash-mcp">
5757
Set up MCP with your AI assistant

references/integrations/lightdash-mcp.mdx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ Since MCP provides raw tools without built-in intelligence, your AI assistant ne
245245
- Search for business terms (e.g., "basket total", "partner name") not technical field names
246246
- Use multiple search queries in one call to find related fields efficiently
247247
- 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)
248254
```
249255

250256
<Info>
@@ -279,6 +285,19 @@ MCP provides AI assistants with powerful tools to interact with your Lightdash d
279285
- **Find dashboards** - Locate existing dashboards by name or content
280286
- **Find charts** - Search through saved charts and visualizations
281287

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+
282301
### Example conversations
283302

284303
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
389408

390409
**Q: Can MCP modify my data or dashboards?**
391410

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.
393412

394413
**Q: Claude returns data as text but no visual chart is displayed. What's wrong?**
395414

0 commit comments

Comments
 (0)