Skip to content

Lab 04: Connect Power BI Modeling MCP

Time
About 30 minutes
Level
intermediate
Platforms
Windows 11, macOS (file mode, no Desktop)
Copilot surfaces
VS Code, Power BI Desktop
You'll use
mcp
Starts from
lab02-start: The baseline model exactly as it ships on main.
Ends at
None needed
Last verified
Not yet run end to end on Windows 11

Works on macOS

Nobody has run this lab end to end on Windows 11 yet. The steps follow the current docs for each tool, but menu labels may differ. The verify command at the end is the source of truth, and feedback is welcome.

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.

  • 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.json is 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.
  • You finished Lab 02 and can open fabric\ContosoPharmacy.pbip on 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:

.vscode/extensions.json
{
// 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"
]
}
.vscode/mcp.json
{
// 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.

Run the lab check for only the MCP config:

Terminal window
pwsh ./scripts/lab/Test-LabProgress.ps1 -Lab 04 -Only L04-mcp-config

This 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:

config/cloud-agent-mcp.template.json (lines 1-16)
{
"$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”
Windows only
  1. In File Explorer, open fabric\ContosoPharmacy.pbip.
  2. In Power BI Desktop, select Home > Refresh and wait for the refresh to finish.
  3. Leave Desktop open. The MCP server discovers the Analysis Services instance that Desktop starts for the model.
Terminal window
pwsh ./scripts/lab/Test-LabProgress.ps1 -Lab 04 -Only L04-desktop

You 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.

  1. Open the Command Palette: Ctrl+Shift+P (macOS: Cmd+Shift+P), or View > Command Palette.
  2. Run MCP: List Servers.
  3. Select powerbi-modeling-mcp.
  4. Choose Start Server. If VS Code says the server is disabled, choose Enable first.
  5. 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”
  1. Open Copilot Chat: Ctrl+Alt+I (macOS: Ctrl+Cmd+I), or View > Chat.
  2. Switch the chat mode to Agent from the mode picker in the chat input.
  3. Select Configure Tools in the chat input.
  4. Expand powerbi-modeling-mcp.
  5. 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:

  1. Open MCP: List Servers from View > Command Palette.
  2. Select powerbi-modeling-mcp.
  3. 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.

Run this from the repo root in a PowerShell 7 terminal (Terminal > New Terminal in VS Code):

Terminal window
pwsh ./scripts/lab/Test-LabProgress.ps1 -Lab 04

When everything is done you should see:

Expected output
PASS L04-mcp-config .vscode/mcp.json parses, has the Power BI Modeling MCP server, and no secret values
PASS 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.

CheckWhat it looks atIf it fails
L04-mcp-config.vscode/mcp.json parses, has the Power BI Modeling MCP server, and no secret valuesRestore .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 toOpen fabric\ContosoPharmacy.pbip in Power BI Desktop. Go to step 3
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.

Where does this repo define the shared MCP server configuration?

Show the answer

In .vscode/mcp.json, committed with the workspace.

The workspace .vscode/mcp.json is the shared config. User settings can add more servers, but they are not part of the lab repo.

Why do you approve MCP tool calls one by one?

Show the answer

Tool approval lets you review what external code or data access the agent is about to use.

MCP tools can read data or change a model. Approval is the moment to reject a call that is out of scope.

What can macOS learners do in this lab?

Show the answer

Use file mode and the TMDL checks, while skipping Desktop-only live DAX steps.

Power BI Desktop is Windows-only. Most repo checks read files, so macOS learners can continue in file mode and use a Windows machine for Desktop-specific checks.

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.

Next: Lab 05: Your first custom agent: question-tester, before

  • Start the optional fabric-mcp server 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 npx path, then disable one server so the tool list stays clean.