pbi-mcp-server 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. pbi_mcp_server-0.3.0/.github/workflows/ci.yml +54 -0
  2. pbi_mcp_server-0.3.0/.github/workflows/publish.yml +104 -0
  3. pbi_mcp_server-0.3.0/.gitignore +48 -0
  4. pbi_mcp_server-0.3.0/AGENTS.md +15 -0
  5. Ticket Backlog.pdf +0 -0
  6. pbi_mcp_server-0.3.0/Dockerfile +29 -0
  7. pbi_mcp_server-0.3.0/GLOSSARY.md +61 -0
  8. pbi_mcp_server-0.3.0/LICENSE +674 -0
  9. pbi_mcp_server-0.3.0/PKG-INFO +202 -0
  10. pbi_mcp_server-0.3.0/README.md +177 -0
  11. pbi_mcp_server-0.3.0/docker-compose.yml +14 -0
  12. pbi_mcp_server-0.3.0/docs/adr/0001-src-layout-consolidation.md +3 -0
  13. pbi_mcp_server-0.3.0/docs/adr/0002-visual-field-abstraction-and-tool-pruning.md +3 -0
  14. pbi_mcp_server-0.3.0/docs/adr/0003-post-write-validation-and-rollback.md +3 -0
  15. pbi_mcp_server-0.3.0/docs/adr/0004-powerbi-analyst-toolkit.md +7 -0
  16. pbi_mcp_server-0.3.0/docs/adr/0005-phased-hardening-and-cross-layer-lineage.md +30 -0
  17. pbi_mcp_server-0.3.0/docs/adr/0006-partition-sql-codec-and-progressive-editing.md +24 -0
  18. pbi_mcp_server-0.3.0/docs/agent-workflows.md +58 -0
  19. pbi_mcp_server-0.3.0/docs/agents/domain.md +51 -0
  20. pbi_mcp_server-0.3.0/docs/agents/issue-tracker.md +50 -0
  21. pbi_mcp_server-0.3.0/docs/agents/triage-labels.md +15 -0
  22. pbi_mcp_server-0.3.0/npm/LICENSE +674 -0
  23. pbi_mcp_server-0.3.0/npm/README.md +41 -0
  24. pbi_mcp_server-0.3.0/npm/bin/pbi-mcp-server.js +6 -0
  25. pbi_mcp_server-0.3.0/npm/lib/launcher.js +299 -0
  26. pbi_mcp_server-0.3.0/npm/package.json +41 -0
  27. pbi_mcp_server-0.3.0/npm/test/launcher.test.mjs +139 -0
  28. pbi_mcp_server-0.3.0/pyproject.toml +78 -0
  29. pbi_mcp_server-0.3.0/sample_project.Report/definition.pbir +9 -0
  30. pbi_mcp_server-0.3.0/sample_project.Report/report.json +70 -0
  31. pbi_mcp_server-0.3.0/sample_project.SemanticModel/definition/model.tmdl +12 -0
  32. pbi_mcp_server-0.3.0/sample_project.SemanticModel/definition/relationships.tmdl +3 -0
  33. pbi_mcp_server-0.3.0/sample_project.SemanticModel/definition/tables/Customer.tmdl +38 -0
  34. pbi_mcp_server-0.3.0/sample_project.SemanticModel/definition/tables/Sales.tmdl +67 -0
  35. pbi_mcp_server-0.3.0/sample_project.SemanticModel/definition.pbism +4 -0
  36. pbi_mcp_server-0.3.0/sample_project.pbip +13 -0
  37. pbi_mcp_server-0.3.0/src/pbi_mcp_server/__init__.py +16 -0
  38. pbi_mcp_server-0.3.0/src/pbi_mcp_server/analyst.py +448 -0
  39. pbi_mcp_server-0.3.0/src/pbi_mcp_server/config.py +23 -0
  40. pbi_mcp_server-0.3.0/src/pbi_mcp_server/engine_a/__init__.py +1 -0
  41. pbi_mcp_server-0.3.0/src/pbi_mcp_server/engine_a/parser.py +385 -0
  42. pbi_mcp_server-0.3.0/src/pbi_mcp_server/engine_a/writer.py +414 -0
  43. pbi_mcp_server-0.3.0/src/pbi_mcp_server/engine_b/__init__.py +1 -0
  44. pbi_mcp_server-0.3.0/src/pbi_mcp_server/engine_b/parser.py +876 -0
  45. pbi_mcp_server-0.3.0/src/pbi_mcp_server/errors.py +101 -0
  46. pbi_mcp_server-0.3.0/src/pbi_mcp_server/integrity/__init__.py +1 -0
  47. pbi_mcp_server-0.3.0/src/pbi_mcp_server/integrity/references.py +26 -0
  48. pbi_mcp_server-0.3.0/src/pbi_mcp_server/integrity/validator.py +121 -0
  49. pbi_mcp_server-0.3.0/src/pbi_mcp_server/jinja_templates.py +460 -0
  50. pbi_mcp_server-0.3.0/src/pbi_mcp_server/lineage.py +710 -0
  51. pbi_mcp_server-0.3.0/src/pbi_mcp_server/logging_utils.py +80 -0
  52. pbi_mcp_server-0.3.0/src/pbi_mcp_server/m_codec.py +1142 -0
  53. pbi_mcp_server-0.3.0/src/pbi_mcp_server/main.py +171 -0
  54. pbi_mcp_server-0.3.0/src/pbi_mcp_server/meta_tools.py +269 -0
  55. pbi_mcp_server-0.3.0/src/pbi_mcp_server/models.py +199 -0
  56. pbi_mcp_server-0.3.0/src/pbi_mcp_server/mutation.py +199 -0
  57. pbi_mcp_server-0.3.0/src/pbi_mcp_server/pbip_references.py +173 -0
  58. pbi_mcp_server-0.3.0/src/pbi_mcp_server/server.py +804 -0
  59. pbi_mcp_server-0.3.0/src/pbi_mcp_server/service.py +1188 -0
  60. pbi_mcp_server-0.3.0/src/pbi_mcp_server/sql_edit.py +1764 -0
  61. pbi_mcp_server-0.3.0/src/pbi_mcp_server/sql_sections.py +739 -0
  62. pbi_mcp_server-0.3.0/src/pbi_mcp_server/tmdl_sql.py +1413 -0
  63. pbi_mcp_server-0.3.0/src/pbi_mcp_server/workflows.py +345 -0
  64. pbi_mcp_server-0.3.0/src/pbi_mcp_server/workspace.py +73 -0
  65. pbi_mcp_server-0.3.0/src/pbi_mcp_server/workspace_registry.py +498 -0
  66. pbi_mcp_server-0.3.0/templates/README.md +47 -0
  67. pbi_mcp_server-0.3.0/templates/gemma.jinja +82 -0
  68. pbi_mcp_server-0.3.0/templates/gemma4.jinja +76 -0
  69. pbi_mcp_server-0.3.0/templates/gpt_oss.jinja +73 -0
  70. pbi_mcp_server-0.3.0/templates/lfm2_5.jinja +81 -0
  71. pbi_mcp_server-0.3.0/templates/mellum2_1.jinja +74 -0
  72. pbi_mcp_server-0.3.0/templates/qwen.jinja +92 -0
  73. pbi_mcp_server-0.3.0/templates/qwen3_coder.jinja +83 -0
  74. pbi_mcp_server-0.3.0/tests/test_analyst_tools.py +83 -0
  75. pbi_mcp_server-0.3.0/tests/test_cte_and_batch_edits.py +1204 -0
  76. pbi_mcp_server-0.3.0/tests/test_enterprise_and_mcp_extensions.py +148 -0
  77. pbi_mcp_server-0.3.0/tests/test_mcp_server.py +57 -0
  78. pbi_mcp_server-0.3.0/tests/test_meta_tools_and_jinja.py +343 -0
  79. pbi_mcp_server-0.3.0/tests/test_packaging.py +48 -0
  80. pbi_mcp_server-0.3.0/tests/test_partition_sql_codec.py +630 -0
  81. pbi_mcp_server-0.3.0/tests/test_phase1_discovery.py +162 -0
  82. pbi_mcp_server-0.3.0/tests/test_phase2_and_3_lineage.py +164 -0
  83. pbi_mcp_server-0.3.0/tests/test_phase4_to_7_hardening.py +248 -0
  84. pbi_mcp_server-0.3.0/tests/test_sql_search.py +604 -0
  85. pbi_mcp_server-0.3.0/tests/test_sql_sections_and_outline.py +684 -0
  86. pbi_mcp_server-0.3.0/tests/test_tmdl_and_sql.py +129 -0
  87. pbi_mcp_server-0.3.0/tests/test_update_table_sql.py +703 -0
  88. pbi_mcp_server-0.3.0/tests/test_visuals.py +67 -0
  89. pbi_mcp_server-0.3.0/tests/test_workspace_registry.py +106 -0
  90. pbi_mcp_server-0.3.0/uv.lock +893 -0
