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
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) enables AI assistants (e.g. ChatGPT, Claude) and custom agents to directly interact with your Lightdash data. This integration allows MCP clients to explore your data models, search for metrics and dimensions, and provide data-driven insights - all through natural conversation. You can use MCP with existing AI assistants or integrate it into your own custom agents and automated workflows. MCP uses secure OAuth authentication and respects all your existing access controls, ensuring data remains protected.
10
+
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) enables AI assistants (e.g. ChatGPT, Claude, OpenAI Codex) and custom agents to directly interact with your Lightdash data. This integration allows MCP clients to explore your data models, search for metrics and dimensions, and provide data-driven insights - all through natural conversation. You can use MCP with existing AI assistants or integrate it into your own custom agents and automated workflows. MCP uses secure OAuth authentication and respects all your existing access controls, ensuring data remains protected.
11
11
12
12
With MCP, your AI assistant becomes a data analyst that can:
13
13
14
14
- Browse and understand your data models
15
15
- Find relevant metrics and dimensions
16
+
- Run queries and generate visualizations
17
+
- Leverage your AI agents' domain expertise and verified answers
16
18
- Switch between different projects seamlessly
17
19
- Respect your data governance and access controls
18
20
@@ -29,7 +31,7 @@ Setting up MCP is quick and straightforward. You can connect your AI assistant t
29
31
### Prerequisites
30
32
31
33
- A Lightdash Cloud account or Enterprise account with MCP enabled
32
-
- An MCP-compatible AI assistant (e.g., Claude.ai, Claude Desktop, ChatGPT)
34
+
- An MCP-compatible AI assistant (e.g., Claude.ai, Claude Desktop, ChatGPT, OpenAI Codex)
33
35
34
36
### Network requirements
35
37
@@ -148,6 +150,31 @@ ChatGPT support for MCP is coming soon\! Stay tuned for updates.
148
150
</Accordion>
149
151
*/}
150
152
153
+
#### OpenAI Codex
154
+
155
+
<Accordiontitle="Setup instructions">
156
+
1.**Navigate to Settings**
157
+
158
+
Go to **Settings > MCP Servers** and click **Add Server**.
159
+
160
+
2.**Configure Connection**
161
+
162
+
Select **Streamable HTTP** as the transport type and enter your Lightdash MCP URL.
163
+
164
+
<Frame>
165
+

Once the server is created, an **Authenticate** option will appear in the MCP Servers list. Click it to complete the OAuth flow with your Lightdash account.
172
+
173
+
<Frame>
174
+

175
+
</Frame>
176
+
</Accordion>
177
+
151
178
#### Claude Code CLI
152
179
153
180
For developers using Claude Code CLI:
@@ -216,78 +243,33 @@ This will open an interactive inspector where you can explore available tools an
216
243
217
244
{/* TODO: Add screenshots of the MCP inspector interface */}
218
245
219
-
## Configuring your AI assistant
220
-
221
-
Since MCP provides raw tools without built-in intelligence, your AI assistant needs proper instructions to use Lightdash MCP effectively. We recommend adding custom instructions to guide the AI in using the tools correctly.
222
-
223
-
<Accordiontitle="Setting up custom instructions for Claude">
224
-
<Frame>
225
-

