☰
10 个即拿即用的 AI 建模场景:powerbi-modeling-mcp 提示词清单(命名规范、模型翻译、文档生成)
2026/10/14 17:04:30 网站建设 项目流程

【免费下载链接】powerbi-modeling-mcp

The Power BI Modeling MCP Server, brings Power BI semantic modeling capabilities to your AI agents.

项目地址:https://gitcode.com/gh_mirrors/po/powerbi-modeling-mcp
点击查看免费下载

powerbi-modeling-mcp(Power BI Authoring MCP Server)是微软开源的 MCP Server,把 Power BI 语义模型的建模能力带给 AI Agent:用自然语言即可完成建模、批量重命名、模型翻译和 DAX 验证。本文整理了一份即拿即用的 AI 建模提示词清单,覆盖 10 个高频场景——命名规范分析、语义模型翻译、专业文档生成等,直接复制到 Copilot 聊天框即可执行。

🧭 先认识 powerbi-modeling-mcp 是什么

它基于 MCP 协议 在本地运行,让 AI Agent 像人一样操作语义模型:

  • 🔄自然语言建模:创建、更新、管理表、列、度量值、关系
  • ⚡批量操作:批量重命名、批量重构、模型翻译、安全规则,一次处理数百个对象
  • 🤖Agentic 工作流:支持 TMDL 与 Power BI Project(PBIP)文件,AI 可自主规划建模任务
  • 🔍DAX 查询与验证:执行、测试、排查度量值计算

它支持三类模型载体:Power BI Desktop、Fabric Workspace和PBIP 项目文件。

🚀 快速上手:3 步连接 Power BI 语义模型

第 1 步:安装 VS Code 扩展(推荐方式)

  1. 安装 Visual Studio Code 与 GitHub Copilot Chat 扩展
  2. 从扩展市场安装Power BI Authoring MCP扩展:

  1. 打开 Copilot 聊天窗口,确认工具列表里已出现powerbi-modeling-mcp

第 2 步:接受 EULA

首次使用需阅读并同意 EULA.txt。在聊天中授权后,Agent 可调用accept_eula工具完成确认,之后不再重复提示。

第 3 步:用一句话连接模型

根据模型位置,直接输入对应的连接提示词:

Connect to '[File Name]' in Power BI Desktop
Connect to semantic model '[Semantic Model Name]' in Fabric Workspace '[Workspace Name]'
Open semantic model from PBIP folder '[Path to the definition/TMDL folder in the PBIP]'

💡 也可以不手写连接语句:在聊天框输入/,使用内置的 ConnectTo 斜杠命令(见下文「附赠」章节)。

📋 10 个即拿即用的 AI 建模场景提示词清单

以下前 7 个场景的提示词来自官方 README.md 的 Example scenarios 表格,后 3 个基于工具表扩展,可按自己的模型改写。

场景 1 | 命名规范分析与批量重命名

让 AI 先学习模型里已有表的命名模式,再统一应用到整个模型——适合接手历史项目时"一键规范命名":

Analyze my model's naming conventions and suggest renames to ensure consistency.
Analyze the naming convention of the 'Sales' table and apply the same pattern across the entire model.

底层调用 table / column / measure 的 rename 工具,数百个对象可一次批量完成。

场景 2 | 全模型批量补全描述与说明

模型交接、审计前必备。给所有对象补上用途说明,并把 DAX 逻辑翻译成"人话":

Add descriptions to all measures, columns, and tables to clearly explain their purpose and explain the logic behind the DAX code in simple, understandable terms.

场景 3 | 语义模型多语言翻译(模型翻译)

利用 culture 与 object translation 工具,一键生成法语、日语等语言版本的表名、列名与度量值:

Generate a French translation for my model including tables, columns and measures.

场景 4 | 时间智能度量值重构为 Calculation Group

散落的 12 个月、6 个月平均度量值容易失控,让 AI 重构进计算组并顺手扩展变体:

Refactor measures 'Sales Amount 12M Avg' and 'Sales Amount 6M Avg' into a calculation group and include new variants: 24M and 3M.

场景 5 | Power Query 数据源配置参数化

分析所有表的 Power Query 代码,把数据源位置抽成语义模型参数,切换环境(开发/生产)时不再改代码:

Analyze the Power Query code for all tables, identify the data source configuration, and create semantic model parameters to enable easy switching of the data source location.

场景 6 | 两个模型 DAX 查询性能对比基准

同时连接 V1、V2 两个模型版本,用同一条 DAX 查询做性能对标,量化重构收益:

Connect to semantic model 'V1' and 'V2'. And benchmark the following DAX query against both models. [DAX Query]

