Lab 04: Connect Power BI Modeling MCP
At a glance
Section titled “At a glance”Why this matters
Section titled “Why this matters”Instructions tell Copilot what good work looks like. MCP gives it tools. The Power BI Modeling MCP server lets a chat agent inspect the semantic model that is open in Power BI Desktop, run DAX, and make model changes with your approval. In this lab you connect it in read-first mode, so later agents can test their answers against the live model instead of guessing from files.
Concepts
Section titled “Concepts”- Model Context Protocol (MCP): an open protocol that lets VS Code expose external tools to Copilot Chat. See MCP.
- Power BI Modeling MCP: Microsoft’s local MCP server for Power BI semantic models. It can connect to Power BI Desktop, Fabric semantic models, or PBIP project files, and it exposes tools for model metadata, DAX queries, relationships, measures, and other modeling operations.
- Workspace MCP config:
.vscode/mcp.jsonis committed so every learner sees the same server names and pinned package versions. Secrets stay out of this file. - Tool approval: VS Code asks before an MCP server starts and before tools run. The Power BI MCP server also asks before the first query or model edit.
- File mode: macOS learners cannot run Power BI Desktop, but they can still read and edit PBIP files. Some Power BI Modeling MCP PBIP operations are documented, but this lab only verifies the live Desktop path on Windows.
Before you begin
Section titled “Before you begin”- You finished Lab 02 and can open
fabric\ContosoPharmacy.pbipon Windows. - You finished Lab 03 or you restored the baseline checkpoint below.
- You use VS Code with GitHub Copilot Chat signed in.
- Node.js is installed. The workspace MCP entry starts the server with
npx.
Step 1. Find the two ways this repo registers Power BI Modeling MCP
Section titled “Step 1. Find the two ways this repo registers Power BI Modeling MCP”Open the Explorer (Ctrl+Shift+E, or View > Explorer) and review these files:
{ // Recommended extensions for the Contoso Pharmacy lab. VS Code offers to install them when you // open the folder. Nothing installs automatically. "recommendations": [ "GitHub.copilot-chat", "analysis-services.TMDL", "analysis-services.powerbi-modeling-mcp", "ms-vscode.powershell", "ms-python.python", "charliermarsh.ruff", "redhat.vscode-yaml", "astro-build.astro-vscode" ]}{ // MCP servers for the Contoso Pharmacy lab. No secrets or tenant details belong in this file. // Versions are pinned; update them deliberately and re-run Lab 04 after an update. "servers": { // Power BI Modeling MCP: connects to the model open in Power BI Desktop, or to the PBIP folder. // If you installed the Power BI Modeling MCP VS Code extension instead, disable this entry so // the tools don't appear twice. "powerbi-modeling-mcp": { "type": "stdio", "command": "npx", "args": ["-y", "@microsoft/powerbi-modeling-mcp@0.5.0-beta.13", "--start"] }, // Optional. Fabric MCP: Microsoft Fabric documentation and item definitions. Its docs tools // work without a Fabric tenant. Start it from the MCP view only if you want it. "fabric-mcp": { "type": "stdio", "command": "npx", "args": ["-y", "@microsoft/fabric-mcp@1.4.0", "server", "start", "--mode", "all"] } }}The recommended extension is analysis-services.powerbi-modeling-mcp. The workspace config also registers the npm package @microsoft/powerbi-modeling-mcp@0.5.0-beta.13. Use one path at a time. If both are enabled, the same tools can appear twice in chat.
You should see: the Power BI Modeling MCP VS Code extension in the recommendations, and a workspace server named powerbi-modeling-mcp that starts with npx. You should not see passwords, tenant IDs, workspace IDs, or access tokens.
Step 2. Validate the committed MCP config
Section titled “Step 2. Validate the committed MCP config”Run the lab check for only the MCP config:
pwsh ./scripts/lab/Test-LabProgress.ps1 -Lab 04 -Only L04-mcp-configpwsh ./scripts/lab/Test-LabProgress.ps1 -Lab 04 -Only L04-mcp-configThis check parses .vscode/mcp.json, looks for a Power BI server entry, and scans for literal secrets or GUIDs. The same pattern is used for the cloud agent template:
{ "$comment": "Template for Copilot cloud agent MCP configuration. Paste the mcpServers object into your repository's Settings > Copilot > Coding agent > MCP configuration. It contains no secrets. The cloud agent runs on Linux without Power BI Desktop. Power BI Modeling MCP ships a Linux build and can open a PBIP folder, but this lab hasn't verified that on the cloud agent, so it's read-only here and the cloud agent labs don't depend on it.", "mcpServers": { "powerbi-modeling-mcp": { "type": "local", "command": "npx", "args": [ "-y", "@microsoft/powerbi-modeling-mcp@0.5.0-beta.13", "--start", "--readonly" ], "tools": [ "*" ] },You should see: PASS L04-mcp-config, with powerbi-modeling-mcp listed as the server. If Fabric MCP is also listed, that’s fine. Fabric MCP is optional in this lab.
Step 3. Open the Contoso Pharmacy model in Desktop
Section titled “Step 3. Open the Contoso Pharmacy model in Desktop”- In File Explorer, open
fabric\ContosoPharmacy.pbip. - In Power BI Desktop, select Home > Refresh and wait for the refresh to finish.
- Leave Desktop open. The MCP server discovers the Analysis Services instance that Desktop starts for the model.
pwsh ./scripts/lab/Test-LabProgress.ps1 -Lab 04 -Only L04-desktoppwsh ./scripts/lab/Test-LabProgress.ps1 -Lab 04 -Only L04-desktopYou should see: on Windows, the check reports a running Desktop model instance. On macOS, it reports SKIP, because Power BI Desktop is not available there.
Step 4. Start the MCP server from VS Code
Section titled “Step 4. Start the MCP server from VS Code”- Open the Command Palette: Ctrl+Shift+P (macOS: Cmd+Shift+P), or View > Command Palette.
- Run MCP: List Servers.
- Select powerbi-modeling-mcp.
- Choose Start Server. If VS Code says the server is disabled, choose Enable first.
- When the trust dialog appears, select the server configuration link, confirm it points to this workspace’s
.vscode/mcp.json, then select Trust.
VS Code’s current MCP docs say you can also find installed MCP servers in the Extensions view by searching @mcp, and that first start shows a trust prompt for workspace servers.
You should see: powerbi-modeling-mcp moves to a running state. If this is the first run, npx may download the pinned package before the server is ready.
Step 5. Enable the Power BI tools in agent mode
Section titled “Step 5. Enable the Power BI tools in agent mode”- Open Copilot Chat: Ctrl+Alt+I (macOS: Ctrl+Cmd+I), or View > Chat.
- Switch the chat mode to Agent from the mode picker in the chat input.
- Select Configure Tools in the chat input.
- Expand powerbi-modeling-mcp.
- Leave read tools and DAX query tools selected. Keep write tools selected only if you are ready to approve model edits later.
The Power BI Modeling MCP repo documents tool groups such as connection_operations, model_operations, table_operations, relationship_operations, measure_operations, and dax_query_operations. The exact display names can change while the server is in preview.
You should see: Power BI Modeling MCP tools in the tool picker. At minimum, you should see connection and DAX query capabilities. If Fabric MCP tools appear too, you can leave them off for now.
Step 6. Connect to Desktop and run a safe read
Section titled “Step 6. Connect to Desktop and run a safe read”In Agent mode, send this prompt:
Connect to the Power BI Desktop instance that has ContosoPharmacy open. List the tables and row counts, then run a DAX query that returns prescription fill counts by region for 2025-12. Do not change the model.Approve each tool call after you read it. For the Power BI MCP server, expect an approval before the first query. Do not approve any edit or write operation in this lab.
You should see: a connection to the open Desktop model, a list of the baseline tables, and DAX results grouped by region. The table names still use the baseline source names, because Lab 07 has not renamed them yet.
Step 7. Try the PBIP file-mode path, then stop the server
Section titled “Step 7. Try the PBIP file-mode path, then stop the server”The Power BI Modeling MCP docs say the server can open a semantic model from a PBIP folder with a prompt like this:
Open semantic model from PBIP folder 'fabric/ContosoPharmacy.SemanticModel/definition' in read-only mode and list the tables.Use this as an exploration path only. I verified the repo configuration and the public documentation that describe PBIP support. I could not verify that offline PBIP mode returns data rows on macOS, and it should not replace the Desktop path for Labs 05, 08, or 10.
To stop the server:
- Open MCP: List Servers from View > Command Palette.
- Select powerbi-modeling-mcp.
- Choose Stop Server.
You should see: file-mode metadata if your server version supports it, or a clear error that the operation needs a different path or Desktop connection. After stopping, the server shows as stopped in MCP: List Servers.
Verify your work
Section titled “Verify your work”Run this from the repo root in a PowerShell 7 terminal (Terminal > New Terminal in VS Code):
pwsh ./scripts/lab/Test-LabProgress.ps1 -Lab 04pwsh ./scripts/lab/Test-LabProgress.ps1 -Lab 04Checks marked Windows only print SKIP on macOS. SKIP doesn't count as a failure.
When everything is done you should see:
PASS L04-mcp-config .vscode/mcp.json parses, has the Power BI Modeling MCP server, and no secret valuesPASS L04-desktop Power BI Desktop has a model open for MCP to connect to
Lab 04: 2 of 2 checks passed.Each FAIL line prints a hint and a link back to the step on this page that fixes it. The command exits with code 0 when every required check passes.
| Check | What it looks at | If it fails |
|---|---|---|
L04-mcp-config | .vscode/mcp.json parses, has the Power BI Modeling MCP server, and no secret values | Restore .vscode/mcp.json from git and keep secrets in ${input:...} prompts or environment variables. Go to step 2 |
L04-desktop (Windows only) | Power BI Desktop has a model open for MCP to connect to | Open fabric\ContosoPharmacy.pbip in Power BI Desktop. Go to step 3 |
Troubleshooting
Section titled “Troubleshooting”MCP: List Servers does not show powerbi-modeling-mcp
Open .vscode/mcp.json and confirm it still has the powerbi-modeling-mcp server. Then run Developer: Reload Window from View > Command Palette. If your organization disables MCP servers in Copilot, VS Code can read the file but not expose the tools.
The server starts, then fails with an npx or Node error
Run node --version in the VS Code terminal. The lab expects Node.js 20 or later. If Node works, open MCP: List Servers > powerbi-modeling-mcp > Show Output and read the first error. Corporate proxies often block the first npx package download.
The agent cannot find Power BI Desktop
Make sure Desktop is open with fabric\ContosoPharmacy.pbip, not just the welcome screen. Select Home > Refresh once and wait for the spinner to finish. The local Analysis Services port file appears only after the model is loaded.
The tools are available but Copilot never calls them
Open Copilot Chat, switch to Agent mode, select Configure Tools, and make sure the Power BI tools are checked. Ask for a specific tool-backed action, for example “connect to the Desktop model and list tables”.
I see two Power BI Modeling MCP servers
You likely have both the VS Code extension and the workspace npx server active. Disable one from MCP: List Servers. For this lab, keep the workspace server if you want to match the pinned version in .vscode/mcp.json.
Knowledge check
Section titled “Knowledge check”Recap and next
Section titled “Recap and next”You reviewed the workspace MCP config, started the Power BI Modeling MCP server, connected it to the model open in Desktop, and saw how tool approval works. The model is still the weak baseline. Next you use the connection to measure how well an agent answers business questions before the model is improved.
Go further
Section titled “Go further”- Start the optional
fabric-mcpserver from MCP: List Servers and ask it for Fabric documentation about PBIP projects. Keep it out of the required lab path. - Open the Power BI Modeling MCP output log and find the exact command VS Code used to start the server.
- Try the extension path instead of the workspace
npxpath, then disable one server so the tool list stays clean.
Something wrong or unclear on this page? Open a lab feedback issue. The form is prefilled with this page's name. Nothing is sent until you submit it, and please don't include screenshots of real accounts.