Metadata-Version: 2.4
Name: pbi-doc-generator
Version: 1.2.0
Summary: Power BI & Microsoft Fabric Architecture Portal, Report X-Ray, Live Lineage & Local AI (MCP) Studio
Author-email: Rien Scheerlinck <dj.rien@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/djrien-ai/pbi-doc-generator
Project-URL: Live Demo, https://djrien-ai.github.io/pbi-doc-generator/
Project-URL: Repository, https://github.com/djrien-ai/pbi-doc-generator
Project-URL: Issues, https://github.com/djrien-ai/pbi-doc-generator/issues
Project-URL: Author LinkedIn, https://www.linkedin.com/in/rienscheerlinck/
Keywords: power-bi,microsoft-fabric,tmdl,pbix,pbip,documentation,data-lineage,mcp,dax,tabular-editor,governance
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Documentation
Classifier: Topic :: Database
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pbixray>=0.15.5
Requires-Dist: pandas<3.0.0,>=2.0.0
Requires-Dist: playwright>=1.40.0
Provides-Extra: all
Requires-Dist: pbixray>=0.15.5; extra == "all"
Requires-Dist: pandas<3.0.0,>=2.0.0; extra == "all"
Requires-Dist: playwright>=1.40.0; extra == "all"
Dynamic: license-file

# Power BI & Fabric Architecture Portal, Report X-Ray & Local AI (MCP) Studio

