# zedmoster/revit-mcp architecture

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

- Interactive diagram: https://gitdiagram.com/zedmoster/revit-mcp
- Repository: https://github.com/zedmoster/revit-mcp

## Overview

##### Project type and purpose
- This is a Python-based integration library (“xml.Revit.MCP Tools”) that exposes Autodesk Revit functionality via the Model Context Protocol (MCP) and JSON-RPC, allowing AI agents or other clients to programmatically drive Revit.
- Its primary use case is to run a JSON-RPC server (main.py / xml_revit_mcp/server.py) that proxies calls to a Revit plugin (the MCP DLL) over stdio (via UV’s “uvx revit-mcp” command).

##### File structure
- Top level:
- main.py — entry point that launches the MCP JSON-RPC server
- pyproject.toml / build.bat — build and packaging
- tests/ — end-to-end tests covering each exported command
- xml_revit_mcp/ — the package implementing prompts, RPC glue, resource definitions, connection management, and high-level tools.
- Key modules under xml_revit_mcp:
- server.py — JSON-RPC server setup
- revit_connection.py & rpc.py — low-level request/response framing
- tools.py & prompts.py — high-level helpers for AI integration
- resources.py — command metadata
- Tests spin up a test TCP bridge (_tcp.py) or the real “uvx revit-mcp” server to validate each operation.

##### README for additional insights
- Describes all supported operations (create walls, query parameters, etc.)
- Specifies dependencies: Python 3.10+, uv, Revit 2019–2024
- Outlines how AI assistants (e.g., Claude, Cursor, Cline) integrate via JSON-RPC settings.

##### Essential details to capture
- The stdio transport boundary between Python and Revit
- The modular structure inside xml_revit_mcp (server vs. tools vs. connection)
- The extension point where custom MCP DLLs slot in

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    AIClient["AI Client<br/>(e.g., Claude, Cursor)"]:::client

    %% Python Package Components
    subgraph "xml.Revit.MCP Python Package" 
        direction TB
        Main["main.py<br/>(JSON-RPC Entry)"]:::core
        ServerImpl["server.py<br/>(JSON-RPC Server)"]:::core
        subgraph "RPC Transport Layer"
            direction TB
            Connection["revit_connection.py"]:::transport
            RPC["rpc.py"]:::transport
        end
        subgraph "High-Level Helpers"
            direction TB
            Tools["tools.py"]:::client
            Prompts["prompts.py"]:::client
        end
        Resources["resources.py<br/>(Command Metadata)"]:::client
    end

    %% Transport & Plugin
    UVCLI["UV CLI<br/>(uvx revit-mcp)"]:::transport
    RevitPlugin["Revit MCP Plugin<br/>(C# DLL)"]:::plugin

    %% Revit App
    RevitApp["Autodesk Revit Application"]:::plugin

    %% Peripheral Files
    subgraph "Build & Packaging"
        Pyproj["pyproject.toml"]:::infra
        BuildScript["build.bat"]:::infra
    end
    subgraph "Tests"
        direction TB
        Tests["tests/"]:::infra
        TCPBridge["tests/_tcp.py"]:::infra
    end

    %% Data Flows
    AIClient -->|"JSON-RPC request"| Main
    Main -->|"forwards to"| ServerImpl
    ServerImpl -->|"uses"| Connection
    ServerImpl -->|"uses"| RPC
    ServerImpl -->|"calls helpers"| Tools
    ServerImpl -->|"calls prompts"| Prompts
    ServerImpl -->|"reads metadata"| Resources
    ServerImpl -->|"spawns"| UVCLI
    UVCLI -->|"RPC call"| RevitPlugin
    RevitPlugin -->|"calls Revit API"| RevitApp
    RevitPlugin -->|"returns result"| UVCLI
    UVCLI -->|"stdio response"| ServerImpl
    ServerImpl -->|"JSON-RPC response"| AIClient

    %% Click Events
    click Main "https://github.com/zedmoster/revit-mcp/blob/main/main.py"
    click ServerImpl "https://github.com/zedmoster/revit-mcp/blob/main/xml_revit_mcp/server.py"
    click Connection "https://github.com/zedmoster/revit-mcp/blob/main/xml_revit_mcp/revit_connection.py"
    click RPC "https://github.com/zedmoster/revit-mcp/blob/main/xml_revit_mcp/rpc.py"
    click Tools "https://github.com/zedmoster/revit-mcp/blob/main/xml_revit_mcp/tools.py"
    click Prompts "https://github.com/zedmoster/revit-mcp/blob/main/xml_revit_mcp/prompts.py"
    click Resources "https://github.com/zedmoster/revit-mcp/blob/main/xml_revit_mcp/resources.py"
    click Pyproj "https://github.com/zedmoster/revit-mcp/blob/main/pyproject.toml"
    click BuildScript "https://github.com/zedmoster/revit-mcp/blob/main/build.bat"
    click Tests "https://github.com/zedmoster/revit-mcp/tree/main/tests/"
    click TCPBridge "https://github.com/zedmoster/revit-mcp/blob/main/tests/_tcp.py"

    %% Styles
    classDef client fill:#E0F7FA,stroke:#0288D1,color:#01579B
    classDef transport fill:#C8E6C9,stroke:#2E7D32,color:#1B5E20
    classDef core fill:#BBDEFB,stroke:#1976D2,color:#0D47A1
    classDef plugin fill:#FFE0B2,stroke:#F57C00,color:#E65100
    classDef infra fill:#E1BEE7,stroke:#6A1B9A,color:#4A148C
```
