powerbi-mcp
If you are the rightful owner of powerbi-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Power BI MCP Server is a Model Context Protocol server that allows AI assistants to interact with Power BI datasets using natural language, enabling seamless data querying and insight generation.
Power BI MCP Server ๐
๐ฅ Live Demo
Transform your Power BI experience - ask questions in natural language and get instant insights from your data.
A Model Context Protocol (MCP) server that enables AI assistants to interact with Power BI datasets through natural language. Query your data, generate DAX, and get insights without leaving your AI assistant.
โจ Features
- ๐ Direct Power BI Connection - Connect to any Power BI dataset via XMLA endpoints
- ๐ฌ Natural Language Queries - Ask questions in plain English, get DAX queries and results
- ๐ Automatic DAX Generation - AI-powered DAX query generation using GPT-4o-mini
- ๐ Table Discovery - Automatically explore tables, columns, and measures
- โก Optimized Performance - Async operations and intelligent caching
- ๐ก๏ธ Secure Authentication - Service Principal authentication with Azure AD
- ๐ Smart Suggestions - Get relevant question suggestions based on your data
๐ฅ Demo
Ask questions like "What are total sales by region?" and get instant insights from your Power BI data.
๐ Quick Start
Prerequisites
- Python 3.8 or higher
- Windows OS (required for ADOMD.NET)
- SQL Server Management Studio (SSMS) or ADOMD.NET client libraries
- Power BI Pro/Premium with XMLA endpoint enabled
- Azure AD Service Principal with access to your Power BI dataset
- OpenAI API key
Installation
-
Clone the repository
git clone https://github.com/yourusername/powerbi-mcp-server.git cd powerbi-mcp-server
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
cp .env.example .env # Edit .env with your credentials
-
Test the connection
python quickstart.py
Configure with Claude Desktop
Add to your Claude Desktop configuration file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"powerbi": {
"command": "python",
"args": ["C:/path/to/powerbi-mcp-server/src/server.py"],
"env": {
"PYTHONPATH": "C:/path/to/powerbi-mcp-server",
"OPENAI_API_KEY": "your-openai-api-key"
}
}
}
}
๐ Usage
Once configured, you can interact with your Power BI data through Claude:
Connect to Your Dataset
Connect to Power BI dataset at powerbi://api.powerbi.com/v1.0/myorg/YourWorkspace
Explore Your Data
What tables are available?
Show me the structure of the Sales table
Ask Questions
What are the total sales by product category?
Show me the trend of revenue over the last 12 months
Which store has the highest gross margin?
Execute Custom DAX
Execute DAX: EVALUATE SUMMARIZE(Sales, Product[Category], "Total", SUM(Sales[Amount]))
๐ง Configuration
Required Credentials
-
Power BI XMLA Endpoint
- Format:
powerbi://api.powerbi.com/v1.0/myorg/WorkspaceName
- Enable in Power BI Admin Portal โ Workspace Settings
- Format:
-
Azure AD Service Principal
- Create in Azure Portal โ App Registrations
- Grant access in Power BI Workspace โ Access settings
-
OpenAI API Key
- Get from OpenAI Platform
- Model used:
gpt-4o-mini
(200x cheaper than GPT-4)
Environment Variables
Create a .env
file:
# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4o-mini # Optional: defaults to gpt-4o-mini
# Optional: Default Power BI Credentials
DEFAULT_TENANT_ID=your_tenant_id
DEFAULT_CLIENT_ID=your_client_id
DEFAULT_CLIENT_SECRET=your_client_secret
# Logging
LOG_LEVEL=INFO
๐๏ธ Architecture
powerbi-mcp-server/
โโโ src/
โ โโโ server.py # Main MCP server implementation
โโโ docs/ # Documentation
โโโ examples/ # Example queries and use cases
โโโ tests/ # Test suite
โโโ .env.example # Environment variables template
โโโ requirements.txt # Python dependencies
โโโ quickstart.py # Quick test script
โโโ README.md # This file
Key Components
- PowerBIConnector - Handles XMLA connections and DAX execution
- DataAnalyzer - AI-powered query generation and interpretation
- PowerBIMCPServer - MCP protocol implementation
๐ Security Best Practices
- Never commit credentials - Use
.env
files and keep them in.gitignore
- Use Service Principals - Avoid personal credentials
- Minimal permissions - Grant only necessary access to datasets
- Rotate secrets regularly - Update Service Principal secrets periodically
- Use secure connections - Always use HTTPS/TLS
๐งช Testing
Run the test suite:
python -m pytest tests/
Test specific functionality:
python tests/test_connection.py
python tests/test_dax_generation.py
๐ค Contributing
We welcome contributions! Please see for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
๐ Performance
- Connection time: 2-3 seconds
- Query execution: 1-5 seconds depending on complexity
- Token usage: ~500-2000 tokens per query with GPT-4o-mini
- Cost: ~$0.02-0.06 per day for typical usage
๐ Troubleshooting
Common Issues
-
ADOMD.NET not found
- Install SQL Server Management Studio (SSMS)
- Or download ADOMD.NET
-
Connection fails
- Verify XMLA endpoint is enabled in Power BI
- Check Service Principal has workspace access
- Ensure dataset name matches exactly
-
Timeout errors
- Increase timeout in Claude Desktop config
- Check network connectivity to Power BI
See for detailed solutions.
๐ License
This project is licensed under the MIT License - see the file for details.
๐ Acknowledgments
- Anthropic for the MCP specification
- Microsoft for Power BI and ADOMD.NET
- OpenAI for GPT models
- The MCP community for inspiration and support
๐ฌ Support
- ๐ง Email:
- ๐ฌ Issues: GitHub Issues
- ๐ Docs: Full Documentation