Token导航 LogoToken导航TokenDH.com
pbi MCP logo
浏览器工具stdio官方级别未说明来源级核验

pbi MCP

MCP Server

@modelcontextprotocol/inspector

一个远程Model Context Protocol (MCP)服务器,将Power BI操作作为工具暴露给AI助手使用。

工具数

4

提示词数

0

GitHub Stars

0

资源数

0
数据分析HTMLVS CodeVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

bcperry

提供方

bcperry

最后核验

2026/5/17 20:23

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx @modelcontextprotocol/inspector

详细介绍

Power BI MCP服务器

工具

工具说明参数
list_workspaces列出经过身份验证的用户可访问的所有Power BI工作区--
list_datasets列出工作区中的数据集workspaceId
list_tables列出数据集中的表和列(通过DAX COLUMNSTATISTICS())workspaceId, datasetId
execute_dax通过REST API执行DAX查询workspaceId, datasetId, daxQuery

先决条件

快速开始

# 1. Clone and enter the repo
git clone  && cd pbi-mcp

# 2. Log in to Azure (use your Power BI tenant)
az login --tenant 

# 3. Update appsettings.json with your tenant ID
#    (already configured if you cloned this repo)

# 4. Build and run
dotnet run

服务器启动于 http://localhost:3001/mcp.

配置

应用程序参数

{
  "PowerBi": {
    "TenantId": "your-tenant-id-here"
  }
}

TenantId 传递给 DefaultAzureCredential 以确保为正确的租户获取令牌。

认证

服务器使用 DefaultAzureCredential,它按顺序尝试这些来源:

优先级来源用例
1AZURE_TENANT_ID / AZURE_CLIENT_ID / AZURE_CLIENT_SECRET env变量服务主体/CI
2工作负载标识Kubernetes
3托管身份Azure虚拟机、应用服务、ACA
4Azure命令行界面(az login)地方发展

本地开发(az登录)

az login --tenant 16b3c013-d300-468d-ac64-7eda0820b6d3
dotnet run

服务主体(环境变量)

export AZURE_TENANT_ID="your-tenant-id"
export AZURE_CLIENT_ID="your-sp-app-id"
export AZURE_CLIENT_SECRET="your-sp-secret"
dotnet run

无需更改代码-- DefaultAzureCredential 自动拾取env变量。

连接MCP客户端

VS代码(副本)

回购包括 .vscode/mcp.json:

{
  "servers": {
    "pbi-mcp": {
      "type": "http",
      "url": "http://localhost:3001/mcp"
    }
  }
}

使用启动服务器 dotnet run,则Copilot将自动发现工具。

MCP检查员

npx @modelcontextprotocol/inspector

连接到 http://localhost:3001/mcp 使用流式HTTP传输。

项目结构

PbiMcpServer.csproj          # ASP.NET Core Web project
Program.cs                   # Entry point — DI, MCP server, HTTP transport
PowerBiService.cs            # Power BI REST API + XMLA service layer
PowerBiTools.cs              # MCP tool definitions (4 tools)
appsettings.json             # Tenant ID + logging config
.vscode/mcp.json             # VS Code MCP client config
tests/
  PbiMcpServer.Tests/
    PowerBiServiceUnitTests.cs        # 11 offline tests (mocked HTTP)
    PowerBiServiceIntegrationTests.cs # 5 live API tests
    XunitLoggerProvider.cs            # xUnit ↔ ILogger bridge

测试

# Unit tests (offline, fast — no credentials needed)
dotnet test tests/PbiMcpServer.Tests/PbiMcpServer.Tests.csproj \
  --filter "Category!=Integration"

# Integration tests (hits live Power BI API — requires az login)
dotnet test tests/PbiMcpServer.Tests/PbiMcpServer.Tests.csproj \
  --filter "Category=Integration"

# All tests
dotnet test tests/PbiMcpServer.Tests/PbiMcpServer.Tests.csproj

# With detailed HTTP request/response logging
dotnet test tests/PbiMcpServer.Tests/PbiMcpServer.Tests.csproj \
  --filter "Category=Integration" \
  --logger "console;verbosity=detailed"

架构说明

DAX执行

所有DAX查询都使用 Power BI REST API (POST /datasets/{id}/executeQueries).这适用于任何Pro/EPU/Premium工作区,不需要XMLA端点。

XMLA路径(通过ADOMD.NET)包含在代码库中,但被注释掉了。它需要租户管理员启用XMLA读取的高级/PPU容量。

表发现

list_tables 工具用途 EVALUATE COLUMNSTATISTICS() 通过REST DAX端点而不是REST /tables 端点,因为 /tables 仅适用于推送数据集。DAX方法适用于所有数据集类型(导入、DirectQuery、复合)。

.NET运行时

该项目需要:

  • Microsoft.NETCore.App --基地。NET运行时(控制台、I/O、网络)
  • Microsoft.AspNetCore.App --web运行时(Kestrel、路由、中间件)

安装方式: sudo apt install aspnetcore-runtime-8.0 (包括两者)。

技术栈

许可证

该项目根据 MIT许可证.

目录标签

目录标签

数据分析HTMLVS Code本地部署PowerBIMCP协议AI工具集成微软生态

支持客户端

VS Code

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

session

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

@modelcontextprotocol/inspector

工具数量(toolCount,工具数)

4

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiosession部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP