MCP Server for Power BI

MCP Server for Power BI

Enables exploring Microsoft Fabric / Power BI workspaces and semantic models, and executing ad-hoc DAX queries.

Category
访问服务器

README

MCP Server for Power BI

CodeQL Ask DeepWiki MIT License

Model Context Protocol (MCP) server for exploring Microsoft Fabric / Power BI workspaces and semantic models, and for executing ad‑hoc DAX queries.

🔐 Now with OAuth/Entra ID support! Seamlessly integrates with LibreChat and other OAuth-enabled clients using JWT validation and On-Behalf-Of flow.

Architecture Overview

Architecture diagram for PBI MCP Server

Features

Tool Purpose
powerbi_list_workspaces() List workspaces the signed-in user can access.
get_workspace_id(workspace_name) Get the workspace ID for a given workspace name.
list_datasets_in_workspace(workspace_id) Enumerate datasets in a workspace.
get_dataset_details(workspace_id, dataset_id) Retrieve dataset (semantic model) metadata and definition via Fabric.
execute_dax_query(workspace_id, dataset_id, dax_query) Run a DAX query against a dataset using the Execute Queries API.

Transport Modes

🌐 HTTP Transport with OAuth (Recommended for Production)

  • Full Entra ID/Azure AD authentication
  • JWT token validation with JWKS
  • On-Behalf-Of (OBO) flow for Power BI and Fabric API access
  • Role and scope-based authorization
  • Claims challenge support for conditional access
  • Perfect for LibreChat integration

💻 STDIO Transport (Local Development)

  • Simple bearer token authentication
  • Direct Power BI API access
  • Suitable for local testing with MCP clients

Requirements

  • Python 3.12+
  • uv (fast Python package/project manager)
  • For HTTP mode: Azure AD app registrations with OAuth configured
  • For STDIO mode: Power BI access token

Development

Code Quality Tools

This project uses Ruff for linting and formatting, and ty for type checking.

Install development dependencies:

uv sync --extra dev

Run Ruff linting:

uv run ruff check .

Run ty type checking:

uv run ty check mcp_for_powerbi/

Quick Start

HTTP Mode with OAuth (LibreChat)

  1. Install dependencies:
uv sync
  1. Configure environment (copy .env.example):
# Azure AD Configuration
PORT=3001
TENANT_ID=your-tenant-id
AUDIENCE=your-api-app-id
OBO_CLIENT_ID=your-obo-client-id
OBO_CLIENT_SECRET=your-obo-client-secret

# Authorization
REQUIRED_SCOPES=mcp.access
REQUIRED_ROLES=mcp.user

# Logging
LOG_LEVEL=info
  1. Run the server:
python -m mcp_for_powerbi.server_http

Server starts on http://localhost:3001/mcp

STDIO Mode (Local Development)

Note: STDIO mode now requires OAuth integration. The server expects the Authorization header to be passed via the MCP client.

Run the server:

uv run mcp-for-powerbi

Authentication

OAuth with Entra ID

Both HTTP and STDIO modes now use Entra ID OAuth2 with:

  • JWT Validation: Verifies token signature, audience, issuer
  • OBO Flow: Exchanges user token for downstream Power BI and Fabric tokens (resource-bound)
  • Authorization: Validates roles and scopes

Client Integration Examples

LibreChat (HTTP with OAuth)

mcpServers:
  mcp-server-for-powerbi:
    type: streamable-http
    url: http://localhost:3001/mcp
    requiresOAuth: true
    oauth:
      authorization_url: https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/authorize
      token_url: https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
      client_id: <client-id>
      client_secret: <client-secret>
      scope: "api://<api-app-id>/mcp.access openid profile offline_access"
      redirect_uri: http://localhost:3080/api/mcp/mcp-server-for-powerbi/oauth/callback

Cherry Studio (STDIO)

{
  "mcpServers": {
    "mcp-for-powerbi": {
      "name": "mcp-for-powerbi",
      "type": "stdio",
      "isActive": true,
      "registryUrl": "",
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "<your_directory>/mcp-server-for-powerbi",
        "mcp-for-powerbi"
      ]
    }
  }
}

Note: MCP client must pass OAuth token via Authorization header.


## Docker Deployment to Azure

- Login to Azure CLI and ACR

```bash
az login
az acr login --name <acr-name>
  • Build the Docker image
docker build -t <acr-name>.azurecr.io/mcp-server-for-powerbi .
  • Run the image locally for testing
docker run -it --rm -p 8080:8080 \
  -e TENANT_ID=<tenant-id> \
  -e AUDIENCE=<api-app-id> \
  -e OBO_CLIENT_ID=<obo-client-id> \
  -e OBO_CLIENT_SECRET=<obo-secret> \
  <acr-name>.azurecr.io/mcp-server-for-powerbi
  • Push the image to ACR
docker push <acr-name>.azurecr.io/mcp-server-for-powerbi

Error Handling & Troubleshooting

The server raises structured MCP tool errors with detailed suggestions:

  • Missing Authorization – OAuth token not provided in Authorization header.
  • TokenExpired – obtain a fresh token (user tokens are short‑lived).
  • Unauthorized (401) – token is invalid or lacks required permissions.
  • Forbidden (403) – user lacks permission to the workspace or dataset.
  • NotFound (404) – invalid workspace_id or dataset_id.
  • BadRequest (400) – invalid parameters or DAX syntax errors.
  • TooManyRequests (429) – rate limit exceeded (120 requests per minute).
  • Timeout – network / API slowness (default timeout 30s).

Each error includes:

  • Error code and message from the Power BI API
  • Context-aware suggestions to help resolve the issue
  • Parameter validation for workspace_id and dataset_id (UUID format)
  • DAX-specific error analysis with syntax and semantic suggestions

Acknowledgments

This project is built on FastMCP v2 and draws inspiration from the following repositories:

Their approaches to semantic model surfacing and Power BI integration helped shape the tool design here.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Disclaimer

This project is an independent, open‑source MCP server for Microsoft Power BI. It is not affiliated with, endorsed by, or sponsored by Microsoft. “Power BI” is a trademark of Microsoft Corporation.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选