MCP
Why MCP matters here
Section titled “Why MCP matters here”Model Context Protocol gives Copilot tools that are not just text editing. In this lab, MCP lets an agent inspect or edit a Power BI model through supported tools instead of guessing from file text only.
The repo has two MCP files:
| File | Use |
|---|---|
.vscode/mcp.json | Local VS Code workspace MCP. |
config/cloud-agent-mcp.template.json | Template for GitHub repository MCP settings used by cloud agent and code review. |
VS Code workspace config
Section titled “VS Code workspace config”{ // 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 primary server is powerbi-modeling-mcp. It runs npx with @microsoft/powerbi-modeling-mcp@0.5.0-beta.13 and starts the MCP server. It can work with the PBIP folder and, on Windows, the model open in Power BI Desktop.
The optional fabric-mcp server runs @microsoft/fabric-mcp@1.4.0. The config says to start it from the MCP view only when you want it. Its docs tools can work without a tenant, but workspace operations need Fabric access.
Power BI Modeling MCP
Section titled “Power BI Modeling MCP”Power BI Modeling MCP can inspect a PBIP project and connect to an open Power BI Desktop model. Use it when you need model structure, measures, relationships, or Desktop-backed semantic model operations.
Local prerequisites:
- Windows.
- Power BI Desktop installed.
- The PBIP open in Desktop when you need live model operations.
- Workspace trust accepted in VS Code.
- MCP tool approval accepted for the specific tool call.
Optional Fabric MCP
Section titled “Optional Fabric MCP”Fabric MCP is for tenant and workspace operations. It is not required for this lab. The core lab validates locally from files and generated CSVs, so learners do not need a Fabric tenant.
If you enable Fabric MCP, keep secrets out of source. Use environment variables, VS Code inputs, or the GitHub MCP secret flow.
Cloud agent MCP template
Section titled “Cloud agent MCP 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": [ "*" ] }, "fabric-mcp": { "type": "local", "command": "npx", "args": [ "-y", "@microsoft/fabric-mcp@1.4.0", "server", "start", "--mode", "all" ], "tools": [ "*" ] } }}GitHub repository MCP settings use a root mcpServers object. For cloud agent and code review, copy the template into the repository MCP settings UI and adjust only values your organization allows.
Cloud code review tools should be read-only. Do not give review tools write access to production services.
Secrets and inputs
Section titled “Secrets and inputs”Use ${input:name} in .vscode/mcp.json when a value should be requested locally.
{ "inputs": [ { "id": "fabricTenantId", "type": "promptString", "description": "Fabric tenant ID" } ]}Use environment variables when the tool can read them without putting the value in JSON.
{ "env": { "FABRIC_TENANT_ID": "${env:FABRIC_TENANT_ID}" }}For GitHub-hosted surfaces, use repository or organization MCP secrets and variables. GitHub documents COPILOT_MCP_ variables for MCP configuration.
Tool approval and trust
Section titled “Tool approval and trust”Expect two prompts:
- Workspace trust or MCP server trust. You are allowing VS Code or GitHub to start the server.
- Tool approval. You are allowing a specific tool call.
Approve narrowly. If an MCP server can write, review the arguments before approving.
When to use MCP instead of file edits
Section titled “When to use MCP instead of file edits”| Task | Best path |
|---|---|
| Rename columns and add descriptions in TMDL | File edits plus validation are usually enough. |
| Inspect live model metadata from Desktop | Power BI Modeling MCP. |
| Compare Desktop state to PBIP files | Power BI Modeling MCP plus validation scripts. |
| Work with Fabric workspace assets | Fabric MCP, only with a tenant and approved auth. |
| Cloud PR review | Repository MCP settings, read-only tools only. |