PowerBI MCP Server

PowerBI REST API integration. Query workspaces, datasets, and execute DAX queries via MCP.

0MITother

Install

Config snippet generator goes here (5 client tabs)

README

# PowerBI MCP Server

[![PyPI](https://img.shields.io/pypi/v/powerbi-mcp.svg)](https://pypi.org/project/powerbi-mcp/)
[![Python Versions](https://img.shields.io/pypi/pyversions/powerbi-mcp.svg)](https://pypi.org/project/powerbi-mcp/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<!-- mcp-name: io.github.gurvinder-dhillon/powerbi-mcp -->

A Model Context Protocol (MCP) server that provides tools for interacting with PowerBI REST APIs. This server enables AI assistants like Claude to query PowerBI workspaces, datasets, and execute DAX queries.

> [!WARNING]
> **Security Best Practices**
> - Never commit credentials to version control
> - Store credentials in `.env` files (add to `.gitignore`)
> - Rotate client secrets regularly in Azure AD
> - Use least-privilege access (only grant necessary workspace permissions)
> - This server has read/write access to PowerBI datasets - use with caution

## ✨ Features

- **Query Your Data**: Run DAX queries to extract insights and analyze your PowerBI data directly through conversation
- **Discover Workspaces & Datasets**: Explore what data is available across your organization's PowerBI environment
- **Understand Data Models**: Get detailed schema information to know what tables, columns, and relationships exist
- **Natural Language to Insights**: Ask questions about your data and get answers without opening PowerBI

See all [available tools](#-available-tools) below.

## 💡 What Can You Do?

| Scenario | Example Prompt |
|----------|----------------|
| Explore available data | "What workspaces do I have access to?" |
| Discover reports | "What reports are available in my workspace?" |
| Understand data schema | "Show me the schema for dataset [dataset-name]" |
| Monitor data freshes | "When was this dataset last refreshed?" |
| Check parameters | "What parameters does this dataset accept?" |
| Query data with DAX | "Run a DAX query to get top 10 sales by region from [dataset]" |
| Analyze data quality | "What tables are in the Sales dataset?" |
| Extract insights | "Get the list of all measures in the Financial dataset" |

## 📋 Prerequisites

- **Azure AD Service Principal**: Required for authentication. Follow the [Azure AD Configuration](#-azure-ad-configuration) steps below to set this up.

## 🔐 Azure AD Configuration

Before installing the server, you need to set up an Azure AD application with PowerBI access.

### Create Azure AD App Registration

1. Go to [Azure Portal](https://portal.azure.com)
2. Navigate to **Azure Active Directory** > **App registrations**
3. Click **New registration**
4. Enter a name (e.g., "PowerBI MCP Server")
5. Click **Register**

### Get Credentials

After registration, collect these values:

- **Tenant ID**: Found in app Overview page (Directory ID)
- **Client ID**: Found in app Overview page (Application ID)
- **Client Secret**:
  - Go to **Certificates & secrets**
  - Click **New client secret**
  - Add description and set expiry
  - Copy the secret **Value** (you can only see this once!)

### Enable Service Principal in PowerBI

1. Go to [PowerBI Admin Portal](https://app.powerbi.com/admin-portal)
2. Navigate to **Tenant settings** > **Developer settings**
3. Enable **Service principals can use PowerBI APIs**
4. Add your app to the security group or enable for entire organization
5. Click **Apply**

> [!NOTE]
> Service principals can access workspaces where they've been granted explicit permissions (Admin, Member, or Contributor roles).

### Grant Workspace Access

For each workspace you want to access:

1. Go to the workspace in PowerBI
2. Click workspace settings (⚙️) > **Access**
3. Click **Add people or groups**
4. Search for your app name
5. Assign role: **Admin**, **Member**, or **Contributor**
6. Click **Add**

## 📦 Installation

### Method 0: From PyPI (Recommended)

Once published to PyPI, this is the simplest installation method.

Add the following to your MCP client configuration file:

**For Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):

```json
{
  "mcpServers": {
    "powerbi-mcp": {
      "command": "uvx",
      "args": ["powerbi-mcp"],
      "env": {
        "POWERBI_TENANT_ID": "your-tenant-id-here",
        "POWERBI_CLIENT_ID": "your-client-id-here",
        "POWERBI_CLIENT_SECRET": "your-client-secret-here"
      }
    }
  }
}
```

**For Claude Code** (`./.mcp.json` in your project directory):

```json
{
  "mcpServers": {
    "powerbi-mcp": {
      "command": "uvx",
      "args": ["powerbi-mcp"],
      "env": {}
    }
  }
}
```

When using Claude Code, create a `.env` file in your project directory (where you run Claude Code from):

```env
POWERBI_TENANT_ID=your-tenant-id-here
POWERBI_CLIENT_ID=your-client-id-here
POWERBI_CLIENT_SECRET=your-client-secret-here
```

> [!TIP]
> The `.env` file should be in your working directory, not where the server is installed.

**For OpenCode** (`~/.config/opencode/ope