
通过 Claude 控制 Power BI Desktop 的 MCP 服务器
概览
⚠️ – API 和行为可能会在未预警的情况下发生变化。 Power BI Desktop MCP Server 允许 Claude(或任何 MCP 客户端)使用自然语言与运行中的 Power BI Desktop 实例通信。它将模型上下文协议与表格对象模型桥接,使你无需离开聊天即可检查、优化和编写 DAX。 逐步设置(Power BI 前置条件、.NET 库、环境变量)都存在于 INSTALLATION.md 中。 列出你当前 Power BI 模型中的表格: - 如果Microsoft分析服务的 DLL 未被自动检测,则将 .env.example 复制到 .env,并设置 TOM_DLL_PATH。可选变量包括 LOG_LEVEL、MCP_KNOWLEDGE_BASE 和 POWERBI_WORKSPACE_NAME。- 向 Claude Desktop(或任何 MCP 主机)添加 CLI 入口点: - CLI 是 python -m powerbi_mcp.server 的薄包装,因此任一调用方式均可用于部署和调试。
概述(AI 翻译)
⚠️ Alpha版本——API和行为可能会在未通知的情况下发生变化。
Power BI Desktop MCP Server 允许 Claude(或任何 MCP 客户端)使用自然语言与运行中的 Power BI Desktop 实例通信。它将模型上下文协议与表格对象模型桥接,使你无需离开聊天即可检查、优化和编写 DAX。
安装
逐步设置(Power BI 前置条件、.NET 库、环境变量)都存在于 INSTALLATION.md 中。
关于本地发展:
快速示例
列出你当前 Power BI 模型中的表格:
向知识库导出测量:
对一个表达式运行优化器:
配置
-
如果 Microsoft Analysis Services 的 DLL 未被自动检测,则将
.env.example复制到.env,并设置TOM_DLL_PATH。可选变量包括LOG_LEVEL、MCP_KNOWLEDGE_BASE和POWERBI_WORKSPACE_NAME。 -
向 Claude Desktop(或任何 MCP 主机)添加 CLI 入口点:
-
CLI是
python -m powerbi_mcp.server的薄包裹器,因此任一调用方式均可用于部署和调试。
特色
- DAX代码生成与度量创建
- 测量和表元数据检查
- 带有规则建议的DAX优化器
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Power BI Desktop MCP Server
⚠️ Alpha version – APIs and behaviours may change without notice.
Power BI Desktop MCP Server lets Claude (or any MCP client) talk to a running Power BI Desktop instance using natural language. It bridges the Model Context Protocol to the Tabular Object Model so you can inspect, optimize, and author DAX without leaving chat.
Installation
Step-by-step setup (Power BI prerequisites, .NET libraries, environment variables) lives in INSTALLATION.md.
For local development:
pip install -e .
# or install from the current directory:
pip install .
Quick Example
List the tables in your current Power BI model:
python examples/list_model_info.py --include-columns
Export measures to the knowledge base:
python examples/export_measures_to_knowledge_base.py --project "Executive Dashboard"
Run the optimizer on an expression:
python examples/optimize_dax.py --expr "CALCULATE(SUM(Sales[Amount]), FILTER(ALL(Date), Date[Year] = 2024))"
Configuration
-
Copy
.env.exampleto.envand setTOM_DLL_PATHif the Microsoft Analysis Services DLLs are not auto-detected. Optional variables includeLOG_LEVEL,MCP_KNOWLEDGE_BASE, andPOWERBI_WORKSPACE_NAME. -
Add the CLI entry point to Claude Desktop (or any MCP host):
{ "mcpServers": { "powerbi": { "command": "powerbi-mcp-server", "args": [] } } } -
The CLI is a thin wrapper around
python -m powerbi_mcp.server, so either invocation works for deployments and debugging.
Features
- DAX code generation and measure creation
- Measure and table metadata inspection
- DAX optimizer with rule-based suggestions
- TMDL import/export helpers
- Knowledge base bridge for storing curated measures
- Example scripts for quick automation (
examples/directory)
Known Issues
- Power BI visuals live outside the XMLA endpoint, so visual creation/editing is not supported.
- The server connects to the most recently opened Power BI Desktop workspace; multiple instances are not yet multiplexed.
- Write operations require the Power BI model to allow external tools and, in some scenarios, elevated permissions.
pythonnetrelies on local Microsoft Analysis Services DLLs; misconfiguredTOM_DLL_PATHis the most common setup failure.
Contributing
Pull requests are welcome. Please:
- Open an issue describing the change if it alters behaviour or APIs.
- Keep additions formatted with
ruff/blackstyle conventions (if configured) and include type hints. - Add or update example scripts/tests where it helps illustrate new functionality.
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"powerbi": {
"command": "powerbi-mcp-server",
"args": []
}
}
}