Power BI MCP Server
Enables AI assistants to interact with Power BI datasets through natural language, allowing users to query data, generate DAX, and get insights without leaving their AI assistant.
README
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
.envfiles 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 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
📊 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 TROUBLESHOOTING.md for detailed solutions.
📝 License
This project is licensed under the MIT License - see the LICENSE 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: sulaimanahmed013@gmail.com
- 💬 Issues: GitHub Issues
- 📚 Docs: Full Documentation
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。