mcp-artifact-integration
Skill này làm gì
Skill này giải thích cách xây dựng một artifact web gọi Lightdash qua MCP và hiển thị kết quả truy vấn. Skill dành cho lập trình viên muốn một trang hoặc ứng dụng tùy chỉnh hiển thị dữ liệu Lightdash trực tiếp.
Khi nào nên dùng
- ✓Khi bạn muốn xây dựng một trang web hiển thị kết quả truy vấn Lightdash.
- ✓Khi bạn cần xử lý các trạng thái tải, lỗi và rỗng cho một truy vấn Lightdash trong artifact.
- ✓Khi bạn muốn dùng dữ liệu CSV từ truy vấn Lightdash làm phương án dự phòng.
Liên kết skill
https://github.com/lightdash/lightdash/blob/main/packages/backend/src/ee/services/ai/skills/builtInSkills/mcp-artifact-integration/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Xây dựng một artifact HTML hiển thị kết quả truy vấn số liệu này dưới dạng bảng, có trạng thái đang tải và trạng thái lỗi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill giải thích cách bắt đầu một truy vấn, giữ lại mã định danh và kiểm tra kết quả định kỳ cho đến khi có. Skill mô tả cách đọc phản hồi, gồm nội dung có cấu trúc và các cờ lỗi, và cách hiển thị đúng từng trạng thái.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Skill có thêm endpoint mới không?
Không. Skill mô tả hợp đồng dữ liệu hiện có và không thêm endpoint hay SDK nào.
Nên dùng công cụ truy vấn nào?
Dùng công cụ truy vấn số liệu cho các câu hỏi mà semantic layer trả lời được, và công cụ SQL cho các truy vấn chỉ đọc khác.
Có cần cho trò chuyện thông thường không?
Không. Mô tả nêu rõ skill không cần cho trò chuyện thông thường hay ứng dụng biểu đồ tích hợp sẵn của Lightdash.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 6.2k
- Vị trí xếp hạng
- #14398
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
breakup-pr
6.2kGiúp agent của bạn tách một pull request lớn thành các phần nhỏ, xếp chồng lên nhau, để có thể xem xét và gộp từng phần một.
lightdash-agent-slack-messaging
6.2kGiúp agent của bạn viết báo cáo bảo trì và hoạt động cho quản trị viên Lightdash rõ ràng, thân thiện, chỉ dựa trên bằng chứng có sẵn.
developing-in-lightdash
6.2kGiúp agent của bạn đọc, tạo và chỉnh sửa dashboard và biểu đồ Lightdash dưới dạng JSON, kèm cài đặt của từng loại biểu đồ.
filter-expressions
6.2kGiúp agent của bạn viết biểu thức lọc đúng cho truy vấn số liệu Lightdash, kể cả lọc trên các chỉ số tùy chỉnh.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.