powerbi-mcp
powerbi-mcp
用于 Power BI MCP 访问的内部 Node.js 服务。它旨在与 Next.js 应用并行运行(通常在 PM2 下),并仅从 Next.js 服务器层调用。
本项目并非 Google Ads MCP 仓库的复制品。它遵循相同的专注型 MCP 后端理念,但专为 Power BI/Fabric、直接 JSON-RPC 调用以及已在 PBI 机器人 POC 中验证过的代理/工具迭代而定制。
功能概述
使用用户持有者令牌 (bearer token) 调用 Fabric Power BI MCP 端点。
通过 JSON-RPC 列出并执行 MCP 工具。
发现 Power BI 工作区和语义模型,以获得更好的模型提示词。
运行兼容 OpenAI 的代理循环,该循环可以调用 Power BI MCP 工具。
为 Next.js 后端公开内部 HTTP 端点。
附带名为
powerbi-mcp的 PM2 进程配置。
Related MCP server: Power BI MCP for Claude
端点
GET /healthPOST /internal/mcp/toolsPOST /internal/mcp/callPOST /internal/powerbi/catalogPOST /internal/chatPOST /internal/chat/json
浏览器/代理兼容路由也可在 /api/* 下使用:
GET /api/auth/statusGET /api/auth/loginGET /api/auth/callbackGET /api/auth/logoutPOST /api/mcp/toolsPOST /api/mcp/callPOST /api/powerbi/catalogPOST /api/chatPOST /api/chat/json
所有内部路由均接受以下形式的用户 Power BI 访问令牌:
Authorization: Bearer <power-bi-access-token>x-powerbi-access-token: <power-bi-access-token>JSON 请求体字段
accessToken
如果配置了 INTERNAL_API_KEY,还需发送:
x-internal-api-key: <your-internal-key>安装
cd powerbi-mcp
npm install
cp .env.example .env
npm run check在 .env 中填入您的 LiteLLM/兼容 OpenAI 的网关设置。
对于浏览器路由,请将您的 Azure 重定向 URI 设置为 Next.js 代理回调,例如:
http://localhost:3000/api/powerbi-mcp/auth/callback本地运行
npm run dev默认服务 URL 为 http://127.0.0.1:3101。
使用 PM2 运行
pm2 start ecosystem.config.js
pm2 status预期的进程名称:
powerbi-mcpNext.js 嵌入式路由
请将 Next.js 路由文件保留在此后端仓库之外。在此工作区中,它们位于同级文件夹中:
../powerbi-analyst-next-dropin/app将这些文件复制到实际的 ads-next/app 目录中:
app/Power_BI_Analyst/page.tsxapp/api/powerbi-mcp/[...path]/route.ts
然后浏览至:
/Power_BI_AnalystNext.js 代理调用此后端的地址为:
http://127.0.0.1:3101/api/*Next.js 服务器示例
仅从服务器路由、服务器操作或 API 处理程序中调用此服务。除正常的身份验证流程外,请勿将 Power BI 访问令牌暴露给浏览器端代码。
const response = await fetch("http://127.0.0.1:3101/internal/chat/json", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-internal-api-key": process.env.POWERBI_MCP_INTERNAL_API_KEY,
"Authorization": `Bearer ${powerBiAccessToken}`
},
body: JSON.stringify({
message: "Show total sales this month vs last month",
history: []
})
});
const data = await response.json();对于流式 UI 响应,请调用 /internal/chat 或 /api/chat;它会返回服务器发送的事件 (SSE):
data: {"token":"..."}
data: [DONE]注意事项
本服务同时支持通过
/internal/*进行令牌转发,以及通过/api/auth/*进行浏览器会话流。除非您有意将其置于私有网络边界之后,否则在生产环境中请绑定到
127.0.0.1。在部署前设置
INTERNAL_API_KEY,以确保只有受信任的内部调用者可以使用该服务。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Governed BI MCP. Ask questions of live company data and list workspace sources via OAuth.
Forge designed Power BI projects (.pbip) from your agent, bound to your own semantic model.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Official Fibery MCP server: query and update your workspace from any AI client via OAuth.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceThe Fabric-Analytics-MCP server enables AI agents to interact directly with Microsoft Fabric using natural language. It transforms complex data engineering tasks—such as workspace management, data exploration, and job execution—into intuitive, conversational workflows for LLMs like Claude or GitHub7 npm110MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for Microsoft Power BI and Fabric, enabling Claude to discover workspaces, semantic models, generate and execute DAX queries, and retrieve report metadata via device-code authentication.16 npm1MIT
- AlicenseAqualityCmaintenanceAn MCP (Model Context Protocol) server that lets AI agents manage Power BI workspaces, datasets, and refreshes via natural language.112MIT
- AlicenseBqualityCmaintenanceMCP server for Microsoft Fabric REST APIs that enables data engineers and analysts to manage Fabric components using AI assistants.219AGPL 3.0