226
-
</Frame>
227
-
Here's a suggested template for optimizing Lightdash MCP usage. Feel free to modify these instructions based on your specific needs and use cases:
228
-
229
-
```
230
-
## Lightdash Tool Usage Best Practices
231
-
232
-
### Initial Data Discovery Pattern
233
-
1. **Start with explore discovery**: Use `find_explores` with `exploreName: null` to see all available tables
234
-
2. **Examine table descriptions** to identify the most relevant explore for your query
235
-
3. **Search for specific fields** using `find_fields` with descriptive search terms
236
-
4. **Execute queries** once you have the correct field IDs
237
-
238
-
### Common Parameter Mistakes to Avoid
239
-
- **find_explores**: Pass `null` (not boolean `true`) for exploreName to get all explores
240
-
- **find_explores**: Pass _exact explore name_ as `exploreName` if you want to zoom in on particular explore
241
-
- **find_fields**: Always use the exact `fieldId` values returned from field searches
242
-
- **Page parameters**: Use numbers (e.g., `1` by default) . NEVER use `NaN`or `"null"` (null as a string)
243
-
244
-
### Field Search Strategy
245
-
- Search for business terms (e.g., "basket total", "partner name") not technical field names
246
-
- Use multiple search queries in one call to find related fields efficiently
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)
254
-
```
255
-
256
-
<Info>
257
-
For Claude Code CLI users, you can add these instructions to your project's `CLAUDE.md` file instead of configuring them in the web interface.
258
-
</Info>
259
-
</Accordion>
260
-
261
246
## What it can do
262
247
263
248
### Core capabilities
264
249
265
250
MCP provides AI assistants with powerful tools to interact with your Lightdash data:
266
251
267
-
#### System information
268
-
269
-
-**Get Lightdash version** - Check the current version of your Lightdash instance
270
-
271
252
#### Project management
272
253
273
254
-**List projects** - View all accessible projects in your organization
274
255
-**Set active project** - Switch context between different projects (required before accessing any data)
275
256
-**Get current project** - Check which project is currently active
276
257
277
258
<Info>
278
-
**Important:**An active project must be set before MCP can retrieve any data. Your AI assistant will typically handle this automatically by listing available projects and asking you to select one if none is currently active.
259
+
An active project must be set before MCP can retrieve any data. Your AI assistant will typically handle this automatically by listing available projects and asking you to select one.
279
260
</Info>
280
261
281
-
#### Data exploration tools
262
+
#### Data exploration
282
263
283
-
-**Find explores** - Browse available data models (explores) and understand their structure
284
-
-**Find fields** - Search for specific metrics and dimensions across your data models
285
-
-**Find dashboards** - Locate existing dashboards by name or content
286
-
-**Find charts** - Search through saved charts and visualizations
264
+
-**List explores** - See all available data models in the current project at a glance
265
+
-**Find explores** - Search for relevant data models using natural language (e.g., "customer orders")
266
+
-**Find fields** - Search for specific metrics and dimensions by business terms (e.g., "total revenue", "order date")
267
+
-**Search field values** - Look up valid values for a field, useful for building filters
268
+
-**Find content** - Search for existing charts and dashboards by name or description
287
269
288
270
#### Query execution
289
271
290
-
-**Run metric query** - Execute queries using your semantic layer's metrics and dimensions
272
+
-**Run metric query** - Execute queries using your semantic layer's metrics and dimensions, and generate visualizations (tables, bar charts, line charts, pie charts, and more)
291
273
-**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
274
293
275
<Info>
@@ -298,27 +280,142 @@ MCP provides AI assistants with powerful tools to interact with your Lightdash d
298
280
**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
281
</Warning>
300
282
283
+
#### Agent context
284
+
285
+
-**List agents** - Discover available AI agents and their areas of expertise
286
+
-**Set agent** - Activate an agent to scope your session to its explores, instructions, and verified answers
287
+
-**Get current agent** - Check which agent is active and view its full context
288
+
-**Clear agent** - Remove agent scoping and return to the full project context
289
+
290
+
These tools are covered in detail in the [Using AI agent context](#using-ai-agent-context) section below.
291
+
301
292
### Example conversations
302
293
303
294
Here are some examples of how you can interact with AI assistants using MCP:
304
295
305
-
<AccordionGroup>
306
-
<Accordiontitle="Verifying MCP connection">
307
-
<Frame>
308
-

309
-
</Frame>
310
-
</Accordion>
311
-
<Accordiontitle="Setting up project and finding dashboards">
312
-
<Frame>
313
-

314
-
</Frame>
315
-
</Accordion>
316
-
<Accordiontitle="Finding explores and fields, and executing metric queries">
317
-
<Frame>
318
-

319
-
</Frame>
320
-
</Accordion>
321
-
</AccordionGroup>
296
+
#### Example 1: Verifying your MCP connection
297
+
298
+
After connecting, verify that the MCP integration is working by asking your AI assistant to list available tools.
299
+
300
+
**Prompt:**_"What Lightdash tools do you have access to?"_
301
+
302
+
The assistant will confirm the connection and list the available MCP tools, such as `list_projects`, `find_fields`, `run_metric_query`, `run_sql`, and others. This is a quick way to verify that authentication succeeded and the MCP server is reachable.
303
+
304
+
<Accordiontitle="See screenshot">
305
+
<Frame>
306
+

307
+
</Frame>
308
+
</Accordion>
309
+
310
+
#### Example 2: Setting up a project and finding dashboards
311
+
312
+
Before querying data, you need to set an active project. Then you can search for existing dashboards and charts.
313
+
314
+
**Prompt:**_"What projects do I have access to? Set the Jaffle Shop project, then show me all dashboards related to revenue."_
315
+
316
+
The assistant will:
317
+
1. Call `list_projects` to show your available projects
318
+
2. Call `set_project` to activate "Jaffle Shop"
319
+
3. Call `find_content` with your search term to find matching dashboards and charts
320
+
321
+
**Expected output:** A list of dashboards and charts matching "revenue", including their names, descriptions, and direct links to view them in Lightdash.
322
+
323
+
<Accordiontitle="See screenshot">
324
+
<Frame>
325
+

326
+
</Frame>
327
+
</Accordion>
328
+
329
+
#### Example 3: Exploring data and running a metric query
330
+
331
+
Once a project is active, you can explore data models and run queries using your semantic layer.
332
+
333
+
**Prompt:**_"What metrics do we have for orders? Show me total revenue by month for the last 6 months as a bar chart."_
334
+
335
+
The assistant will:
336
+
1. Call `find_fields` to search for order-related metrics and dimensions (e.g., `orders_total_revenue`, `orders_order_date`)
337
+
2. Call `run_metric_query` with the appropriate explore, metrics, dimensions, filters, and sort order to fetch the data and render a visualization
338
+
339
+
**Expected output:** A bar chart showing monthly revenue for the last 6 months, along with the underlying data table. The query uses your semantic layer definitions, so metric calculations and joins are handled automatically.
340
+
341
+
<Accordiontitle="See screenshot">
342
+
<Frame>
343
+

344
+
</Frame>
345
+
</Accordion>
346
+
347
+
## Using AI agent context
348
+
349
+
If your organization has [Lightdash AI agents](/guides/ai-agents) configured, you can reuse their configuration in your MCP sessions — so you get consistent guidance regardless of where you're working.
350
+
351
+
### How is this different from Lightdash AI agents?
352
+
353
+
[Lightdash AI agents](/guides/ai-agents) are a fully managed experience inside Lightdash and Slack. They handle everything end-to-end: interpreting your question, picking the right data, running queries, and presenting results.
354
+
355
+
With MCP, you can use Lightdash data in other contexts, but the AI assistant driving an MCP session doesn't have the same specialized tuning that Lightdash AI agents provide out of the box. Agent context via MCP bridges that gap: it brings your agents' domain knowledge into any MCP session.
356
+
357
+
### What you get from agent context
358
+
359
+
When you activate an agent in your MCP session, your AI assistant receives:
360
+
361
+
-**[Specialized content](/guides/ai-agents/best-practices#think-specialized-not-general)**: only the data models relevant to that agent's domain
362
+
-**[Verified answers](/guides/ai-agents/verified-answers#how-verified-answers-work)**: curated example queries that demonstrate correct usage of the data model
363
+
-**[Custom instructions](/guides/ai-agents/getting-started#instructions)**: domain-specific rules like _"Always filter orders by status = 'completed'"_
364
+
365
+
### Example workflow
366
+
367
+
1.**Set your project** with `set_project`
368
+
2.**Browse available agents** with `list_agents` (e.g., "Sales Analyst", "Marketing Metrics")
369
+
3.**Activate an agent** with `set_agent` to load its context
370
+
4.**Ask your questions** — the agent's context automatically guides queries
371
+
372
+
**Prompt:**_"What AI agents are available?"_
373
+
374
+
<Accordiontitle="See screenshot: listing agents">
375
+
<Frame>
376
+

377
+
</Frame>
378
+
</Accordion>
379
+
380
+
**Prompt:**_"Use the Sales Analyst agent."_
381
+
382
+
<Accordiontitle="See screenshot: setting agent and viewing explores">
383
+
<Frame>
384
+

385
+
</Frame>
386
+
</Accordion>
387
+
388
+
Once an agent is active, your queries automatically follow its instructions. For example, with a Sales Analyst agent configured with these instructions:
389
+
390
+
```
391
+
You are a Sales analyst for Jaffle Shop. Your role is to answer questions
392
+
about revenue, orders, customers and subscriptions.
393
+
394
+
Key guidelines:
395
+
- Use the orders explore as the starting point for revenue and order
396
+
volume questions.
397
+
- Always include a time dimension when showing trends. Default to monthly
398
+
granularity unless the user specifies otherwise.
399
+
- Format currency values in CAD.
400
+
```
401
+
402
+
**Prompt:**_"Can you show me revenue so far?"_
403
+
404
+
The assistant will automatically use the `orders` explore, include a monthly time dimension, and format values in CAD — all without you specifying these details, because the agent's instructions guide the query.
405
+
406
+
<Accordiontitle="See screenshot: querying with agent context">
407
+
<Frame>
408
+

409
+
</Frame>
410
+
</Accordion>
411
+
412
+
## Built-in prompt
413
+
414
+
The Lightdash MCP server includes a built-in **`lightdash-analyst`** prompt with guidelines for querying data effectively. MCP clients that support prompts can use this automatically, so you don't need to configure custom instructions manually.
415
+
416
+
<Info>
417
+
When an [AI agent](#using-ai-agent-context) is active, the prompt automatically adapts to include the agent's context.
418
+
</Info>
322
419
323
420
## Best practices
324
421
@@ -329,6 +426,8 @@ To get the most value from MCP, ensure your Lightdash data is well-organized and
329
426
- Optimizing for AI assistant performance
330
427
- Security and permissions considerations
331
428
429
+
---
430
+
332
431
## Lightdash Docs MCP
333
432
334
433
In addition to the Lightdash data MCP above, we also offer a **Docs MCP endpoint** that gives AI coding agents access to the complete Lightdash documentation. This is free for everyone—including open source users and all cloud tiers.
0 commit comments