Aller au contenu
Skillpedia
Sites et interfaces (frontend)6.2k · #14398

mcp-artifact-integration

Ce qu’il fait

Cette compétence explique comment construire un artefact web qui appelle Lightdash via MCP et affiche les résultats de requête. Elle s'adresse aux développeurs qui veulent une page ou une application personnalisée affichant des données Lightdash en direct.

Quand l’utiliser

  • ✓Quand vous voulez créer une page web qui affiche les résultats d'une requête Lightdash.
  • ✓Quand vous devez gérer les états de chargement, d'erreur et vide d'une requête Lightdash dans un artefact.
  • ✓Quand vous voulez un repli sur les données CSV d'une requête Lightdash.

Lien du skill

https://github.com/lightdash/lightdash/blob/main/packages/backend/src/ee/services/ai/skills/builtInSkills/mcp-artifact-integration/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/lightdash/lightdash/blob/main/packages/backend/src/ee/services/ai/skills/builtInSkills/mcp-artifact-integration/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Construis un artefact HTML qui affiche les résultats de cette requête de métrique Lightdash sous forme de tableau, avec des états de chargement et d'erreur.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

La compétence explique comment lancer une requête, conserver son identifiant et interroger le résultat jusqu'à obtenir la réponse. Elle décrit comment lire la réponse, y compris le contenu structuré et les indicateurs d'erreur, et comment afficher correctement chaque état.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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 inspect structuredContent.result.status: terminal query statuses can arrive without isError.
  • _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

  1. Start the query once with run_sql or run_metric_query.
  2. Check isError first. For structured results, branch on result.status.
  3. running: retain the returned queryUuid, show "Query still running…", wait nextPollAfterMs, then call get_query_result with 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.
  4. done: stop polling and render the data. An empty rows array is successful completion with zero rows, not a parsing failure.
  5. error, cancelled or expired: stop polling and display the returned error/status. These can be normal MCP results without isError: 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

Questions fréquentes

Ajoute-t-elle un nouveau point d'accès ?

Non, la compétence décrit le contrat de données existant et n'ajoute ni point d'accès ni SDK.

Quel outil de requête utiliser ?

Utilisez l'outil de requête de métriques pour les questions que la couche sémantique peut traiter, et l'outil SQL pour les autres requêtes en lecture seule.

Est-elle nécessaire pour un chat ordinaire ?

Non, la description indique qu'elle n'est pas nécessaire pour un chat ordinaire ni pour l'application de graphiques intégrée de Lightdash.

Détails

Description originale de l’auteur

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

Popularité

Étoiles GitHub
6.2k
Position au classement
#14398
Licence
—
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires