powerbi-agent
MCP server enabling AI agents to directly query and manage Power BI datasets, reports, and workspaces via DAX, with built-in data security policies and support for both Power BI Desktop and Service.
README
powerbi-agent
MCP server + bộ skill biến AI Agent thành chuyên gia phân tích làm việc TRỰC TIẾP trên Power BI — từ truy vấn DAX có chính sách an toàn dữ liệu, đến dựng trang báo cáo đẹp theo template, đến quy trình phân tích end-to-end 9 khâu.
Hỗ trợ Power BI Desktop (local) · Power BI Service (cloud) · PBIP/PBIR (project files). Host: Claude Code · Codex CLI · Google Antigravity và mọi MCP client stdio.
📘 Cài đặt chi tiết từng bước (có hình): mở
INSTALL.html· Lộ trình: ROADMAP.md · Kết quả UAT: docs/UAT-REPORT.md
Cài bằng AI Agent (khuyến nghị — 1 câu lệnh)
Dán vào agent của bạn (Claude Code / Codex / Antigravity):
Clone https://github.com/ducnguyen221/powerbi-agent vào ~/.mcp/powerbi-mcp rồi chạy install.ps1 trong đó (đọc script trước khi chạy), sau đó restart MCP host.
Agent sẽ: clone → dựng .venv → dò ADOMD.NET/TOM (mọi bản SSMS/standalone/GAC) → đăng ký MCP
vào cả 3 host → copy 2 skill (powerbi-mcp, pbi-pipeline). Cài tay: xem INSTALL.html.
git clone https://github.com/ducnguyen221/powerbi-agent "$env:USERPROFILE\.mcp\powerbi-mcp"
cd "$env:USERPROFILE\.mcp\powerbi-mcp"
powershell -ExecutionPolicy Bypass -File .\install.ps1
Yêu cầu: Windows (Power BI Desktop chỉ có trên Windows) · Python 3.11+ · ADOMD.NET (có sẵn nếu cài SSMS; hoặc Analysis Services client libraries).
11 tool
| Nhóm | Tool | Chức năng |
|---|---|---|
| Khám phá | list_local_reports |
Báo cáo Desktop đang mở (port + model ID) |
list_tables |
Bảng trong model (lọc bảng hệ thống) | |
describe_table |
Cột + kiểu dữ liệu + measure của 1 bảng | |
| Truy vấn 🛡️ | execute_dax_local |
DAX lên Desktop — qua policy an toàn dữ liệu |
execute_dax_service |
DAX lên Service (MSAL, token cache) — qua policy | |
| Ghi model | add_measure_local |
Tạo/sửa measure qua TOM |
add_relationship_local |
Tạo relationship Many-to-One qua TOM | |
| Template 🎨 | list_templates |
Kit báo cáo có sẵn |
apply_template |
Dựng TRANG MỚI từ kit — clone-and-rebind, style giữ nguyên | |
distill_template |
Chưng cất trang đẹp thành kit tái dùng (sanitize được) | |
| Tri thức | distill_model_schema |
Model → Markdown blueprint + Mermaid ERD |
🛡️ Chính sách an toàn dữ liệu (enforce ở server, không phải lời nhắc)
Nguyên tắc: dữ liệu thô ở lại trong engine Power BI — chỉ kết quả tổng hợp vào context LLM.
- aggregate-only (mặc định BẬT):
EVALUATE 'Bảng'/EVALUATE ALL(...)bị từ chối kèm hướng dẫn viết lại bằngSUMMARIZECOLUMNS/TOPN/measure. Tắt:POWERBI_AGGREGATE_ONLY=0. - PII blocklist: copy
policy.example.json→policy.json, liệt kê cột cấm project (SĐT, CMND, email…). Cột bị chặn ở MỌI truy vấn. - Audit log: mọi truy vấn ghi
~/.powerbi-agent/audit/*.jsonl(verdict + số dòng) — bằng chứng kiểm toán "không dump dữ liệu thô". - Trần dimension: kết quả có cột chữ bị siết 200 dòng (thuần measure không giới hạn).
- Trung thực về giới hạn: đây là guard chống rò rỉ sơ ý — bảo mật cứng vẫn là RLS trên model + service principal quyền tối thiểu.
🎨 Template kit — báo cáo đẹp tái tạo được
Bài học đắt giá: layout agent tự dựng từ đầu luôn xấu; clone trang đã chứng minh + đổi binding thì đẹp.
apply_template biến luật đó thành code: giữ nguyên visualContainerObjects (style), chỉ đổi
name/position/fields/visualType/title.
Kit = thư mục text git-được:
templates/kpim-business-light/ # kit mẫu đi kèm (đã sanitize)
kit.json # meta: canvas, blocks, roles
blueprint.md # bản đồ trang mẫu: 30 visual, vị trí, binding
blocks/*.json # visual.json VERBATIM mỗi loại (card KPI, combo chart, pivot, slicer, map…)
_page.json # page settings + nền
Vòng tri thức: trang nào user khen đẹp → distill_template thành kit → dự án sau apply_template tái tạo.
Kit chứa binding nghiệp vụ thật thì để NGOÀI repo (env POWERBI_TEMPLATES_DIR); muốn chia sẻ → sanitize=True.
🤝 Chạy song song microsoft/powerbi-modeling-mcp (khuyến nghị)
powerbi-agent không xây lại modeling — delegate cho MCP chính chủ Microsoft:
claude mcp add powerbi-modeling -s user -- npx -y "@microsoft/powerbi-modeling-mcp@latest" --start
| Việc | Server |
|---|---|
| Query DAX + policy, schema discovery, template/PBIR report layer, distill | powerbi-agent |
| Tạo/sửa table/column/measure/relationship, bulk + transaction, TMDL, DAX validate | powerbi-modeling (Microsoft) |
📐 Quy trình 9 khâu (skill pbi-pipeline)
Agent làm dự án Power BI trọn gói theo thứ tự chuẩn, mỗi khâu có cổng kiểm:
- Kết nối dữ liệu (Power Query, M parameter) → 2. Transform M (kiểu dữ liệu tường minh) → 3. Mô hình hóa star schema + relationship → 4. Measure/calc column DAX (verify từng cái) → 5. Truy vấn tổng hợp (policy gác) → 6+7. Visual & trang báo cáo từ template → 8. Nâng cao (tooltip, drill-through, parameters; bookmark để tay) → 9. Artifact + chưng cất tri thức.
Chi tiết: skill/pbi-pipeline/SKILL.md (tự cài vào host khi chạy install.ps1).
Cấu trúc repo
powerbi_agent/ # package server (query, tom, template, distill, policy, pbir)
mcp_server_powerbi.py # entrypoint back-compat (host đăng ký file này)
skill/ # 2 skill: powerbi-mcp (tool guide) + pbi-pipeline (quy trình 9 khâu)
templates/ # kit mẫu kpim-business-light (sanitized)
tests/ # 32 unit tests (CI windows-latest)
install.ps1 # cài in-place 3 host, idempotent
policy.example.json # mẫu PII blocklist
docs/UAT-REPORT.md # kết quả UAT trên dashboard thật
Bảo mật & vận hành
.env(service principal cloud) không bao giờ bị ghi đè/commit — chỉ tạo từ.env.example.- Tool GHI model nhắc rõ trong docstring; ghi REPORT chỉ khi file .pbip đóng (tool tự cảnh báo).
- Gỡ:
.\uninstall.ps1(giữ file) ·.\uninstall.ps1 -RemoveVenv.
License
MIT — © 2026 Duc Nguyen (ducnguyen221)
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。