场景 7 | 一键生成专业模型文档(Markdown + Mermaid)

官方最"惊艳"的场景:自动生成包含 Mermaid 关系图、度量值 DAX 代码、业务逻辑说明、行级过滤器与数据源分析的完整 Markdown 文档:

Generate a Markdown document (.md) that provides complete, professional documentation for a Power BI Semantic Model. Use a simple mermaid diagram to illustrate the table relationships; Document each measure including the DAX code and a description of the business logic using business friendly names; Document row level filters; Document the data sources by analyzing the Power Query code.

场景 8 | 用自然语言生成并验证 DAX 查询

不背 DAX 语法也能取数:描述问题 → AI 生成 DAX → 执行并返回结果;配合缓存清理还能拿到执行指标,做 DAX 性能分析:

How many distinct customers placed an order in the last 30 days? Run the DAX query and show the result.

场景 9 | 配置行级安全性(RLS)角色

示例提示词(可按角色与过滤规则改写),调用 security role 工具创建角色并验证:

Create a security role 'Store Managers' that restricts the 'Sales' table to rows where 'Store' matches the user's store, then validate it with a sample query.

场景 10 | 建模最佳实践体检

官方能力之一:对照 Power BI 建模最佳实践评估模型并给出整改建议:

Review my semantic model against Power BI modeling best practices and list the issues with concrete fixes.

⚠️重要提醒:LLM 可能产生意外修改,操作前务必备份模型。官方提示词示例仅供参考,配合正确上下文,几乎任何建模任务都可以自动化。

🎁 附赠:6 个内置斜杠提示词(/ 命令)

powerbi-modeling-mcp 自带 6 个内置 Prompts,在 VS Code 聊天框输入/即可唤起(部分命令还会为 LLM 附加 DAX 语法、PBIP 上下文等资源):

提示词名称作用
ConnectToPowerBIDesktop按文件名搜索并连接 Power BI Desktop 实例
ConnectToFabric连接 Fabric Workspace 中的语义模型
ConnectToPBIP加载 PBIP 项目的 TMDL 定义(附加 PBIP 上下文)
CreateDAXQuery用自然语言问题生成 DAX 查询(附加 DAX 语言上下文)
RunDAXQueryWithMetrics执行 DAX 查询,可选清缓存、只返回执行指标
AnalyzeDAXQuery清空缓存后运行查询并分析性能问题

🛡️ 安全第一:写保护与关键配置

  • 默认开启写保护确认:--readwrite(默认)模式下,Agent 每次修改语义模型前会弹出确认对话框,逐库确认:

  • 只读安全模式:加--readonly参数后禁止一切写操作,适合纯查询、分析场景
  • 事务支持:transaction 工具可 begin / commit / rollback 批量修改,出问题可整体回滚
  • 兼容模式:--compatibility=Full可对接 Analysis Services 数据库(默认优化 Power BI 场景)
  • 认证方式:--authmode=interactive(交互)或serviceprincipal(服务主体,配合AZURE_CLIENT_ID等环境变量)

在 VS Code 中搜索@ext:Microsoft.powerbi-modeling-mcp即可修改上述用户设置:

🩺 常见问题排查

  1. 看日志:命令面板(Ctrl+Shift+P)→MCP: List Servers→ 选择powerbi-modeling-mcp→Show Output,在输出窗口查看服务器日志:

  1. 换账号认证失败:Fabric 会话内认证会复用,需重启 MCP 服务器触发重新认证
  2. 安装新版本卡住:重启 MCP 服务器,再不行就重启 VS Code
  3. Fabric 侧审计:MCP 产生的命令会以应用名MCP-PBIModeling记录在 Fabric Workspace Monitor 中,可据此追踪 AI 的每次操作

更多细节见 TROUBLESHOOTING.md。

📚 相关文档与文件

  • 项目说明与场景示例:README.md
  • 故障排查指南:TROUBLESHOOTING.md
  • 许可协议:EULA.txt、LICENSE
  • 安全说明:SECURITY.md
  • 支持渠道:SUPPORT.md
  • 行为准则:CODE_OF_CONDUCT.md

把这份提示词清单收藏起来,下次打开 Power BI 语义模型时,直接复制对应场景的提示词,让 AI 帮你把数小时的重复建模工作压缩到几秒钟。

【免费下载链接】powerbi-modeling-mcp

The Power BI Modeling MCP Server, brings Power BI semantic modeling capabilities to your AI agents.

项目地址:https://gitcode.com/gh_mirrors/po/powerbi-modeling-mcp
点击查看免费下载

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询