@@ -0,0 +1,54 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ name: Pytest (${{ matrix.os }}, Python ${{ matrix.python-version }})
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ os: [ubuntu-latest, windows-latest]
17
+ python-version: ["3.11", "3.12"]
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v7
22
+
23
+ - name: Set up Python ${{ matrix.python-version }}
24
+ uses: actions/setup-python@v7
25
+ with:
26
+ python-version: ${{ matrix.python-version }}
27
+
28
+ - name: Install package and test dependencies
29
+ run: |
30
+ python -m pip install --upgrade pip
31
+ python -m pip install -e . --group dev
32
+
33
+ - name: Run pytest suite
34
+ run: python -m pytest -v
35
+
36
+ npm-launcher:
37
+ name: npm Launcher Tests (${{ matrix.os }})
38
+ runs-on: ${{ matrix.os }}
39
+ strategy:
40
+ fail-fast: false
41
+ matrix:
42
+ os: [ubuntu-latest, windows-latest]
43
+ steps:
44
+ - name: Checkout repository
45
+ uses: actions/checkout@v7
46
+
47
+ - name: Set up Node.js 22
48
+ uses: actions/setup-node@v7
49
+ with:
50
+ node-version: "22"
51
+
52
+ - name: Run npm launcher tests
53
+ working-directory: npm
54
+ run: npm test && npm pack --dry-run
@@ -0,0 +1,104 @@
1
+ name: Publish to PyPI and npm
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+ inputs:
8
+ dry_run:
9
+ description: "Build and validate packages without publishing"
10
+ type: boolean
11
+ default: true
12
+
13
+ jobs:
14
+ build-and-verify:
15
+ name: Build & Verify Packages
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - name: Checkout repository
19
+ uses: actions/checkout@v7
20
+
21
+ - name: Set up Python 3.12
22
+ uses: actions/setup-python@v7
23
+ with:
24
+ python-version: "3.12"
25
+
26
+ - name: Set up Node.js 22
27
+ uses: actions/setup-node@v7
28
+ with:
29
+ node-version: "22"
30
+
31
+ - name: Install Python test & build tools
32
+ run: |
33
+ python -m pip install --upgrade pip
34
+ python -m pip install -e . --group dev
35
+ python -m pip install build twine
36
+
37
+ - name: Run Python test suite
38
+ run: python -m pytest -v
39
+
40
+ - name: Run npm launcher tests
41
+ working-directory: npm
42
+ run: npm test
43
+
44
+ - name: Build Python sdist and wheel
45
+ run: |
46
+ python -m build
47
+ twine check dist/*
48
+
49
+ - name: Dry-run npm pack
50
+ working-directory: npm
51
+ run: npm pack --dry-run
52
+
53
+ - name: Upload Python dist artifacts
54
+ uses: actions/upload-artifact@v7
55
+ with:
56
+ name: python-dist
57
+ path: dist/
58
+
59
+ publish-pypi:
60
+ name: Publish to PyPI
61
+ needs: build-and-verify
62
+ if: ${{ github.event_name == 'release' || inputs.dry_run == false }}
63
+ runs-on: ubuntu-latest
64
+ environment:
65
+ name: pypi
66
+ url: https://pypi.org/p/pbi-mcp-server
67
+ permissions:
68
+ id-token: write
69
+ steps:
70
+ - name: Download Python dist artifacts
71
+ uses: actions/download-artifact@v8
72
+ with:
73
+ name: python-dist
74
+ path: dist/
75
+
76
+ - name: Publish distribution to PyPI (Trusted Publishing)
77
+ uses: pypa/gh-action-pypi-publish@release/v1
78
+
79
+ publish-npm:
80
+ name: Publish to npm
81
+ needs: [build-and-verify, publish-pypi]
82
+ if: ${{ github.event_name == 'release' || inputs.dry_run == false }}
83
+ runs-on: ubuntu-latest
84
+ environment:
85
+ name: npm
86
+ url: https://www.npmjs.com/package/pbi-mcp-server
87
+ permissions:
88
+ contents: read
89
+ id-token: write
90
+ steps:
91
+ - name: Checkout repository
92
+ uses: actions/checkout@v7
93
+
94
+ - name: Set up Node.js 22
95
+ uses: actions/setup-node@v7
96
+ with:
97
+ node-version: "22"
98
+ registry-url: "https://registry.npmjs.org"
99
+
100
+ - name: Publish npm launcher package
101
+ working-directory: npm
102
+ env:
103
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
104
+ run: npm publish --provenance --access public
@@ -0,0 +1,48 @@
1
+ # Python caches
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ /lib/
14
+ /lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ share/python-wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+
24
+ # Virtual environments
25
+ .venv/
26
+ venv/
27
+ ENV/
28
+ env/
29
+
30
+ # Pytest / Testing caches
31
+ .pytest_cache/
32
+ .coverage
33
+ htmlcov/
34
+ .mypy_cache/
35
+ .ruff_cache/
36
+
37
+ # IDE / OS files
38
+ .vscode/
39
+ .idea/
40
+ *.swp
41
+ *.swo
42
+ *~
43
+ .DS_Store
44
+
45
+ # Working files & scratch
46
+ scratch/
47
+ tmp/
48
+ *.log
@@ -0,0 +1,15 @@
1
+ # Agent Instructions
2
+
3
+ ## Agent skills
4
+
5
+ ### Issue tracker
6
+
7
+ GitHub issues at `jdestef90/PBI_MCP`. See `docs/agents/issue-tracker.md`.
8
+
9
+ ### Triage labels
10
+
11
+ Default triage labels (`needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`). See `docs/agents/triage-labels.md`.
12
+
13
+ ### Domain docs
14
+
15
+ Single-context (`GLOSSARY.md` + `docs/adr/`). See `docs/agents/domain.md`.
Ticket Backlog.pdf ADDED
Binary file
@@ -0,0 +1,29 @@
1
+ # syntax=docker/dockerfile:1
2
+ FROM python:3.11-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y --no-install-recommends \
9
+ git \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Install Python package management tools
13
+ RUN pip install --no-cache-dir uv
14
+
15
+ # Copy dependency definitions
16
+ COPY pyproject.toml uv.lock* ./
17
+
18
+ # Install project dependencies
19
+ ENV UV_SYSTEM_PYTHON=1
20
+ RUN uv pip install --system -r pyproject.toml
21
+
22
+ # Copy the rest of the application code
23
+ COPY . .
24
+
25
+ # Install the package itself
26
+ RUN uv pip install --system --no-deps -e .
27
+
28
+ # Default command to run the MCP server
29
+ ENTRYPOINT ["python", "-m", "pbi_mcp_server.main"]
@@ -0,0 +1,61 @@
1
+ # PBI MCP
2
+
3
+ Local-first MCP server for inspecting and safely editing Power BI PBIP projects.
4
+
5
+ ## Language
6
+
7
+ **Workspace**:
8
+ A resolved Power BI Project directory containing a `.pbip` file or paired `.Report` and `.SemanticModel` folders, identified by a deterministic `workspace_id`.
9
+ _Avoid_: Project folder, report root
10
+
11
+ **Semantic Model**:
12
+ The Tabular Model Definition Language (TMDL) metadata layer defining tables, columns, relationships, partitions, and measures.
13
+ _Avoid_: Dataset, data model
14
+
15
+ **Report Layout**:
16
+ The Power BI Enhanced Report Format (PBIR / PBIR-legacy) JSON structures defining pages, visuals, visual properties, and field bindings.
17
+ _Avoid_: Report template, canvas config
18
+
19
+ **Visual Field Binding**:
20
+ The association between a visual's visual roles (e.g. Y-axis, Tooltips, Values) and a Semantic Model measure or column.
21
+ _Avoid_: Visual property, data projection
22
+
23
+ **Visual Role**:
24
+ A designated data shelf on a visual (such as Category, Values, Legend, or Tooltips) that receives field bindings.
25
+ _Avoid_: Axis property, field bucket
26
+
27
+ **Dependency Graph**:
28
+ The directed cross-layer lineage graph connecting Partition SQL (`sql_table`, `sql_field`, `partition`) $\rightarrow$ Semantic Model (`table`, `column`, `calculated_column`, `measure`, `relationship`) $\rightarrow$ Report Layout (`visual`, `page`).
29
+ _Avoid_: Reference list, call tree
30
+
31
+ **Unused Object**:
32
+ A column or measure in the Semantic Model with zero references across all DAX formulas and Report Layout visual field bindings, or an indirectly referenced object belonging to a dead branch that never reaches a visual or relationship.
33
+ _Avoid_: Orphan field, dead code
34
+
35
+ **Mutation Pipeline**:
36
+ The standardized 7-stage write lifecycle (`resolve` $\rightarrow$ `analyze_impact` $\rightarrow$ `plan & diff` $\rightarrow$ `dry_run_preview` $\rightarrow$ `backup & apply` $\rightarrow$ `validate` $\rightarrow$ `rollback`) that enforces preconditions and produces unified diffs before modifying disk state.
37
+ _Avoid_: Direct file edit, blind overwrite
38
+
39
+ **Best Practice Analyzer (BPA)**:
40
+ Rule-based static analysis auditing both the Semantic Model and Report Layout for performance, relationship integrity, DAX quality, broken visual bindings, and modeling standards.
41
+ _Avoid_: Model linter, rule checker
42
+
43
+ **DAX Measure**:
44
+ A dynamic calculation defined in TMDL associated with a table.
45
+ _Avoid_: Metric formula, calculated field
46
+
47
+ **Partition SQL**:
48
+ The source SQL query embedded within a table's TMDL partition M-expression (e.g., `Value.NativeQuery`, `Databricks.Query`, or `Sql.Database`).
49
+ _Avoid_: DirectQuery script, source query
50
+
51
+ **Clean SQL View**:
52
+ The M-decoded, line-numbered representation of a table's Partition SQL that serves as the canonical coordinate system for inspection and editing.
53
+ _Avoid_: Raw M string, pretty-printed SQL
54
+
55
+ **SQL Section**:
56
+ A named, addressable region of Partition SQL — either a top-level CTE or `main` (the final `SELECT` query) — anchored to its canonical line range in the Clean SQL View.
57
+ _Avoid_: Query chunk, SQL block
58
+
59
+ **Dynamic M Parameter**:
60
+ A Power Query M variable or expression interpolated into Partition SQL (such as a catalog, schema, or date-range parameter) that must be preserved across edits.
61
+ _Avoid_: Query macro, SQL variable, template tag