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 questions
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,41 @@ 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>
246
+
## Built-in prompt
247
+
248
+
The Lightdash MCP server includes a built-in **`lightdash-analyst`** prompt with guidelines for querying data effectively — covering explore selection, query building, visualization rules, and more. MCP clients that support prompts (like Claude) can use this automatically, so you don't need to configure custom instructions manually.
249
+
250
+
<Info>
251
+
The built-in prompt also adapts to the active AI agent context. When an agent is selected, the prompt automatically includes the agent's instructions, available explores, and verified questions.
252
+
</Info>
260
253
261
254
## What it can do
262
255
263
256
### Core capabilities
264
257
265
258
MCP provides AI assistants with powerful tools to interact with your Lightdash data:
266
259
267
-
#### System information
268
-
269
-
-**Get Lightdash version** - Check the current version of your Lightdash instance
270
-
271
260
#### Project management
272
261
273
262
-**List projects** - View all accessible projects in your organization
274
263
-**Set active project** - Switch context between different projects (required before accessing any data)
275
264
-**Get current project** - Check which project is currently active
276
265
277
266
<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.
267
+
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
268
</Info>
280
269
281
-
#### Data exploration tools
270
+
#### Data exploration
282
271
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
272
+
-**List explores** - See all available data models in the current project at a glance
273
+
-**Find explores** - Search for relevant data models using natural language (e.g., "customer orders")
274
+
-**Find fields** - Search for specific metrics and dimensions by business terms (e.g., "total revenue", "order date")
275
+
-**Search field values** - Look up valid values for a field, useful for building filters
276
+
-**Find content** - Search for existing charts and dashboards by name or description
287
277
288
278
#### Query execution
289
279
290
-
-**Run metric query** - Execute queries using your semantic layer's metrics and dimensions
280
+
-**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
281
-**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
282
293
283
<Info>
@@ -298,6 +288,15 @@ MCP provides AI assistants with powerful tools to interact with your Lightdash d
298
288
**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
289
</Warning>
300
290
291
+
#### Agent context
292
+
293
+
-**List agents** - Discover available AI agents and their areas of expertise
294
+
-**Set agent** - Activate an agent to scope your session to its explores, instructions, and verified questions
295
+
-**Get current agent** - Check which agent is active and view its full context
296
+
-**Clear agent** - Remove agent scoping and return to the full project context
297
+
298
+
These tools are covered in detail in the [Using AI agent context](#using-ai-agent-context) section below.
299
+
301
300
### Example conversations
302
301
303
302
Here are some examples of how you can interact with AI assistants using MCP:
@@ -320,6 +319,73 @@ Here are some examples of how you can interact with AI assistants using MCP:
320
319
</Accordion>
321
320
</AccordionGroup>
322
321
322
+
## Using AI agent context
323
+
324
+
If your organization has [Lightdash AI agents](/guides/ai-agents) configured, you can reuse their configuration in your MCP sessions.
325
+
326
+
### How is this different from Lightdash AI agents?
327
+
328
+
[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. They include tailored optimizations like conversation memory, self-improvement, and evaluations that are not available through MCP.
329
+
330
+
MCP gives you more flexibility: you can combine Lightdash data with other tools, write code alongside your analysis, or build custom workflows. But the AI assistant driving the MCP session is generic and doesn't have the specialized tuning that Lightdash AI agents provide out of the box.
331
+
332
+
Agent context via MCP lets you reuse your agents' configuration (curated explores, verified questions, and instructions) in an MCP session. This gives your AI assistant better guidance, but it's not a replacement for the full Lightdash AI agents experience.
333
+
334
+
### What you get from agent context
335
+
336
+
When you activate an agent in your MCP session, your AI assistant receives:
337
+
338
+
-**Scoped explores**: only the data models relevant to that agent's domain
339
+
-**Verified questions**: curated example queries that demonstrate correct usage of the data model
340
+
-**Custom instructions**: domain-specific rules like _"Always filter orders by status = 'completed'"_
341
+
342
+
### Example workflow
343
+
344
+
1.**Set your project** with `set_project`
345
+
2.**Browse available agents** with `list_agents` (e.g., "Sales Analyst", "Marketing Metrics")
346
+
3.**Activate an agent** with `set_agent` to load its context
347
+
4.**Ask your questions**: your AI assistant will use the agent's explores, instructions, and verified questions to guide its queries
348
+
349
+
<AccordionGroup>
350
+
<Accordiontitle="Listing available agents in a project">
351
+
<Frame>
352
+

353
+
</Frame>
354
+
</Accordion>
355
+
<Accordiontitle="Setting an agent and viewing its explores">
356
+
<Frame>
357
+

358
+
</Frame>
359
+
</Accordion>
360
+
<Accordiontitle="Asking a question with agent context">
361
+
This agent was configured with the following instructions:
362
+
363
+
```
364
+
You are a Sales analyst for Jaffle Shop. Your role is to answer questions
365
+
about revenue, orders, customers and subscriptions.
366
+
367
+
Key guidelines:
368
+
- Use the orders explore as the starting point for revenue and order
369
+
volume questions.
370
+
- Always include a time dimension when showing trends. Default to monthly
371
+
granularity unless the user specifies otherwise.
372
+
- Format currency values in CAD.
373
+
```
374
+
375
+
When asked _"Can you show me revenue so far?"_, the response automatically followed these instructions:
376
+
377
+
<Frame>
378
+

379
+
</Frame>
380
+
</Accordion>
381
+
</AccordionGroup>
382
+
383
+
<Tip>
384
+
You can also access agent context as a **resource** using the URI pattern `lightdash://agents/{agentUuid}/context`. MCP clients that support resources can load this directly as structured data.
385
+
</Tip>
386
+
387
+
The built-in `lightdash-analyst` prompt automatically adapts when an agent is active, appending the agent's instructions, explores, and verified questions to the base guidelines.
388
+
323
389
## Best practices
324
390
325
391
To get the most value from MCP, ensure your Lightdash data is well-organized and documented. See our [AI agents best practices guide](/guides/ai-agents#best-practices) for detailed recommendations on:
0 commit comments