# jonaolden/pbixray-mcp-server architecture

> Architecture diagram of the GitHub repository jonaolden/pbixray-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jonaolden/pbixray-mcp-server
- Repository: https://github.com/jonaolden/pbixray-mcp-server

## Overview

##### Project Type & Purpose
- This is a specialized server that exposes the capabilities of the PBIXRay tool as a Model Context Protocol (MCP) server, allowing language model clients (LLM clients) to analyze Power BI (.pbix) files and extract detailed metadata (such as tables, DAX expressions, relationships, etc.).
- The README makes it clear that the server functions as an interface layer between PBIXRay’s functionality and the client’s requests, essentially serving as a microservice (or a dedicated backend server) that supports various commands/tools.

##### File Structure and Its Implications
- Key directories include:
- src: Contains the main server code (pbixray_server.py) which likely sets up endpoints and maps tool calls.
- tests: Holds test scripts to verify server functionality (e.g., test_server.py, test_with_sample.py), ensuring the correct behavior of each tool.
- examples and demo: Provide usage scenarios and sample configurations, highlighting how a client might interact with the server.
- docs and INSTALLATION.md: Contain additional details about the project's roadmap and installation instructions.
- Auxiliary files like run_server.sh and setup.py show that the project supports both direct command-line invocation and integration with various environments (like WSL with Claude Desktop).

##### Key Components to Highlight
- LLM Client / MCP Client: Represent the entity that interacts with the server through command-line interfaces or API calls.
- PBIXRay MCP Server (Main Server Component):
- This component is built around the core Python script (src/pbixray_server.py) and is responsible for exposing various analysis tools.
- It accepts command line parameters (for example, --disallow options, max-rows, page-size) to adjust how the underlying functionalities operate.
- PBIXRay Library: Although not explicitly in this codebase, it is implied (via credits) that the server wraps external functionality. Show that the server internally calls the PBIXRay tools or functions which perform file analysis.
- Power BI File Input: Denote how the server loads and processes .pbix files provided by the client.
- Tools/Endpoints: Enumerate the distinct functions (load_pbix_file, get_tables, get_metadata, get_power_query, get_m_parameters, etc.) as individual service endpoints or modules within the server. They serve as the interface through which the server interacts with the PBIX file.
- Configuration/Deployment Components: Include elements such as deploy scripts (run_server.sh), virtual environment setup, and configuration files (like examples/config/mcp_client_config.json).

##### Relationships and Data Flow
- Server’s internal call from the MCP endpoint to the underlying PBIXRay functionality which processes the .pbix file.
- That configuration parameters (like command line options to disable tools) affect the behavior of the server’s modules.

##### Architectural Patterns & Design Principles
- This project follows a modular design where each tool is separated into its individual functionality behind a unified server interface.
- Separation of concerns: the exposed MCP tools are distinct endpoints and the server ensures each tool’s logic remains segregated, allowing for easier testing and potential future extensions.
- That the design supports security measures (disabling certain tools) and scalability (pagination for large tables) which could be highlighted with annotations.

##### Including Important Details
- Mention the testing and example directories as part of the development cycle but not necessarily part of the live runtime architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        client("LLM/MCP Client"):::client
    end

    %% Server Layer
    subgraph "Server Layer"
        server("PBIXRay MCP Server"):::server
        subgraph "MCP Endpoints"
            ep1("load_pbix_file"):::endpoint
            ep2("get_tables"):::endpoint
            ep3("get_metadata"):::endpoint
            ep4("get_power_query"):::endpoint
            ep5("get_m_parameters"):::endpoint
        end
    end

    %% Analysis Layer
    subgraph "Analysis Layer"
        library("PBIXRay Analysis Library"):::library
        file("Power BI .pbix File Input"):::file
    end

    %% Deployment & Development Components
    subgraph "Deployment & Dev Components"
        deploy("Deployment Scripts"):::deploy
        tests("Testing Suite"):::tests
        docs("Documentation & Roadmap"):::docs
    end

    %% Data Flow Connections
    client -->|"requests"| server
    server -->|"delegates"| ep1
    server -->|"delegates"| ep2
    server -->|"delegates"| ep3
    server -->|"delegates"| ep4
    server -->|"delegates"| ep5
    server -->|"calls"| library
    library -->|"processes"| file
    library -->|"returns metadata"| server
    server -->|"responses"| client

    %% Auxiliary Connections
    client ---|"example usage"| deploy
    client ---|"validate"| tests
    client ---|"read_docs"| docs

    %% Click Events for Component Mapping
    click client "https://github.com/jonaolden/pbixray-mcp-server/blob/main/examples/config/mcp_client_config.json"
    click client "https://github.com/jonaolden/pbixray-mcp-server/blob/main/examples/demo.py"
    click server "https://github.com/jonaolden/pbixray-mcp-server/blob/main/src/pbixray_server.py"
    click file "https://github.com/jonaolden/pbixray-mcp-server/blob/main/demo/AdventureWorks Sales.pbix"
    click deploy "https://github.com/jonaolden/pbixray-mcp-server/blob/main/run_server.sh"
    click deploy "https://github.com/jonaolden/pbixray-mcp-server/blob/main/setup.py"
    click tests "https://github.com/jonaolden/pbixray-mcp-server/blob/main/tests/test_server.py"
    click tests "https://github.com/jonaolden/pbixray-mcp-server/blob/main/tests/test_with_sample.py"
    click tests "https://github.com/jonaolden/pbixray-mcp-server/blob/main/tests/conftest.py"
    click tests "https://github.com/jonaolden/pbixray-mcp-server/blob/main/test_pagination.py"
    click docs "https://github.com/jonaolden/pbixray-mcp-server/blob/main/docs/ROADMAP.md"
    click docs "https://github.com/jonaolden/pbixray-mcp-server/blob/main/docs/TESTING.md"
    click docs "https://github.com/jonaolden/pbixray-mcp-server/blob/main/INSTALLATION.md"

    %% Styles
    classDef client fill:#aaffaa,stroke:#333,stroke-width:1px;
    classDef server fill:#ffddaa,stroke:#333,stroke-width:1px;
    classDef endpoint fill:#aaddff,stroke:#333,stroke-width:1px;
    classDef library fill:#ddaaff,stroke:#333,stroke-width:1px;
    classDef file fill:#ffaaaa,stroke:#333,stroke-width:1px;
    classDef deploy fill:#ffffaa,stroke:#333,stroke-width:1px;
    classDef tests fill:#aaffff,stroke:#333,stroke-width:1px;
    classDef docs fill:#ffaaff,stroke:#333,stroke-width:1px;
```
