PowerBI表格
STDIOPowerBI表格模型DAX查询分析MCP服务器
PowerBI表格模型DAX查询分析MCP服务器
This is a Model Context Protocol (MCP) server for locally running Tabular Models, i.e. PowerBI models running on PowerBI Desktop.
This server allows MCP-enabled LLM clients to communicate with your tabular models and help you debug, analyse and compose DAX queries.
Example: Copilot querying Tabular Model via MCP
It connects to a local running instance of Tabular models using the AdomdConnection in ADOMD.NET.
Using this connection, the server then allows clients to execute DAX-queries and retrieve model metadata (using DMV queries) through pre-defined tools for high accuracy, as well as custom DAX queries for debugging and development.
This MCP server enables communication between clients and Power BI tabular models via ADOMD.NET, supporting both predefined metadata queries and flexible DAX queries with full DEFINE block capabilities for advanced analysis.
MCPBI provides 10 tools that enable LLM clients to explore, analyze, and debug your Power BI models:
ListTables
GetTableDetails
GetTableColumns
GetTableRelationships
ListMeasures
GetMeasureDetails
PreviewTableData
RunQuery
ValidateDaxSyntax
AnalyzeQueryPerformance
Use [ListTables], [GetTableColumns], and [GetTableRelationships] to quickly understand an unfamiliar model's structure without manually clicking through Power BI Desktop.
LLM clients can use [ListMeasures] and [GetMeasureDetails] to learn your existing DAX patterns and suggest consistent new measures that follow your naming conventions and calculation styles.
Combine [RunQuery] with [ValidateDaxSyntax] to iteratively test and refine DAX expressions with immediate feedback on syntax and results.
Use [AnalyzeQueryPerformance] to identify slow queries, then iterate improvements with [RunQuery] to verify performance gains.
Download the release from the Releases directory or GitHub releases page and extract to your preferred location.
Open Power BI Desktop with a PBIX file you want to work with.
Get PowerBI instance information
There are several ways to detect Power BI Desktop instances. The easiest is to open Tabular Editor and check the port in the connection string.
Simply add the port (63717 in example above) to your MCP server configuration in the next step (you can ignore the database ID, as this server connects to the default model).
If you don't have Tabular Editor, you can use the included discovery tool to find the running instance and database.
Open PowerShell, navigate to the release directory, and run:
cd path\to\release .\pbi-local-mcp.DiscoverCli.exe
Note: In PowerShell, you must use .\ prefix to run executables from the current directory.
Follow the prompts to:
This creates a .env file with PBI_PORT and PBI_DB_ID in the release directory, which you can reference in your MCP configuration or ignore if you specify the port directly.
.roo/mcp.json:
Replace{ "mcpServers": { "MCPBI": { "type": "stdio", "command": "path\\to\\release\\mcpbi.exe", "cwd": "path\\to\\release", "args": ["--port", "YOUR_PBI_PORT"], "disabled": false, "alwaysAllow": [ "ListTables", "GetTableDetails", "GetTableColumns", "GetTableRelationships", "ListMeasures", "GetMeasureDetails", "PreviewTableData", "RunQuery", "ValidateDaxSyntax", "AnalyzeQueryPerformance" ] } } }
path\\to\\release with your actual release directory path and YOUR_PBI_PORT with the port number from PBI instance.Clone the repository:
git clone <repository-url> cd tabular-mcp
Build the project:
dotnet build
Open Power BI Desktop with a PBIX file.
Run discovery to create .env file:
dotnet run --project pbi-local-mcp/pbi-local-mcp.csproj discover-pbi
Follow prompts to select instance and database.
Configure MCP server in .roo/mcp.json:
{ "mcpServers": { "mcpbi-dev": { "type": "stdio", "command": "dotnet", "cwd": "path\\to\\tabular-mcp", "envFile": "path\\to\\tabular-mcp\\.env", "args": [ "exec", "path\\to\\tabular-mcp\\pbi-local-mcp\\bin\\Debug\\net8.0\\pbi-local-mcp.dll" ], "disabled": false, "alwaysAllow": [ "ListTables", "GetTableDetails", "GetTableColumns", "GetTableRelationships", "ListMeasures", "GetMeasureDetails", "PreviewTableData", "RunQuery", "ValidateDaxSyntax", "AnalyzeQueryPerformance" ] } } }
Replace path\\to\\tabular-mcp with your actual repository path.
args or use envFile to load from .env.--port argument in the release configuration connects to the specific Power BI Desktop instance on that portenvFile to automatically load PBI_PORT and PBI_DB_ID from .envcwd parameter sets the working directory where the .env file is located