mcp-artifact-integration
できること
MCPを通じてLightdashを呼び出し、クエリ結果を表示するウェブのアーティファクトを作る方法を説明します。ライブのLightdashのデータを見せるカスタムのページやアプリを作る開発者向けです。
使う場面
- ✓Lightdashのクエリ結果を表示するウェブページを作りたいとき。
- ✓アーティファクトでLightdashのクエリの読み込み中、エラー、データなしの状態を扱う必要があるとき。
- ✓Lightdashのクエリで、CSVデータに戻す方法がほしいとき。
スキルのリンク
https://github.com/lightdash/lightdash/blob/main/packages/backend/src/ee/services/ai/skills/builtInSkills/mcp-artifact-integration/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このLightdashの指標クエリの結果を表として表示するHTMLのアーティファクトを作ってください。読み込み中とエラーの状態も含めてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
スキルは、クエリを開始し、そのIDを保持し、結果を取得する方法を説明します。レスポンスの読み方、構造化された内容とエラーのフラグを含め、各状態を正しく表示する方法も説明します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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
よくある質問
新しいエンドポイントを追加しますか?
いいえ。スキルは既存のデータの契約を説明し、エンドポイントやSDKは追加しません。
どのクエリツールを使うべきですか?
セマンティックレイヤーで答えられる質問には指標クエリツールを、それ以外の読み取り専用のクエリにはSQLツールを使います。
通常のチャットにも必要ですか?
いいえ。通常のチャットやLightdashの組み込みのグラフアプリには必要ないと説明されています。
詳細
作者による元の説明
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
人気
- GitHubのスター
- 6.2k
- ランキング
- #14398
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
breakup-pr
6.2k大きなプルリクエストを、一つずつレビューしてマージできる、小さく積み重ねたスライスに分割するのを支援します。
lightdash-agent-slack-messaging
6.2k証拠に基づいて、Lightdashの管理者向けに、わかりやすく親しみのある保守とアクティビティの報告を書くのを支援します。
developing-in-lightdash
6.2kLightdashのダッシュボードとグラフを、JSONとして読み、作成し、編集するのを支援します。各グラフの種類の設定を含みます。
filter-expressions
6.2kLightdashの指標クエリに、正しいフィルター式を書くのを支援します。カスタム指標へのフィルターも含みます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。