PBIXRay MCP服务器
](https://mseep.ai/app/jonaolden-pbixray-mcp-server)
信息!
对这个项目感兴趣的人也可能对这个后续项目感兴趣, 表格式mcp,它允许对本地PowerBI模型运行DAX查询。非常感谢您的支持!
A. 模型上下文协议 PBIXRay的MCP服务器。
此MCP服务器公开了以下功能 PBIXRay 作为LLM客户端与Power BI(.pbix)文件交互的工具和资源。
特性
- \[x\] 加载和分析PBIX文件
- \[x\] 数据模型探索
- \[x\] 在模型中列出表 - \[x\] 正在检索模型元数据 - \[x\] 检查模型尺寸 - \[x\] 获取模型统计信息 - \[x\] 获取全面的模型摘要
- \[x\] 查询语言访问
- \[x\] 查看电源查询(M)代码 - \[x\] 访问M参数 - \[x\] 探索DAX计算表 - \[x\] 查看DAX指标 - \[x\] 检查DAX计算列
- \[x\] 数据结构分析
- \[x\] 正在检索架构信息 - \[x\] 分析表关系 - \[x\] 通过分页访问表内容
工具列表是可配置的,因此您可以选择要向MCP客户端提供哪些工具。
工具
| 工具 | 类别 | 描述 |
|---|---|---|
load_pbix_file | 核心 | 加载Power BI(.pbix)文件进行分析 |
get_tables | 模型 | 列出模型中的所有表 |
get_metadata | 模型 | 获取Power BI配置的元数据 |
get_power_query | 查询 | 显示用于数据转换的所有M/Power查询代码 |
get_m_parameters | 查询 | 显示所有M个参数值 |
get_model_size | 模型 | 获取模型大小(以字节为单位) |
get_dax_tables | 查询 | 查看DAX计算表 |
get_dax_measures | 查询 | 通过按表或度量值名称筛选访问DAX度量值 |
get_dax_columns | 查询 | 使用筛选选项访问计算列DAX表达式 |
get_schema | 结构 | 获取有关数据模型架构和列类型的详细信息 |
get_relationships | 结构 | 获取数据模型关系的详细信息 |
get_table_contents | 数据 | 使用分页检索指定表的内容 |
get_statistics | 模型 | 通过可选过滤获取模型的统计信息 |
get_model_summary | 模型 | 获取当前Power BI模型的全面摘要 |
需求
- Python 3.13 (推荐)或Python 3.10+
- uv包管理器
- Windows PowerShell
检查你的Python版本
python --version
# Should show Python 3.13.x (recommended) or 3.10+ minimum安装和设置
首次设置-创建虚拟环境
# Navigate to your project directory
cd "d:\AI\Guyen\pbixray-mcp-server-main"
# Check Python version (must be 3.10+)
python --version
# Create virtual environment with Python 3.13
uv venv --python 3.13
# Activate the virtual environment
.venv\Scripts\Activate.ps1
# Install dependencies
uv pip install mcp pbixray numpy
# Test that everything works
python src/pbixray_server.py --help验证
设置好所有内容后,您可以测试服务器:
# Navigate to your project directory
cd "d:\AI\Guyen\pbixray-mcp-server-main"
# Activate the virtual environment
.venv\Scripts\Activate.ps1
# Test the server
python src/pbixray_server.py --help您应该看到类似于以下内容的输出:
usage: pbixray_server.py [-h] [--disallow DISALLOW [DISALLOW ...]] [--max-rows MAX_ROWS] [--page-size PAGE_SIZE]
[--load-file LOAD_FILE]
PBIXRay MCP Server
options:
-h, --help show this help message and exit
--disallow DISALLOW [DISALLOW ...]
Specify tools to disable
--max-rows MAX_ROWS Maximum rows to return for table data (default: 10)
--page-size PAGE_SIZE
Default page size for paginated results (default: 10)
--load-file LOAD_FILE
Automatically load a PBIX file at startupClaude桌面配置
我的真实Claude_Desktop_config json
路径: C:\Users\guyen\AppData\Roaming\Claude
内容:
{
"mcpServers": {
"test-server": {
"command": "D:\\AI\\Guyen\\Claude-mcp-agentic-system\\.venv\\Scripts\\python.exe",
"args": ["D:\\AI\\Guyen\\Claude-mcp-agentic-system\\servers\\basic_server_clean.py"],
"env": {}
},
"pbixray": {
"command": "D:\\AI\\Guyen\\pbixray-mcp-server-main\\.venv\\Scripts\\python.exe",
"args": ["D:\\AI\\Guyen\\pbixray-mcp-server-main\\src\\pbixray_server.py"],
"env": {}
},
"powerbi": {
"command": "D:\\Projects\\powerbi-mcp-master\\.venv\\Scripts\\python.exe",
"args": [
"D:\\Projects\\powerbi-mcp-master\\src\\server.py"
],
"env": {
"PYTHONPATH": "D:\\Projects\\powerbi-mcp-master",
"OPENAI_API_KEY": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}PowerShell的替代配置
如果您更喜欢使用PowerShell命令:
{
"mcpServers": {
"pbixray": {
"command": "powershell.exe",
"args": [
"-Command",
"cd 'd:\\AI\\Guyen\\pbixray-mcp-server-main'; .venv\\Scripts\\Activate.ps1; python src/pbixray_server.py"
]
}
}
}紫外线运行的替代配置
如果您更喜欢使用 uv run (自动处理虚拟环境):
{
"mcpServers": {
"pbixray": {
"command": "powershell.exe",
"args": [
"-Command",
"cd 'd:\\AI\\Guyen\\pbixray-mcp-server-main'; uv run python src/pbixray_server.py"
]
}
}
}用法
Windows路径使用情况
在Windows上使用PBIXRay MCP服务器时,您可以直接使用标准的Windows路径:
# Load a PBIX file using Windows path
load_pbix_file("C:\\Users\\YourName\\Documents\\file.pbix")
# Or using forward slashes (also works)
load_pbix_file("C:/Users/YourName/Documents/file.pbix")命令行选项
服务器支持多种命令行选项:
--disallow [tool_names]:出于安全原因禁用特定工具--max-rows N:设置返回的最大行数(默认值:100)--page-size N:为分页结果设置默认页面大小(默认值:20)
查询选项
工具支持用于过滤和分页的其他参数:
按名称筛选
工具如 get_dax_measures, get_dax_columns, get_schema 其他支持按特定名称过滤:
# Get measures from a specific table
get_dax_measures(table_name="Sales")
# Get a specific measure
get_dax_measures(table_name="Sales", measure_name="Total Sales")大桌子分页
这 get_table_contents 该工具支持分页,以高效处理大型表:
# Get first page of Customer table (default 20 rows per page)
get_table_contents(table_name="Customer")
# Get second page with 50 rows per page
get_table_contents(table_name="Customer", page=2, page_size=50)开发和测试
uv开发安装
对于参与该项目的开发人员:
- 克隆存储库(如果尚未完成):
git clone https://github.com/username/pbixray-mcp.git
cd pbixray-mcp- 安装Python 3.13(如果需要):
uv python install 3.13- 使用Python 3.13创建虚拟环境:
uv venv --python 3.13- 激活虚拟环境:
.venv\Scripts\Activate.ps1- 在开发模式下安装:
uv pip install -e .- 安装依赖项:
uv pip install mcp pbixray numpy使用示例文件进行测试
该存储库包括示例文件和测试脚本,以帮助您入门:
在激活的虚拟环境中:
# Make sure you're in the project directory and venv is activated
cd "d:\AI\Guyen\pbixray-mcp-server-main"
.venv\Scripts\Activate.ps1
# Test with sample AdventureWorks Sales.pbix file in demo/ folder
python tests/test_with_sample.py
# Try the interactive demo
python examples/demo.py
# For isolated tests of specific features
python test_pagination.py
python test_metadata_fix.py使用uv run(自动处理venv):
# Test with sample AdventureWorks Sales.pbix file in demo/ folder
uv run python tests/test_with_sample.py
# Try the interactive demo
uv run python examples/demo.py
# For isolated tests of specific features
uv run python test_pagination.py
uv run python test_metadata_fix.py发展模式
要在开发过程中测试服务器,请使用MCP检查器:
在激活的虚拟环境中:
# Navigate to project directory
cd "d:\AI\Guyen\pbixray-mcp-server-main"
# Activate virtual environment
.venv\Scripts\Activate.ps1
# Run the MCP Inspector
mcp dev src/pbixray_server.py使用uv run(自动处理venv):
cd "d:\AI\Guyen\pbixray-mcp-server-main"
uv run mcp dev src/pbixray_server.py这将启动一个交互式会话,您可以在其中调用工具并测试响应。
项目结构
pbixray-mcp/
├── README.md - This file
├── INSTALLATION.md - Detailed installation instructions
├── pyproject.toml - uv/pip configuration
├── src/ - Source code
│ ├── __init__.py
│ └── pbixray_server.py
├── tests/ - Test scripts
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_server.py
│ └── test_with_sample.py
├── examples/ - Example scripts and configs
│ ├── demo.py
│ └── config/
├── demo/ - Sample PBIX files
│ ├── README.md
│ └── AdventureWorks Sales.pbix
└── docs/ - Additional documentation
└── ROADMAP.md替代安装方法
传统管道安装
您还可以使用pip安装PBIXRay MCP服务器:
pip install pbixray-mcp-server使用pip进行开发:
python -m venv venv
venv\Scripts\activate
pip install mcp pbixray numpyWSL(备选方案)
如果您更喜欢使用WSL,请将服务器配置添加到客户端配置文件中:
{
"mcpServers": {
"pbixray": {
"command": "wsl.exe",
"args": [
"bash",
"-c",
"source ~/dev/pbixray-mcp/venv/bin/activate && python ~/dev/pbixray-mcp/src/pbixray_server.py"
]
}
}
}WSL路径转换
在Windows上使用WSL中的PBIXRay MCP服务器和Claude Desktop时,加载PBIX文件时需要注意路径差异。 Windows路径(如 C:\Users\name\file.pbix)无法在WSL中直接访问。相反,在引用文件时使用WSL路径:
- 窗户:
C:\Users\name\Downloads\file.pbix - WSL:
/mnt/c/Users/name/Downloads/file.pbix
贡献
欢迎投稿!
