pbixray-mcp-server

Integrations

  • Used as a dependency for data processing operations in the PBIXRay server, supporting statistical analysis and data manipulation of Power BI models.

PBIXRay MCP 服务器

PBIXRay 的模型上下文协议(MCP) 服务器。

该 MCP 服务器将PBIXRay的功能公开为 LLM 客户端与 Power BI (.pbix) 文件交互的工具和资源。

特征

  • [x] 加载和分析 PBIX 文件
  • [x] 数据模型探索
    • [x] 列出模型中的表
    • [x] 检索模型元数据
    • [x] 检查模型尺寸
    • [x] 获取模型统计数据
    • [x] 获取全面的模型摘要
  • [x] 查询语言访问
    • [x] 查看 Power Query (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 Query 代码
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 模型的全面摘要

用法

WSL(推荐)

将服务器配置添加到客户端配置文件中。例如,对于 Claude Desktop:

{ "mcpServers": { "pbixray": { "command": "wsl.exe", "args": [ "bash", "-c", "source ~/dev/pbixray-mcp/venv/bin/activate && python ~/dev/pbixray-mcp/src/pbixray_server.py" ] } } }

WSL 路径转换(例如 Claude 项目说明)

在 Windows 上使用 Claude Desktop 在 WSL 中使用 PBIXRay MCP 服务器时,加载 PBIX 文件时需要注意路径差异。Windows 路径(例如C:\Users\name\file.pbix )无法在 WSL 中直接访问。请在项目说明中添加“请注意,mcp 服务器正在 WSL 中运行。Windows 路径(例如 C:\Users\name\file.pbix )无法在 WSL 中直接访问。请在引用文件时使用 WSL 路径:Windows:C:\Users\name\Downloads\file.pbix”或类似说明,让您的 AI 助手知道如何在路径之间进行转换。

命令行选项

该服务器支持多个命令行选项:

  • --disallow [tool_names] :出于安全原因禁用特定工具
  • --max-rows N :设置返回的最大行数(默认值:100)
  • --page-size N :设置分页结果的默认页面大小(默认值:20)

可以根据需要在配置json中添加命令行选项:

{ "mcpServers": { "pbixray": { "command": "wsl.exe", "args": [ "bash", "-c", "source ~/dev/pbixray-mcp/venv/bin/activate && python ~/dev/pbixray-mcp/src/pbixray_server.py --max-rows 100 --page-size 50 --disallow get_power_query" ], "env": {} } } }

查询选项

工具支持用于过滤和分页的附加参数:

按名称过滤

get_dax_measuresget_dax_columnsget_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)

开发和测试

您可以安装 PBIXRay MCP 服务器:

pip install pbixray-mcp-server

开发安装

对于参与该项目的开发人员:

  1. 克隆存储库:
    git clone https://github.com/username/pbixray-mcp.git cd pbixray-mcp
  2. 以开发模式安装:
    pip install -e .
  3. 如果从源安装,请创建虚拟环境并安装依赖项:
    python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install mcp pbixray numpy

使用示例文件进行测试

该存储库包含示例文件和测试脚本,以帮助您入门:

# 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

测试脚本将帮助您了解如何使用demo/目录中提供的示例 PBIX 文件与服务器交互。

开发模式

要在开发过程中测试服务器,请使用 MCP Inspector:

# Activate your environment first source venv/bin/activate # Run the MCP Inspector mcp dev src/pbixray_server.py

这将启动一个交互式会话,您可以在其中调用工具和测试响应。

项目结构

pbixray-mcp/ ├── README.md - This file ├── INSTALLATION.md - Detailed installation instructions ├── 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

贡献

非常欢迎贡献!

致谢

  • Hugoberry - 原始 PBIXRay 库
  • rusiaaman - WCGW(此 MCP 完全由 Claude 使用 wcgw 编写)

许可证(克劳德坚持要添加这些)

MIT 许可证

-
security - not tested
A
license - permissive license
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

模型上下文协议使 AI 客户端能够通过 PBIXRay python 包查询元数据与 PowerBI 模型进行交互。

  1. 特征
    1. 工具
      1. 用法
        1. WSL(推荐)
          1. WSL 路径转换(例如 Claude 项目说明)
          2. 命令行选项
          3. 查询选项
        2. 开发和测试
          1. 开发安装
          2. 使用示例文件进行测试
          3. 开发模式
          4. 项目结构
        3. 贡献
          1. 致谢
            1. 许可证(克劳德坚持要添加这些)

              Related MCP Servers

              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol server that provides seamless interaction with Workato's API through custom AI tools, enabling management of recipes, connections, connectors, folders, and activity logs.
                Last updated -
                TypeScript
                MIT License
                • Apple
                • Linux
              • A
                security
                F
                license
                A
                quality
                Implements the Model Context Protocol to allow AI models to access and interact with blockchain data, including reading contract states, retrieving events, and accessing transaction information across various networks.
                Last updated -
                10
                45
                30
                TypeScript
              • -
                security
                A
                license
                -
                quality
                A streamlined foundation for building Model Context Protocol servers in Python, designed to make AI-assisted development of MCP tools easier and more efficient.
                Last updated -
                12
                Python
                MIT License
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server that enables AI models to create and manipulate PowerPoint presentations with advanced features like financial charts, formatting, and template management.
                Last updated -
                1
                Python

              View all related MCP servers

              ID: vibjpsvwgs