tompo-mcp 0.1.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.
- tompo_mcp-0.1.0/LICENSE +21 -0
- tompo_mcp-0.1.0/PKG-INFO +177 -0
- tompo_mcp-0.1.0/README.md +155 -0
- tompo_mcp-0.1.0/pyproject.toml +33 -0
- tompo_mcp-0.1.0/src/tompo_mcp/__init__.py +3 -0
- tompo_mcp-0.1.0/src/tompo_mcp/__main__.py +5 -0
- tompo_mcp-0.1.0/src/tompo_mcp/auth.py +59 -0
- tompo_mcp-0.1.0/src/tompo_mcp/core/__init__.py +0 -0
- tompo_mcp-0.1.0/src/tompo_mcp/core/fabric_client.py +467 -0
- tompo_mcp-0.1.0/src/tompo_mcp/core/lineage.py +197 -0
- tompo_mcp-0.1.0/src/tompo_mcp/core/links.py +44 -0
- tompo_mcp-0.1.0/src/tompo_mcp/core/models.py +146 -0
- tompo_mcp-0.1.0/src/tompo_mcp/core/parser.py +836 -0
- tompo_mcp-0.1.0/src/tompo_mcp/server.py +430 -0
- tompo_mcp-0.1.0/src/tompo_mcp/viz/template.html +329 -0
- tompo_mcp-0.1.0/test_fabric_url.py +73 -0
- tompo_mcp-0.1.0/test_live.py +20 -0
- tompo_mcp-0.1.0/tests/__init__.py +0 -0
- tompo_mcp-0.1.0/tests/test_core.py +285 -0
tompo_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TOMPo Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tompo_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tompo-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: TOMPo — Power BI & Fabric Lineage Intelligence MCP Server. Trace lineage from semantic models to reports to visuals. Impact analysis for every column and measure.
|
|
5
|
+
Project-URL: Homepage, https://github.com/microsoft/tompo-mcp
|
|
6
|
+
Project-URL: Repository, https://github.com/microsoft/tompo-mcp
|
|
7
|
+
Author-email: Tushar Pardeshi <tpardeshi@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: copilot,fabric,impact-analysis,lineage,mcp,powerbi,semantic-model
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: azure-identity>=1.15.0
|
|
18
|
+
Requires-Dist: httpx>=0.27.0
|
|
19
|
+
Requires-Dist: mcp>=1.0.0
|
|
20
|
+
Requires-Dist: pydantic>=2.0.0
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# TOMPo MCP — Power BI & Fabric Lineage Intelligence
|
|
24
|
+
|
|
25
|
+
**Trace lineage from semantic models → tables → reports → pages → visuals → columns/measures.**
|
|
26
|
+
|
|
27
|
+
An MCP (Model Context Protocol) server that brings Power BI lineage intelligence directly into your AI assistant — GitHub Copilot, Claude Desktop, Cursor, or any MCP-compatible client.
|
|
28
|
+
|
|
29
|
+
## What it does
|
|
30
|
+
|
|
31
|
+
- **Full Lineage:** See exactly which columns and measures appear in which visuals, across all reports bound to a semantic model
|
|
32
|
+
- **Impact Analysis:** "What breaks if I rename `Employee.StartDate`?" — instantly shows every affected visual
|
|
33
|
+
- **Interactive Visualization:** Export a self-contained D3 tree (HTML file) with expand/collapse, zoom, and search
|
|
34
|
+
- **Zero Infrastructure:** Runs locally on your machine using your own Azure identity. No App Service, no Docker, no backend.
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### 1. Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install git+https://github.com/microsoft/tompo-mcp.git
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or clone and install locally:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/microsoft/tompo-mcp.git
|
|
48
|
+
cd tompo-mcp
|
|
49
|
+
pip install -e .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Login to Azure
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
az login
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 3. Add to VS Code
|
|
59
|
+
|
|
60
|
+
Add to your VS Code `settings.json` (Ctrl+Shift+P → "Preferences: Open User Settings (JSON)"):
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"mcp": {
|
|
65
|
+
"servers": {
|
|
66
|
+
"tompo": {
|
|
67
|
+
"command": "python",
|
|
68
|
+
"args": ["-m", "tompo_mcp"]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 4. Use in Copilot Chat
|
|
76
|
+
|
|
77
|
+
Open GitHub Copilot Chat and start asking:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
> List my Fabric workspaces
|
|
81
|
+
> Generate lineage for dataset abc-123 in workspace xyz-456
|
|
82
|
+
> What visuals use the Employee.Department column?
|
|
83
|
+
> Export the lineage as an interactive HTML file
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## MCP Tools
|
|
87
|
+
|
|
88
|
+
| Tool | Description |
|
|
89
|
+
|------|-------------|
|
|
90
|
+
| `list_workspaces` | List all Fabric/Power BI workspaces you have access to |
|
|
91
|
+
| `generate_lineage` | Full lineage: Model → Tables → Reports → Pages → Visuals → Fields |
|
|
92
|
+
| `impact_analysis` | Find all visuals where a specific column or measure is used |
|
|
93
|
+
| `describe_semantic_model` | Detailed metadata: tables, columns, measures, relationships, roles |
|
|
94
|
+
| `export_lineage_html` | Generate interactive D3 visualization as a self-contained HTML file |
|
|
95
|
+
|
|
96
|
+
## How It Works
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
You type in Copilot Chat
|
|
100
|
+
│
|
|
101
|
+
▼
|
|
102
|
+
Copilot calls TOMPo MCP tools
|
|
103
|
+
│
|
|
104
|
+
▼
|
|
105
|
+
TOMPo runs locally on your machine:
|
|
106
|
+
→ Uses your az login identity
|
|
107
|
+
→ Calls Fabric REST APIs (getDefinition, Scanner, DAX)
|
|
108
|
+
→ Parses model + report definitions
|
|
109
|
+
→ Builds lineage tree
|
|
110
|
+
→ Returns data to Copilot
|
|
111
|
+
│
|
|
112
|
+
▼
|
|
113
|
+
Copilot shows the lineage tree / impact table
|
|
114
|
+
(or opens interactive HTML in your browser)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Authentication
|
|
118
|
+
|
|
119
|
+
TOMPo uses `DefaultAzureCredential` which automatically picks up:
|
|
120
|
+
1. **Azure CLI** (`az login`) — most common for developers
|
|
121
|
+
2. **VS Code Azure Account** — if you're signed into the Azure extension
|
|
122
|
+
3. **Environment variables** — for CI/CD pipelines
|
|
123
|
+
4. **Managed Identity** — for Azure-hosted scenarios
|
|
124
|
+
|
|
125
|
+
You need access to the Fabric workspaces you want to analyze. No extra app registrations or service principals required.
|
|
126
|
+
|
|
127
|
+
### Metadata Extraction (3-tier fallback)
|
|
128
|
+
|
|
129
|
+
1. **Fabric `getDefinition` API** — returns full model.bim / TMDL / PBIR definitions
|
|
130
|
+
2. **Admin Scanner API** — fallback if getDefinition fails (requires admin permissions)
|
|
131
|
+
3. **DAX `executeQueries`** — last resort using `INFO.TABLES()`, `INFO.COLUMNS()`, etc.
|
|
132
|
+
|
|
133
|
+
If a sensitivity label blocks access, TOMPo temporarily downgrades to "General", extracts metadata, then restores the original label.
|
|
134
|
+
|
|
135
|
+
## Interactive Visualization
|
|
136
|
+
|
|
137
|
+
The `export_lineage_html` tool generates a single HTML file with:
|
|
138
|
+
- **D3 horizontal tree** with expand/collapse nodes
|
|
139
|
+
- **Color-coded** by type (model, table, report, page, visual, column, measure)
|
|
140
|
+
- **Impact Analysis tab** with searchable data grid
|
|
141
|
+
- **Semantic Model tab** with tables, columns, measures, relationships
|
|
142
|
+
- **Zoom, pan, fullscreen** — all interactive
|
|
143
|
+
- **Works offline** — all JavaScript and CSS inlined, no server needed
|
|
144
|
+
|
|
145
|
+
## Claude Desktop
|
|
146
|
+
|
|
147
|
+
Add to `claude_desktop_config.json`:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"mcpServers": {
|
|
152
|
+
"tompo": {
|
|
153
|
+
"command": "python",
|
|
154
|
+
"args": ["-m", "tompo_mcp"]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Development
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
git clone https://github.com/microsoft/tompo-mcp.git
|
|
164
|
+
cd tompo-mcp
|
|
165
|
+
pip install -e ".[dev]"
|
|
166
|
+
python -m pytest tests/
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Requirements
|
|
170
|
+
|
|
171
|
+
- Python 3.10+
|
|
172
|
+
- Azure CLI (`az login`) or any Azure credential
|
|
173
|
+
- Access to Fabric/Power BI workspaces
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# TOMPo MCP — Power BI & Fabric Lineage Intelligence
|
|
2
|
+
|
|
3
|
+
**Trace lineage from semantic models → tables → reports → pages → visuals → columns/measures.**
|
|
4
|
+
|
|
5
|
+
An MCP (Model Context Protocol) server that brings Power BI lineage intelligence directly into your AI assistant — GitHub Copilot, Claude Desktop, Cursor, or any MCP-compatible client.
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
- **Full Lineage:** See exactly which columns and measures appear in which visuals, across all reports bound to a semantic model
|
|
10
|
+
- **Impact Analysis:** "What breaks if I rename `Employee.StartDate`?" — instantly shows every affected visual
|
|
11
|
+
- **Interactive Visualization:** Export a self-contained D3 tree (HTML file) with expand/collapse, zoom, and search
|
|
12
|
+
- **Zero Infrastructure:** Runs locally on your machine using your own Azure identity. No App Service, no Docker, no backend.
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### 1. Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install git+https://github.com/microsoft/tompo-mcp.git
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or clone and install locally:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/microsoft/tompo-mcp.git
|
|
26
|
+
cd tompo-mcp
|
|
27
|
+
pip install -e .
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. Login to Azure
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
az login
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 3. Add to VS Code
|
|
37
|
+
|
|
38
|
+
Add to your VS Code `settings.json` (Ctrl+Shift+P → "Preferences: Open User Settings (JSON)"):
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcp": {
|
|
43
|
+
"servers": {
|
|
44
|
+
"tompo": {
|
|
45
|
+
"command": "python",
|
|
46
|
+
"args": ["-m", "tompo_mcp"]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 4. Use in Copilot Chat
|
|
54
|
+
|
|
55
|
+
Open GitHub Copilot Chat and start asking:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
> List my Fabric workspaces
|
|
59
|
+
> Generate lineage for dataset abc-123 in workspace xyz-456
|
|
60
|
+
> What visuals use the Employee.Department column?
|
|
61
|
+
> Export the lineage as an interactive HTML file
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## MCP Tools
|
|
65
|
+
|
|
66
|
+
| Tool | Description |
|
|
67
|
+
|------|-------------|
|
|
68
|
+
| `list_workspaces` | List all Fabric/Power BI workspaces you have access to |
|
|
69
|
+
| `generate_lineage` | Full lineage: Model → Tables → Reports → Pages → Visuals → Fields |
|
|
70
|
+
| `impact_analysis` | Find all visuals where a specific column or measure is used |
|
|
71
|
+
| `describe_semantic_model` | Detailed metadata: tables, columns, measures, relationships, roles |
|
|
72
|
+
| `export_lineage_html` | Generate interactive D3 visualization as a self-contained HTML file |
|
|
73
|
+
|
|
74
|
+
## How It Works
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
You type in Copilot Chat
|
|
78
|
+
│
|
|
79
|
+
▼
|
|
80
|
+
Copilot calls TOMPo MCP tools
|
|
81
|
+
│
|
|
82
|
+
▼
|
|
83
|
+
TOMPo runs locally on your machine:
|
|
84
|
+
→ Uses your az login identity
|
|
85
|
+
→ Calls Fabric REST APIs (getDefinition, Scanner, DAX)
|
|
86
|
+
→ Parses model + report definitions
|
|
87
|
+
→ Builds lineage tree
|
|
88
|
+
→ Returns data to Copilot
|
|
89
|
+
│
|
|
90
|
+
▼
|
|
91
|
+
Copilot shows the lineage tree / impact table
|
|
92
|
+
(or opens interactive HTML in your browser)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Authentication
|
|
96
|
+
|
|
97
|
+
TOMPo uses `DefaultAzureCredential` which automatically picks up:
|
|
98
|
+
1. **Azure CLI** (`az login`) — most common for developers
|
|
99
|
+
2. **VS Code Azure Account** — if you're signed into the Azure extension
|
|
100
|
+
3. **Environment variables** — for CI/CD pipelines
|
|
101
|
+
4. **Managed Identity** — for Azure-hosted scenarios
|
|
102
|
+
|
|
103
|
+
You need access to the Fabric workspaces you want to analyze. No extra app registrations or service principals required.
|
|
104
|
+
|
|
105
|
+
### Metadata Extraction (3-tier fallback)
|
|
106
|
+
|
|
107
|
+
1. **Fabric `getDefinition` API** — returns full model.bim / TMDL / PBIR definitions
|
|
108
|
+
2. **Admin Scanner API** — fallback if getDefinition fails (requires admin permissions)
|
|
109
|
+
3. **DAX `executeQueries`** — last resort using `INFO.TABLES()`, `INFO.COLUMNS()`, etc.
|
|
110
|
+
|
|
111
|
+
If a sensitivity label blocks access, TOMPo temporarily downgrades to "General", extracts metadata, then restores the original label.
|
|
112
|
+
|
|
113
|
+
## Interactive Visualization
|
|
114
|
+
|
|
115
|
+
The `export_lineage_html` tool generates a single HTML file with:
|
|
116
|
+
- **D3 horizontal tree** with expand/collapse nodes
|
|
117
|
+
- **Color-coded** by type (model, table, report, page, visual, column, measure)
|
|
118
|
+
- **Impact Analysis tab** with searchable data grid
|
|
119
|
+
- **Semantic Model tab** with tables, columns, measures, relationships
|
|
120
|
+
- **Zoom, pan, fullscreen** — all interactive
|
|
121
|
+
- **Works offline** — all JavaScript and CSS inlined, no server needed
|
|
122
|
+
|
|
123
|
+
## Claude Desktop
|
|
124
|
+
|
|
125
|
+
Add to `claude_desktop_config.json`:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"mcpServers": {
|
|
130
|
+
"tompo": {
|
|
131
|
+
"command": "python",
|
|
132
|
+
"args": ["-m", "tompo_mcp"]
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
git clone https://github.com/microsoft/tompo-mcp.git
|
|
142
|
+
cd tompo-mcp
|
|
143
|
+
pip install -e ".[dev]"
|
|
144
|
+
python -m pytest tests/
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Requirements
|
|
148
|
+
|
|
149
|
+
- Python 3.10+
|
|
150
|
+
- Azure CLI (`az login`) or any Azure credential
|
|
151
|
+
- Access to Fabric/Power BI workspaces
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tompo-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "TOMPo — Power BI & Fabric Lineage Intelligence MCP Server. Trace lineage from semantic models to reports to visuals. Impact analysis for every column and measure."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "Tushar Pardeshi", email = "tpardeshi@gmail.com" }]
|
|
13
|
+
keywords = ["powerbi", "fabric", "lineage", "mcp", "copilot", "impact-analysis", "semantic-model"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Topic :: Software Development :: Libraries",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"mcp>=1.0.0",
|
|
23
|
+
"httpx>=0.27.0",
|
|
24
|
+
"azure-identity>=1.15.0",
|
|
25
|
+
"pydantic>=2.0.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/microsoft/tompo-mcp"
|
|
30
|
+
Repository = "https://github.com/microsoft/tompo-mcp"
|
|
31
|
+
|
|
32
|
+
[tool.hatch.build.targets.wheel]
|
|
33
|
+
packages = ["src/tompo_mcp"]
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Authentication for TOMPo MCP.
|
|
3
|
+
|
|
4
|
+
Uses DefaultAzureCredential (Azure CLI / VS Code) by default.
|
|
5
|
+
Also accepts a raw bearer token for Fabric Notebook scenarios.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
from typing import Optional
|
|
12
|
+
|
|
13
|
+
from azure.identity import DefaultAzureCredential
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
_credential: Optional[DefaultAzureCredential] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _get_credential() -> DefaultAzureCredential:
|
|
21
|
+
global _credential
|
|
22
|
+
if _credential is None:
|
|
23
|
+
_credential = DefaultAzureCredential(
|
|
24
|
+
exclude_shared_token_cache_credential=True,
|
|
25
|
+
)
|
|
26
|
+
logger.info("DefaultAzureCredential initialized")
|
|
27
|
+
return _credential
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TokenProvider:
|
|
31
|
+
"""Provides bearer tokens for Fabric/Power BI API calls.
|
|
32
|
+
|
|
33
|
+
If initialized with a raw token string, uses it directly (Fabric Notebook).
|
|
34
|
+
Otherwise uses DefaultAzureCredential (az login / VS Code identity).
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def __init__(self, token: Optional[str] = None) -> None:
|
|
38
|
+
self._raw_token = token
|
|
39
|
+
|
|
40
|
+
def get_powerbi_token(self) -> str:
|
|
41
|
+
if self._raw_token:
|
|
42
|
+
return self._raw_token
|
|
43
|
+
cred = _get_credential()
|
|
44
|
+
result = cred.get_token("https://analysis.windows.net/powerbi/api/.default")
|
|
45
|
+
return result.token
|
|
46
|
+
|
|
47
|
+
def get_fabric_token(self) -> str:
|
|
48
|
+
if self._raw_token:
|
|
49
|
+
return self._raw_token
|
|
50
|
+
cred = _get_credential()
|
|
51
|
+
result = cred.get_token("https://api.fabric.microsoft.com/.default")
|
|
52
|
+
return result.token
|
|
53
|
+
|
|
54
|
+
def get_graph_token(self) -> str:
|
|
55
|
+
if self._raw_token:
|
|
56
|
+
return self._raw_token
|
|
57
|
+
cred = _get_credential()
|
|
58
|
+
result = cred.get_token("https://graph.microsoft.com/.default")
|
|
59
|
+
return result.token
|
|
File without changes
|