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.
- π 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
Ask questions like "What are total sales by region?" and get instant insights from your Power BI data.
- Python 3.8 or higher
- Windows with ADOMD.NET or Docker on Linux (container includes the runtime)
- SQL Server Management Studio (SSMS) or ADOMD.NET client libraries (Windows only)
- Power BI Pro/Premium with XMLA endpoint enabled
- Azure AD Service Principal with access to your Power BI dataset
- OpenAI API key (optional for natural language features)
-
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
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"
}
}
}
}
Build the container image:
docker build -t powerbi-mcp .
Run the server:
docker run -it --rm -e OPENAI_API_KEY=<key> powerbi-mcp
The container listens on port 8000
by default. Override the host or port using
environment variables or command-line arguments:
docker run -it --rm -e OPENAI_API_KEY=<key> -p 7000:7000 powerbi-mcp \
python src/server.py --host 0.0.0.0 --port 7000
The server exposes a Server-Sent Events endpoint at /sse
. Clients should
connect to this endpoint and then POST JSON-RPC messages to the path provided in
the initial endpoint
event (typically /messages/
).
The container includes the .NET runtime required by pythonnet
and pyadomd
.
It sets PYTHONNET_RUNTIME=coreclr
and DOTNET_ROOT=/usr/share/dotnet
so the
.NET runtime is detected automatically. Environment variables mirror those in
.env.example
; pass them with -e VAR=value
or provide a .env
file in the
build context.
Once configured, you can interact with your Power BI data through Claude:
Connect to Power BI dataset at powerbi://api.powerbi.com/v1.0/myorg/YourWorkspace
What tables are available?
Show me the structure of the Sales table
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 DAX: EVALUATE SUMMARIZE(Sales, Product[Category], "Total", SUM(Sales[Amount]))
-
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 (optional)
- Needed only for natural language features
- Endpoints that rely on GPT models are hidden if this key is not set
- Get from OpenAI Platform
- Model used:
gpt-4o-mini
(200x cheaper than GPT-4)
Create a .env
file (OpenAI settings are optional):
# OpenAI Configuration (optional)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4o-mini # Defaults to gpt-4o-mini
# Optional: Default Power BI Credentials
# These values are used when the `connect_powerbi` action does not supply
# tenant_id, client_id or client_secret.
DEFAULT_TENANT_ID=your_tenant_id
DEFAULT_CLIENT_ID=your_client_id
DEFAULT_CLIENT_SECRET=your_client_secret
# Logging
LOG_LEVEL=INFO
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
- PowerBIConnector - Handles XMLA connections and DAX execution
- DataAnalyzer - AI-powered query generation and interpretation
- PowerBIMCPServer - MCP protocol implementation
- 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
Run the test suite:
python -m pytest tests/
Test specific functionality:
python tests/test_connection.py
python tests/test_dax_generation.py
We welcome contributions! Please see CONTRIBUTING.md 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
- 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
-
ADOMD.NET not found
- For Windows, install SQL Server Management Studio (SSMS)
- On Linux, use the provided Docker image which bundles the cross-platform ADOMD.NET runtime
-
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 TROUBLESHOOTING.md for detailed solutions.
This project is licensed under the MIT License - see the LICENSE file for details.
- Anthropic for the MCP specification
- Microsoft for Power BI and ADOMD.NET
- OpenAI for GPT models
- The MCP community for inspiration and support
- π§ Email: [email protected]
- π¬ Issues: GitHub Issues
- π Docs: Full Documentation