DheerajKumar97/Power-BI-Custom-MCP-Server-with-Python--Claude-AI-Integration
If you are the rightful owner of Power-BI-Custom-MCP-Server-with-Python--Claude-AI-Integration and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Model Context Protocol (MCP) server that enables Claude to interact with Power BI Desktop through the XMLA endpoint using Analysis Services.
Power BI Desktop MCP Server
A Model Context Protocol (MCP) server that enables Claude to interact with Power BI Desktop through the XMLA endpoint using Analysis Services.
Overview
This MCP server allows Claude to:
- Query Power BI data models and metadata
- Execute DAX queries
- Retrieve table schemas, columns, and relationships
- Access measures and model information
- All without leaving the Claude interface
Features
- Model Discovery: Get information about active Power BI models
- Schema Exploration: Browse tables, columns, and their properties
- DAX Execution: Run DAX queries directly against your Power BI model
- Measures: Retrieve all measures with their expressions
- Relationships: View model relationships and their properties
- Auto-Detection: Automatically finds the Power BI Desktop XMLA port
Prerequisites
- Windows OS (Power BI Desktop is Windows-only)
- Power BI Desktop installed and running with a report open
- Python 3.8+
- pythonnet package for .NET interoperability
Installation
1. Clone or Download the Repository
git clone <your-repo-url>
cd Claude-Power-BI-Integration
2. Create a Virtual Environment
python -m venv venv
3. Activate the Virtual Environment
Windows:
venv\Scripts\activate
Linux/Mac:
source venv/bin/activate
4. Install Dependencies
pip install mcp pythonnet
Configuration
Claude Desktop Configuration
Add the following configuration to your Claude Desktop config file:
Location: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"powerbi": {
"command": "C:\\Path\\To\\Your\\venv\\Scripts\\python.exe",
"args": [
"C:\\Path\\To\\Your\\powerbi_mcp_server.py"
]
}
}
}
Example Configuration:
{
"mcpServers": {
"powerbi": {
"command": "D:\\Job Preparation\\Personnel Work\\Python - Technology\\VS Code Python Code\\Claude-Power BI-Intergration\\venv\\Scripts\\python.exe",
"args": [
"D:\\Job Preparation\\Personnel Work\\Python - Technology\\VS Code Python Code\\Claude-Power BI-Intergration\\powerbi_mcp_server.py"
]
}
}
}
Important: Replace the paths with your actual project paths. Use double backslashes (\\) or forward slashes (/) in JSON.
Finding Your Paths
-
Python executable path:
where python # Or if in virtual environment venv\Scripts\python.exe -
Script path:
- Navigate to your project folder
- Copy the full path to
powerbi_mcp_server.py
Usage
1. Start Power BI Desktop
Ensure Power BI Desktop is running with a report/model open.
2. Restart Claude Desktop
After updating the configuration, restart Claude Desktop to load the MCP server.
3. Verify Connection
In Claude, you can ask:
"Can you connect to my Power BI model?"
Claude will use the MCP server to connect and retrieve model information.
Available Tools
The MCP server provides the following tools to Claude:
| Tool | Description |
|---|---|
get_powerbi_models | Get all Power BI models in the active report |
get_model_tables | List all tables in the model |
get_table_columns | Get columns from a specific table |
execute_dax_query | Execute DAX queries against the model |
get_measures | Retrieve all measures (optionally filtered by table) |
get_relationships | Get all relationships in the model |
get_report_pages | Get report pages (limited - requires COM) |
get_page_visuals | Get visuals from a page (limited - requires COM) |
Example Queries
Once configured, you can ask Claude:
- "Show me all tables in my Power BI model"
- "What columns are in the Sales table?"
- "Execute this DAX query: EVALUATE TOPN(10, Sales)"
- "What measures are defined in the model?"
- "Show me the relationships between tables"
- "Calculate total sales by year using DAX"
How It Works
- Port Detection: The server automatically finds the local Analysis Services port used by Power BI Desktop
- XMLA Connection: Connects using the MSOLAP provider through OleDB
- DMV Queries: Uses Dynamic Management Views (DMVs) to retrieve metadata
- DAX Execution: Executes DAX queries and returns results to Claude
Troubleshooting
"Could not find Power BI Desktop Analysis Services port"
Solution:
- Ensure Power BI Desktop is running
- Open a report/model in Power BI Desktop
- The XMLA endpoint is only active when a model is loaded
"pythonnet not installed"
Solution:
pip install pythonnet
MCP Server Not Showing in Claude
Solution:
- Verify the JSON configuration is valid (use a JSON validator)
- Check that paths use double backslashes or forward slashes
- Restart Claude Desktop completely
- Check Claude Desktop logs:
%APPDATA%\Claude\logs
Connection Errors
Solution:
- Ensure you have the Microsoft OLE DB Provider for Analysis Services installed
- This comes with Power BI Desktop but may need repair/reinstall
- Try running Claude Desktop as Administrator
Limitations
- Windows Only: Power BI Desktop and XMLA endpoints are Windows-specific
- Local Only: Connects only to local Power BI Desktop instances
- Report Pages/Visuals: Limited access to report-level objects (requires Power BI COM interface)
- No Data Modification: Read-only access to the model
Technical Details
Architecture
Claude Desktop
↓
MCP Server (Python)
↓
pythonnet → .NET OleDb
↓
MSOLAP Provider
↓
Power BI Desktop (XMLA Endpoint)
Security
- All connections are local (localhost)
- Uses Windows Integrated Security (SSPI)
- No external network access required
- No API keys or credentials needed
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
[Add your license here]
Resources
- Power BI XMLA Endpoint Documentation
- DAX Query Language
- Model Context Protocol
- Analysis Services DMVs
Support
For issues or questions:
- Check the Troubleshooting section
- Review Power BI Desktop logs
- Check Claude Desktop logs in
%APPDATA%\Claude\logs - Open an issue on GitHub
Note: This is a community project and is not officially supported by Microsoft or Anthropic.