mcp-artifact-integration
What it does
This skill explains how to build a web artifact that calls Lightdash through MCP and displays the query results. It is for developers who want a custom page or app that shows live Lightdash data.
When to use it
- āWhen you want to build a web page that shows Lightdash query results.
- āWhen you need to handle loading, error and empty states for a Lightdash query in an artifact.
- āWhen you want to fall back to CSV data from a Lightdash query.
Skill link
https://github.com/lightdash/lightdash/blob/main/packages/backend/src/ee/services/ai/skills/builtInSkills/mcp-artifact-integration/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentās skills folder.
Example of what to ask your AI
āBuild an HTML artifact that shows the results of this Lightdash metric query as a table, with loading and error states.ā
5 new skills a week. 1 minute to read.
How it works
The skill explains how to start a query, keep its ID and poll for the result. It describes how to read the response, including the structured content and any error flags, and how to show each state correctly.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Lightdash query results in HTML/React artifacts
Use this skill when creating an HTML/React artifact or app that calls Lightdash through Model Context Protocol (MCP). It describes the existing data contract; it does not add a new endpoint, SDK or browser bridge.
Choose and start the query
Choose run_metric_query for questions expressible in the semantic layer. Discover field IDs with grep_fields / get_metadata, and supply required parameters explicitly: omitted parameters may silently use defaults. Use run_sql for other read-only SELECT queries in the warehouse's dialect. Read each tool's schema for its effective row limit; deployment configuration can change the maximum.
Call the query-start tool once. Keep its query UUID and original project/agent scope for subsequent polling. The artifact should track its own loading, success, empty and error states; a pending query is not an empty dataset.
Read the result envelope
A full MCP CallToolResult can contain:
content: an array of typed content blocks. Query tools put CSV or status/error text in the first text block. Additional blocks can contain an applied-parameters note,queryUuid: <id>,[Scope: ...]or a compatibility warning.structuredContent.result: the typed result, when exposed by the host. Prefer this over parsing CSV.isError: a tool failure flag. Check it, but also inspectstructuredContent.result.status: terminal query statuses can arrive withoutisError._meta: host/app metadata. Do not assume your artifact bridge exposes it.
Do not concatenate every content block into CSV. Do not parse an entire CallToolResult as row data. When the host exposes text only, follow the status text and parse only the data block with a real CSV parser (quoted delimiters, quotes and line breaks are legal). If the bridge discards necessary status or UUID information, show an integration error rather than guessing.
The companion result contracts gives the exact completed/running/terminal shapes and link semantics. Native MCP clients can read the resource; fallback clients can call read_skill_resource with name: "mcp-artifact-integration" and path: "resources/result-contracts.md".
Poll without re-executing
- Start the query once with
run_sqlorrun_metric_query. - Check
isErrorfirst. For structured results, branch onresult.status. running: retain the returnedqueryUuid, show "Query still runningā¦", waitnextPollAfterMs, then callget_query_resultwith that same UUID and scope. Text-only clients use the UUID and wait instructions in the returned text. Never invent an ID or restart the original query to check progress.done: stop polling and render the data. An emptyrowsarray is successful completion with zero rows, not a parsing failure.error,cancelledorexpired: stop polling and display the returned error/status. These can be normal MCP results withoutisError: true.
Both the initial query-start call and each polling call can wait up to approximately 50 seconds server-side. Allow for that in the host bridge's timeout. This is not the warehouse execution timeout; warehouse timeouts come from the Lightdash connection. heartbeatAt records the latest Lightdash check that confirmed the query was still running, not a warehouse progress percentage.
If a polling call loses its connection or times out, retry only get_query_result with the same UUID, using bounded retries/backoff. Avoid overlapping polls; stop on terminal state, artifact teardown or user cancellation. Stopping local polling does not cancel warehouse execution. Ignore stale responses if the user starts a different query while an earlier call is in flight.
If the initial query-start call loses its response before you receive a UUID, do not automatically resubmit: the warehouse may already be executing it. Report that the outcome is unknown; a retry can duplicate execution.
Validation failures should be corrected before another query is started. Application/warehouse errors are terminal until corrected; do not put them into the transient polling retry loop.
Build your artifact's own visualization
Use completed query rows as data for your HTML table or React chart library. For metric results, rows use stable field IDs and fields provides metadata; CSV headers instead use display labels. Keep stable IDs for data access, use labels for presentation, and do not treat labels as un
FAQ
Does it add a new endpoint?
No, the skill describes the existing data contract and does not add an endpoint or SDK.
Which query tool should I use?
Use the metric query tool for questions the semantic layer can answer, and the SQL tool for other read-only queries.
Is this needed for ordinary chat?
No, the description says it is not needed for ordinary chat or Lightdash's built-in chart app.
Details
Original description by the author
Integrate Lightdash MCP query results into Claude-created HTML or React artifacts. Covers host bridges, response envelopes, polling, errors, CSV fallback and chart data. Not needed for ordinary chat or Lightdash's built-in chart app.
repo: lightdash/lightdash
Popularity
- GitHub stars
- 6.2k
- Ranking position
- #14398
- License
- ā
- Updated
- 11/2/2026
Comments
- ā¦
More skills from this repository
breakup-pr
6.2kHelps your agent split a large pull request into smaller, stacked slices that can be reviewed and merged one at a time.
lightdash-agent-slack-messaging
6.2kHelps your agent write clear, friendly maintenance and activity reports for Lightdash administrators, based only on the evidence it has.
developing-in-lightdash
6.2kHelps your agent read, create and edit Lightdash dashboards and charts as JSON, including each chart type's settings.
filter-expressions
6.2kHelps your agent write correct filter expressions for Lightdash metric queries, including filters on custom metrics.
Similar skills
angular-developer
280kHelps your agent create Angular code and give project structure advice. Useful for starting new projects, creating code parts, or improving performance and accessibility.
frontend-a11y
280kHelps your agent make web interfaces accessible to everyone. It ensures websites and apps work well with screen readers and keyboard navigation.
frontend-patterns
280kHas your agent apply modern patterns in frontend development. It optimizes performance, manages state, and follows best practices in React and Next.js.