Skip to content
| Marketplace
Sign in
Visual Studio Code>Data Science>PBI Lens (Power BI Viewer + MCP)New to Visual Studio Code? Get it now.
PBI Lens (Power BI Viewer + MCP)

PBI Lens (Power BI Viewer + MCP)

duckduck_beps

|
1 install
| (1) | Free
View Power BI reports inside VS Code — and let your AI agent see them too
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

PBI Lens

View Power BI reports inside VS Code — and let Claude (or any AI agent) actually see them: screenshot pages, set filters/slicers, query the data with DAX, edit the report source, and republish. Built for fully automated agent loops. Works with a free Power BI license via My Workspace (-w my); Pro only needed for shared workspaces, Premium never.

Costs

Sign-in, tokens and all API calls used here are free of charge. The only thing Microsoft charges for is a Pro license, and that's only required for shared workspaces. The free path:

  1. Sign up for a free Power BI license with any work/school account (e.g. a university account) at powerbi.microsoft.com — no credit card.
  2. Use -w my everywhere (or pbi-lens use -w my once). Publish, screenshot, DAX — all against your personal My Workspace.

How it works

Power BI Desktop can't be screenshotted reliably (WebView2 canvas) and the export-to-PNG API needs Premium. So PBI Lens uses the Pro-compatible path:

  1. You publish your report to a Power BI Service workspace (one click in Desktop, or pbi-lens publish).
  2. PBI Lens embeds it via the powerbi-client SDK ("user owns data", your own AAD token) in a local page.
  3. For you: a VS Code webview shows the live interactive report.
  4. For Claude: headless Chromium renders the same page; the CLI screenshots it to PNG, which Claude reads as an image.
packages/core     auth (MSAL device code), Power BI REST, embed host, Playwright capture
packages/cli      `pbi-lens` CLI — the agent-facing surface
packages/vscode   VS Code extension — the human-facing viewer
packages/mcp      MCP server — gives Claude / Copilot / Codex the report info on demand

Install the extension (any PC)

  1. Download pbi-lens-vscode-<version>.vsix from this repo's Releases page.
  2. In VS Code: Extensions panel → ⋯ menu → Install from VSIX... (or code --install-extension pbi-lens-vscode-0.2.0.vsix).
  3. A Power BI Reports tree appears in the Explorer sidebar — sign in there, then click any workspace → report → page to open it live. (Command Palette still works: PBI Lens: Sign in / Open Report / Capture Page.)

Requirements on the target PC: VS Code, Microsoft Edge or Chrome (Edge ships with Windows — used headlessly for captures), and a Power BI work account with a Pro license. No Node.js needed for the extension.

To rebuild the .vsix: npm run package:vsix.

Dev setup (this repo, CLI included)

npm install
npm run build
node packages/cli/dist/index.js login    # device code sign-in (work account with Pro)

Optionally link the CLI globally: npm link -w pbi-lens → pbi-lens on PATH. Captures use your installed Edge/Chrome — no browser download.

Auth uses the Azure CLI well-known client id by default (pre-consented in most tenants). If your tenant blocks it, register an Entra app (public client, delegated Power BI scopes) and run pbi-lens login --client-id <id> --tenant <tenantId>.

CLI

pbi-lens doctor                              # preflight: browser, assets, offline capture test, sign-in state
pbi-lens ls                                  # workspaces
pbi-lens ls -w "My Workspace"                # reports
pbi-lens ls -w "My Workspace" -r "Sales"     # pages
pbi-lens ls -w "My Workspace" -r "Sales" -p "Overview"   # visuals
pbi-lens use -w my -r "Sales"                # save defaults, then omit -w/-r ("my" = My Workspace, free license)

pbi-lens shot -p "Overview" -o overview.png
pbi-lens shot --all-pages -o shots/
pbi-lens shot -p "Overview" --visual "Revenue by Month" -o rev.png
pbi-lens shot -p "Overview" --filter '[{"$schema":"http://powerbi.com/product/schema#basic","target":{"table":"Region","column":"Name"},"operator":"In","values":["EMEA"],"filterType":1}]' -o emea.png

pbi-lens dax "EVALUATE SUMMARIZECOLUMNS(Region[Name], \"Rev\", [Total Revenue])"
pbi-lens publish dist/report.pbix -w "My Workspace"

# Structured info (what an AI usually needs) — all support --json
pbi-lens context -p "Overview"               # one-shot orientation: pages, visuals + field bindings, model, filters
pbi-lens model                               # tables, columns, measures, relationships (DAX INFO.VIEW.*)
pbi-lens fields -p "Overview"                # which column/measure is on which axis/role, per visual
pbi-lens data --visual "Revenue by Month"    # a visual's data points as CSV
pbi-lens filters -p "Overview"               # active filter + slicer state

Give your AI the plug (MCP)

packages/mcp is an MCP server with 16 tools (get_report_context, get_visual_fields, get_model, run_dax, get_visual_data, get_filters, screenshot_page, set_filters, publish_pbix, refresh_report, ...). Screenshots come back as real images the AI can see; all JSON outputs are token-lean (compact, noise-free — the model schema alone is ~84% smaller than the raw API shape). Publishing auto-reloads the warm render session, so post-edit screenshots are never stale. It works in every MCP-capable agent:

  • Claude Code: claude mcp add --scope user pbi-lens -- node <repo>/packages/mcp/dist/index.js (already registered on this machine; the repo also has a project-scope .mcp.json).
  • GitHub Copilot Chat (VS Code): .vscode/mcp.json in this repo, or user-wide in %APPDATA%\Code\User\mcp.json (already set up on this machine). Enable agent mode to see the tools.
  • Codex CLI: add to ~/.codex/config.toml:
    [mcp_servers.pbi-lens]
    command = "node"
    args = ["C:\\pbi-lens\\packages\\mcp\\dist\\index.js"]
    

All tools default to the workspace/report saved via pbi-lens use, and the server keeps a warm browser session per report so consecutive calls are fast.

VS Code extension

F5 in this repo launches the Extension Development Host. Commands:

  • PBI Lens: Sign in to Power BI
  • PBI Lens: Open Report — live interactive report in a webview panel
  • PBI Lens: Capture Page for Claude (PNG) — saves to .pbi-shots/ in your workspace

Settings pbiLens.workspace / pbiLens.report skip the pickers.

The agent loop

See CLAUDE.md (mirrored as AGENTS.md for Codex). Short version: the agent calls get_report_context to orient, digs into specifics with get_visual_fields / run_dax, edits the PBIP/PBIR report source, republishes, re-screenshots, and verifies — no human eyes required.

Local Desktop DAX (optional)

While a .pbix is open, Power BI Desktop runs a local Analysis Services instance. For model iteration without publishing, install the open-source mcpbi MCP server, which connects to it and gives Claude direct local DAX. Port discovery: %LocalAppData%\Microsoft\Power BI Desktop\AnalysisServicesWorkspaces\*\Data\msmdsrv.port.txt.

Limits to know

  • executeQueries: 120 queries/min, 100k rows, 15 MB per query (Pro limits).
  • Renders take ~4–8 s per page; the capture session reuses one browser for multi-page shots.
  • Desktop does not hot-reload external PBIP edits — close/reopen the project after Claude edits report JSON.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft