# utkarshsinghshorthillsai/fabricmcp_server architecture

> Architecture diagram of the GitHub repository utkarshsinghshorthillsai/fabricmcp_server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/utkarshsinghshorthillsai/fabricmcp_server
- Repository: https://github.com/utkarshsinghshorthillsai/fabricmcp_server

## Overview

##### Project type and purpose
- This is a backend API microservice (Python, Uvicorn) that exposes Microsoft Fabric operations (“tools”) to an LLM-based MCP Client.
- Its responsibilities: authenticate with Azure, translate MCP Client calls into Fabric API calls, manage sessions, and return responses.

##### File structure
- Top-level:
- `.env.example`, `pyproject.toml`, `uv.lock` → configuration and dependency management (Poetry/uv)
- `src/fabricmcp_server/app.py` → entry point (FastAPI or similar)
- `fabric_api_client.py` → wrapper for direct Fabric REST API calls
- `fabric_models.py` → Pydantic or data classes for request/response schemas
- `sessions.py` → in-memory/session caching of Fabric credentials or LLM context
- `activity_types.py` → definitions of supported MCP activities
- `tools/` → individual modules (connection_manager, items, lakehouses, notebooks, pipelines, universal_copy_activity) that implement each Fabric “tool”

##### README for stack and workflows
- Python 3.10+, `uv` (Uvicorn-like CLI), virtual env, MCP Client integration
- Workflow: MCP Client → HTTP → Server → Fabric API Client → Microsoft Fabric REST endpoints

##### Main components and interactions
a. MCP Client (LLM)
- Sends JSON-RPC or REST calls invoking “tools”
b. API Server (`app.py`)
- HTTP framework (FastAPI or similar under Uvicorn) handles incoming requests
- Routes requests to the appropriate tool module
c. Tool Modules (`tools/*.py`)
- Each module implements a business function (e.g., create lakehouse)
- Use `fabric_api_client` for HTTP calls to Fabric
d. Fabric API Client
- Handles authentication (via credentials from `.env`), token management, and request/response serialization
e. Azure/Microsoft Fabric Services
- External: Lakehouses, Notebooks, Pipelines, etc.
f. Session Manager
- Maintains session state (optional caching of tokens or context)

##### Architectural patterns & design principles
- Modular tool-based design: each Fabric feature lives in its own module under `tools/`
- Single‐responsibility: `fabric_api_client` vs. `fabric_models` vs. `sessions`
- Dependency injection via environment config (`.env`) for service principal credentials
- Stateless HTTP API; transient sessions managed in memory or simple cache

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Systems
    MCPClient["MCP Client (LLM)"]:::external
    FabricServices[(Microsoft Fabric Services)]:::external

    %% Infrastructure / Config
    Env[".env.example"]:::infra
    BuildConfig["pyproject.toml\nuv.lock"]:::infra
    README["README.md"]:::docs
    SessionMgr["Session Manager"]:::infra
    ActivityDefs["Activity Definitions"]:::infra

    %% Core Application
    subgraph "API Layer"
        APIServer["API Server\n(src/fabricmcp_server/app.py)"]:::core
        Models["Data Models\n(src/fabricmcp_server/fabric_models.py)"]:::core
    end

    subgraph "Business Logic"
        FabricClient["Fabric API Client\n(src/fabricmcp_server/fabric_api_client.py)"]:::core
        subgraph "Tool Modules"
            ConnMgr["connection_manager.py"]:::core
            Items["items.py"]:::core
            Lakehouses["lakehouses.py"]:::core
            Notebooks["notebooks.py"]:::core
            Pipelines["pipelines.py"]:::core
            UniversalCopy["universal_copy_activity.py"]:::core
        end
    end

    %% Data Flow
    MCPClient -->|"HTTP Request"| APIServer
    APIServer -->|"validate & parse"| Models
    APIServer -->|"route to tool"| ConnMgr
    APIServer --> ConnMgr
    APIServer --> Items
    APIServer --> Lakehouses
    APIServer --> Notebooks
    APIServer --> Pipelines
    APIServer --> UniversalCopy

    ConnMgr -->|"calls"| FabricClient
    Items --> FabricClient
    Lakehouses --> FabricClient
    Notebooks --> FabricClient
    Pipelines --> FabricClient
    UniversalCopy --> FabricClient

    FabricClient -->|"REST API"| FabricServices
    FabricServices -->|"response"| FabricClient
    FabricClient -->|"response"| ConnMgr
    ConnMgr --> APIServer
    Models --> APIServer
    APIServer -->|"HTTP Response"| MCPClient

    %% Config & Sessions
    Env --> APIServer
    APIServer --> FabricClient
    BuildConfig --> APIServer
    SessionMgr --> APIServer
    APIServer --> SessionMgr
    ActivityDefs --> APIServer

    %% Click Events
    click APIServer "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/app.py"
    click ConnMgr "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/tools/connection_manager.py"
    click Items "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/tools/items.py"
    click Lakehouses "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/tools/lakehouses.py"
    click Notebooks "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/tools/notebooks.py"
    click Pipelines "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/tools/pipelines.py"
    click UniversalCopy "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/tools/universal_copy_activity.py"
    click FabricClient "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/fabric_api_client.py"
    click Models "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/fabric_models.py"
    click SessionMgr "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/sessions.py"
    click ActivityDefs "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/src/fabricmcp_server/activity_types.py"
    click Env "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/.env.example"
    click BuildConfig "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/pyproject.toml"
    click README "https://github.com/utkarshsinghshorthillsai/fabricmcp_server/blob/main/README.md"

    %% Styles
    classDef external fill:#D8BFD8,stroke:#800080,color:#000
    classDef core fill:#ADD8E6,stroke:#00008B,color:#000
    classDef infra fill:#90EE90,stroke:#006400,color:#000
    classDef docs fill:#D3D3D3,stroke:#696969,color:#000
```