[![PyPI version](https://img.shields.io/pypi/v/pbi-doc-generator?color=025DA4&label=PyPI)](https://pypi.org/project/pbi-doc-generator/)
[![CI](https://github.com/djrien-ai/pbi-doc-generator/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/djrien-ai/pbi-doc-generator/actions/workflows/ci.yml)
[![Latest Release](https://img.shields.io/github/v/release/djrien-ai/pbi-doc-generator?label=Latest%20Release&color=0284c7)](https://github.com/djrien-ai/pbi-doc-generator/releases/latest)
[![GitHub Stars](https://img.shields.io/github/stars/djrien-ai/pbi-doc-generator?style=flat&logo=github&label=Stars&color=0f172a)](https://github.com/djrien-ai/pbi-doc-generator/stargazers)
[![Live Demo](https://img.shields.io/badge/Live_Demo-Explore_v1.2_Portal-2563eb)](https://djrien-ai.github.io/pbi-doc-generator/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B-3776AB.svg)](https://www.python.org/)
[![100% Local & Read-Only](https://img.shields.io/badge/Privacy-100%25_Local_%26_Read--Only-0f766e.svg)](SECURITY.md)
[![djrien-ai/pbi-doc-generator MCP server](https://glama.ai/mcp/servers/djrien-ai/pbi-doc-generator/badges/score.svg)](https://glama.ai/mcp/servers/djrien-ai/pbi-doc-generator)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-Rien_Scheerlinck-0A66C2?logo=linkedin&logoColor=white)](https://www.linkedin.com/in/rienscheerlinck/)
[![Support on Ko-fi](https://img.shields.io/badge/Support_on_Ko--fi-Buy_me_a_coffee-FF5E5B?logo=ko-fi&logoColor=white)](https://ko-fi.com/rienscheerlinck)

[**Live Interactive Demo**](https://djrien-ai.github.io/pbi-doc-generator/) &bull; [**Download Windows `.zip` (No Python)**](https://github.com/djrien-ai/pbi-doc-generator/releases/latest/download/PBI_Doc_Generator_Windows_Portable.zip) &bull; [**Quick Start (`pip install`)**](#quick-start) &bull; [**Ask AI (Copilot / Claude MCP)**](#talk-to-your-power-bi-estate-local-mcp-server) &bull; [**Built for Both Worlds**](#built-for-both-worlds) &bull; [**Security**](SECURITY.md) &bull; [**Roadmap**](ROADMAP.md)

Turn **Power BI Pro / Premium**, **Microsoft Fabric** (Direct Lake, Dataflow Gen2, PySpark/SQL Notebooks), and local **`.pbix` / `.pbip` / `.xlsx`** files into an offline interactive architecture portal with **16:9 Report X-Ray**, **Live End-to-End Lineage**, and **Governance Audits**. Connect the built-in **14-tool local MCP server** to **VS Code Copilot, Claude, and Cursor** so your AI assistant can trace KPIs to SQL, diff `DEV` vs. `PROD`, and generate safe Tabular Editor `.csx` cleanup scripts 100% locally.

![pbi-doc-generator Interactive Portal, Report X-Ray & Live Lineage Walkthrough](docs/media/v1_1_showcase_walkthrough.gif)

> [!TIP]
> **Try `v1.2.0` in 30 Seconds**
> - **Interactive Browser Demo (Zero Install):** [**Explore the Live `v1.2` Architecture Portal**](https://djrien-ai.github.io/pbi-doc-generator/)
> - **Via PyPI (Windows / macOS / Linux):** `pip install pbi-doc-generator` -> run `pbi-doc-generator` *(package on [PyPI](https://pypi.org/project/pbi-doc-generator/))*
> - **Windows Portable (No Python required):** [**Download `PBI_Doc_Generator_Windows_Portable.zip`**](https://github.com/djrien-ai/pbi-doc-generator/releases/latest/download/PBI_Doc_Generator_Windows_Portable.zip) -> Extract All -> run `PBI_Doc_Generator.exe`

---

## Built for Both Worlds

Most Power BI tools stop at a single `.pbix` file, while Power BI's native Lineage View stops at the container boundary (`Dataflow -> Semantic Model -> Report`) without showing which SQL query, Fabric Notebook, column, or DAX measure drives which visual. `pbi-doc-generator v1.2` serves both classic Power BI estates and modern Microsoft Fabric lakehouses inside one calm **4-tab offline portal**:

### For Power BI Pro & Premium Developers
- **16:9 Report X-Ray & Broken Visual Stepper:** Click any report (`PBIR` or legacy `report.json`) to open a slide-over wireframe inspector showing visual bindings, thin-report local DAX (`reportExtensions.json`), and a 1-click stepper highlighting visuals pointing to deleted or renamed fields.
- **RLS-Bypass Security Radar:** Cross-checks every RLS-protected semantic model against workspace `Admin`, `Member`, and `Contributor` roles that silently bypass Row-Level Security, flagging critical findings (with automatic principal redaction in `--anonymous` mode).
- **Hidden/Locked Hardcoded Filter & Stale Bookmark Detector:** Surfaces `isHiddenInViewMode` / `isLockedInViewMode` hardcoded filters at report, page, and visual scope alongside filter-restoring or stale bookmarks that silently override viewer numbers.
- **Implicit Measures, Visual Overload (`>15`) & Custom Visuals Inventory:** Detects raw-column implicit aggregations (`Sum`, `Count`, etc.), flags overloaded pages with `>15` non-decorative visuals, and maintains a clean inventory of third-party AppSource/custom visuals across the estate.
- **Unused Field Auditing + 1-Click Tabular Editor `.csx` Cleanup:** Audits columns and DAX measures across intra-model references and scanned bound reports, then exports a safe, leaf-first Tabular Editor 2/3 `.csx` cleanup script (defaulting to non-destructive `hide` with deprecation tags).
- **`DEV` vs. `PROD` Breaking-Change Diff (`pbi-doc-generator diff`):** Compares tables, columns, DAX measures, relationships, partitions, and RLS roles across environments and lists every `PROD` report visual that would break on deployment.
- **Opt-In `--pro-export-fallback` for Restricted Pro Workspaces:** When tenant switches or legacy Pro metadata block `getDefinition`, opt into the read-only `Export?downloadType=IncludeModel` bridge (temporary `.pbix` is parsed in-memory/temp dir and deleted immediately).
- **Zero-Python Windows Portable `.zip` or `pip install pbi-doc-generator`:** Run on locked-down corporate laptops with zero Azure Admin setup.

### For Microsoft Fabric Engineers
- **End-to-End Bronze -> Silver -> Gold Medallion Lineage:** Automatically parses **Fabric PySpark & Spark SQL Notebooks** (`notebook-content.py` / `.ipynb` - *Preview* for live Fabric API, 100% locally testable via Fabric Git folders) using a pure-Python AST and CTE-aware SQL parser (`spark.read.table`, `saveAsTable`, `DeltaTable.forName().merge()`, `MERGE INTO`, `# META default_lakehouse`).
- **Lakehouse & Warehouse Delta Tables (Including Standalone Tables):** Inventories Lakehouse and Warehouse Delta tables and SQL DDL views/procedures, connecting upstream medallion stages even before a semantic model consumes them.
- **Fabric Dataflow Gen2, Direct Lake & Auto Vertical Swimlanes:** Connects Dataflow Gen2 (`mashup.pq` + Lakehouse/Warehouse destinations) and Direct Lake `entityName` partitions straight into semantic models and thin reports. When a catalog spans 6+ medallion layers, Live Lineage automatically switches to **Vertical Swimlanes** while pure Power BI estates stay in the classic 5-column horizontal layout.
- **Zero-Dependency Star-Schema Explorer & Scoped Exports:** Native HTML+SVG Star-Schema diagrams, A4 portrait PDF export with stacked vector schemas, Word/Markdown/CSV Data Dictionaries, single-file SharePoint HTML (`export-site`), and 1-click SharePoint Document Library upload.

---

## Talk to Your Power BI Estate (Local MCP Server)

Connect **VS Code GitHub Copilot**, **Claude Desktop**, **Cursor**, **Claude Code**, or **Antigravity** directly to your local catalog (`pbi-doc-generator mcp`) with zero cloud data exposure.

### 5 Things to Ask Your AI Right Away

1. **Breaking-Change Blast Radius:**
   > *"If we rename or drop column `DeliveryDate` in `CV_SD_DELIVERY_OTIF`, trace every affected Dataflow, Fabric Lakehouse table, semantic model, DAX measure, and Power BI report visual across the catalog."*
2. **Unused Bloat Audit + Tabular Editor `.csx` Cleanup:**
   > *"Find all unused columns and DAX measures in `Global Supply Chain & OTIF Core` and generate a safe hide-first Tabular Editor (`.csx`) cleanup script."*
3. **Pre-Release `DEV` vs. `PROD` Breaking-Change Diff:**
   > *"Compare `Global Supply Chain & OTIF Core` in workspace `Enterprise Core Semantic Models` against `Supply Chain - DEV`, highlight breaking column or DAX changes, and list every PROD report visual that would break."*
4. **Silent RLS-Bypass & Hidden Filter Security Audit:**
   > *"Audit our catalog for silent RLS bypasses (workspace Admin/Member/Contributor roles), hidden or locked hardcoded report filters, stale bookmarks, and implicit measures."*
5. **End-to-End KPI Markdown Specification:**
   > *"Generate an audit-ready Markdown lineage specification for `OTIF %` tracing every dependent DAX measure, Power Query step, Dataflow, Fabric Notebook, and SQL source."*

### 14 MCP Tools, 4 Built-In Slash Prompts & Bundled `SKILL.md`

- **Honest Read-Only Disclosure:** **13 of the 14 MCP tools are strictly read-only** (`readOnlyHint: true`). Only `pbi_generate_portal` writes files, and exclusively to your local `<catalog_dir>/portal/` folder. Zero Power BI Service write APIs exist anywhere in the codebase, and all secrets (passwords, SAS tokens, API keys, bearer tokens) are automatically masked.
- **4 Built-In MCP Slash Prompts (`prompts/list` & `prompts/get`):**
  - `audit-semantic-model` - Full architecture, governance, RLS, broken-ref, and bloat review
  - `trace-breaking-change` - Multi-layer blast radius before a DB, view, or Dataflow change
  - `find-unused-bloat` - Unused column/measure review (enforcing `has_parsed_layouts`) + `.csx` script
  - `explain-dax-chain` - Combines upstream-to-SQL trace with downstream dependent KPIs
- **Bundled Agent Playbook (`SKILL.md`):** Ships at repository root ([SKILL.md](SKILL.md)), inside the Python package (`pbi_catalog/resources/SKILL.md`), and via **Studio Mode 3 (`Ask AI (MCP)`)** with 1-click Copy/Download and an in-process **MCP Self-Test** button.

### Client Configuration (Canonical Server Key: `"pbi-doc-generator"`)

#### VS Code GitHub Copilot (`.vscode/mcp.json`)
```json
{
  "servers": {
    "pbi-doc-generator": {
      "type": "stdio",
      "command": "pbi-doc-generator",
      "args": ["mcp"]
    }
  }
}
```

#### Claude Desktop (`claude_desktop_config.json`) & Cursor (`~/.cursor/mcp.json`)
```json
{
  "mcpServers": {
    "pbi-doc-generator": {
      "command": "pbi-doc-generator",
      "args": ["mcp"]
    }
  }
}
```

#### Claude Code CLI
```bash
claude mcp add pbi-doc-generator -- pbi-doc-generator mcp
```

*(Using the Windows Portable `.zip` instead of `pip`? Point `"command"` to `"C:\\path\\to\\PBI_Doc_Generator\\PBI_Doc_Generator.exe"` with `"args": ["mcp"]`. Override the catalog directory with `"env": { "PBI_CATALOG_DIR": "/path/to/catalog" }` if needed.)*

<details>
<summary><b>Complete 14-Tool MCP Reference (Click to expand)</b></summary>

> **Choosing the right lineage tool:** Use **`pbi_get_measure_lineage`** for fast, DAX-layer-only **BIDIRECTIONAL** lineage (direct columns, base measures, **downstream dependent KPIs**, and bound reports). Use **`pbi_trace_measure_end_to_end`** for deep, **UPSTREAM-ONLY** multi-hop lineage back through Power Query M, Dataflows (Gen1/Gen2), Fabric Notebooks/Lakehouse Delta tables, and Native SQL.

| Tool | Read-Only | Purpose |
| --- | :---: | --- |
| `pbi_get_catalog_summary` | Yes | Step 1 orientation: counts of workspaces, models, reports, Dataflows, Fabric items, tables, measures, and connectors. |
| `pbi_list_models` | Yes | Step 2 inventory: model names, dataset GUIDs, workspaces, refresh status, and health finding counts. |
| `pbi_inspect_model` | Yes | Step 3 blueprint: table summaries, relationships, RLS/OLS roles, upstream Dataflows, and governance findings. |
| `pbi_inspect_table` | Yes | Step 4 deep inspection: full column metadata/usage (`all`/`used`/`unused`/`calculated`/`hidden`), hosted DAX measures, complete unclipped M code, native SQL, hierarchies, calculation items, and relationships. |
| `pbi_search_dax_and_m` | Yes | Full-text substring search across DAX measures, calculated columns, model M partitions, Dataflow queries, and Native SQL (with `total_matches` and `truncated` disclosure). |
| `pbi_trace_source_impact` | Yes | Downstream blast radius from a physical server, database, view, SharePoint site, or Dataflow to impacted Dataflows, tables, models, DAX measures, and reports. |
| `pbi_get_measure_lineage` | Yes | Fast DAX-layer **BIDIRECTIONAL** lineage: direct columns, base measures, **downstream dependent KPIs**, and bound reports. |
| `pbi_trace_measure_end_to_end` | Yes | Deep **UPSTREAM-ONLY** multi-hop KPI specification (Markdown or JSON) from DAX through M, Dataflows, Fabric Notebooks/Lakehouses, and Native SQL. |
| `pbi_inspect_report_layout` | Yes | Inspect PBIR/PBIX pages, visual bindings, hidden/locked filters, stale bookmarks, thin-report DAX, and broken references (with optional literal redaction). |
| `pbi_audit_catalog_health` | Yes | Catalog-wide governance triage across refresh failures, staleness, non-prod endpoints, RLS bypasses, hidden filters, implicit measures, visual overload, and broken refs. |
| `pbi_find_unused_fields` | Yes | Audit one semantic model for unused columns and DAX measures (enforces `has_parsed_layouts` safety guard). |
| `pbi_generate_cleanup_script` | Yes | Generate a reviewable, leaf-first Tabular Editor 2/3 C# (`.csx`) script (`action="hide"` default or `"delete"`, supports `dry_run_comment`, allow/deny lists). Does not touch disk or live models. |
| `pbi_diff_model` | Yes | Compare two catalog models (e.g. `PROD` vs. `DEV`) across schema, DAX, M, relationships, and RLS, classifying breaking changes and impacted base reports. |
| `pbi_generate_portal` | Local disk only | Rebuild offline static HTML/CSS/JS portal under `<catalog_dir>/portal/` (zero Power BI Service calls). |

*Legacy v1.1 tool names (`pbi_catalog_summary`, `pbi_source_impact`, `pbi_measure_lineage`, `pbi_report_layout`, `pbi_health_audit`) remain silently accepted by `tools/call` for backwards compatibility.*

</details>

---

## Quick Start

### Option 1: Install from PyPI (Python 3.10+ on Windows, macOS & Linux)

```bash
pip install pbi-doc-generator
pbi-doc-generator
```

*(Tip on Windows if `pip` or Python's `Scripts` folder is not on `PATH`: run `py -m pip install pbi-doc-generator` and start with `py -m pbi_catalog`. Or clone the repo and double-click **`Start_Studio.cmd`**.)*

### Option 2: Portable Windows Download (No Python Required)

1. [**Download `PBI_Doc_Generator_Windows_Portable.zip` (Latest Stable Release)**](https://github.com/djrien-ai/pbi-doc-generator/releases/latest/download/PBI_Doc_Generator_Windows_Portable.zip) *(or view the [Latest Release page](https://github.com/djrien-ai/pbi-doc-generator/releases/latest))*.
2. Right-click the downloaded ZIP file and choose **Extract All...**
3. Open the extracted folder and double-click **`PBI_Doc_Generator.exe`** -> your browser opens **`http://127.0.0.1:8765`** automatically.

> [!NOTE]
> **Power BI Service Workspace Role Prerequisite (`Contributor` or higher)**
> Extracting semantic model TMDL, Dataflow definitions, and cloud report layouts via Microsoft's read-only `getDefinition` API requires at least **Contributor** (**Contributor**, **Member**, or **Admin**) in the target workspace. `Viewer`-only workspaces still return workspace and report inventory. For restricted Pro workspaces where `getDefinition` is blocked by tenant switches or legacy metadata, pass the opt-in `--pro-export-fallback` flag (or enable it in Studio Mode 1) to use the read-only `.pbix` export bridge. Local `.pbix`, `.pbip`, `.xlsx`, and Fabric Git folders require no Power BI Service permissions.

---

## Command-Line Usage (CLI & CI/CD)

```bash
# Launch the interactive Web Studio on http://127.0.0.1:8765 (default)
pbi-doc-generator

# Scan specific workspaces (add --follow-outside for cross-workspace upstream models/dataflows)
pbi-doc-generator scan --workspace "Supply Chain" --follow-outside

# Scan restricted Pro workspaces using opt-in read-only .pbix export fallback
pbi-doc-generator scan --workspace "Sales Pro" --pro-export-fallback

# Scan workspaces while skipping Fabric Notebook & Lakehouse/Warehouse API extraction
pbi-doc-generator scan --workspace "Supply Chain" --no-fabric-notebooks

# Compare two models in the catalog (e.g. PROD vs. DEV) with breaking-change report impact
pbi-doc-generator diff "Global Supply Chain & OTIF Core" "Global Supply Chain & OTIF Core (DEV)" \
  --base-workspace "Enterprise Core Semantic Models" --target-workspace "Supply Chain - DEV"

# Import a local .pbip, .SemanticModel, .pbix, .xlsx, or Fabric Git workspace folder
pbi-doc-generator import-local ./FabricGitWorkspace

# Generate an anonymized portal safe for external sharing (redacts owner/user names & filter literals)
pbi-doc-generator portal --anonymous

# Package the entire portal into a single SharePoint-safe HTML file
pbi-doc-generator export-site -o ./PBI_Catalog_SharePoint.html

# Export a deep end-to-end SQL -> Fabric Notebook -> Dataflow -> Power Query -> DAX lineage spec
pbi-doc-generator measure-doc "OTIF %" --model "Global Supply Chain & OTIF Core" -o ./OTIF_Lineage.md

# Start the local stdio MCP server (14 tools & 4 slash prompts) for AI assistants
pbi-doc-generator mcp
```

---

## Security & Privacy by Design

- **100% Local Execution:** Metadata, TMDL/PBIR/Notebook definitions, and generated HTML stay on your machine (`127.0.0.1`). Zero telemetry or external CDN calls.
- **Hardcoded Read-Only Power BI API Guard:** `PowerBiReadOnlyClient` blocks `DELETE`, `PATCH`, `PUT`, and mutating `POST` calls at the transport layer (including binary export requests), allowing only `GET` metadata/export endpoints and read-only `getDefinition` calls.
- **In-Memory Tokens Only:** OAuth access tokens live strictly in Python RAM for the active session and are never written to disk.
- **Automatic Secret & Storage Redaction:** Connection passwords, SAS signatures, API keys, bearer tokens, and internal Dataflow storage URLs are automatically masked or stripped. See [SECURITY.md](SECURITY.md) for details.

---

## Enterprise Integrations & Architecture Audits

The core of `pbi-doc-generator` is and remains 100% free and open-source under the MIT License. Organizations looking for custom enterprise integrations (automated CI/CD lineage publishing to SharePoint, Confluence, or Microsoft Purview, historical semantic-model drift monitoring, or white-label governance portals) or an independent **Power BI Estate & Semantic Model Architecture Audit** can connect with **Rien Scheerlinck** ([LinkedIn](https://www.linkedin.com/in/rienscheerlinck/) | **Bohan VOF**):

[![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Rien_Scheerlinck-0A66C2?logo=linkedin&logoColor=white)](https://www.linkedin.com/in/rienscheerlinck/)
[![Inquire via Email - Bohan VOF](https://img.shields.io/badge/Enterprise_&_Advisory_Inquiries-Email_Bohan_VOF-0b63ce?logo=gmail&logoColor=white)](mailto:dj.rien@gmail.com?subject=Power%20BI%20Enterprise%20%26%20Architecture%20Inquiry)

---

## Community & Support

Created and maintained by [Rien Scheerlinck](https://www.linkedin.com/in/rienscheerlinck/) (`@djrien-ai`), with thanks to community contributors `@andreasfelder` (PR #19 contributions toward #13/#14 Dataflow Gen1, thin-report parsing & single-file SharePoint export), `@jakubpokusa` (PR #10 relationship viewer), `@okiyuki99` (PR #11 Xpress9 `pbixray` support), and `@nblankes` (Issue #12 TMDL table doc-comment report).

If `pbi-doc-generator` saves your BI team hours of manual documentation or impact analysis, consider starring the repository or [**supporting ongoing open-source development on Ko-fi**](https://ko-fi.com/rienscheerlinck).

## License

MIT License - Copyright (c) 2024-2026 Rien Scheerlinck. See [LICENSE](LICENSE) for full text.
