# revit-mcp/revit-mcp-commandset architecture

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

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

## Overview

##### Project type and purpose
- This is a .NET/Visual Studio solution that implements a Revit add-in (plugin) called “Revit-MCP CommandSet.”
- Its purpose is to act as the core client for the Revit-MCP protocol, connecting large language models (LLMs) with Revit’s API to perform AI-driven BIM operations (CRUD on Revit elements, annotation, MEP components, views, etc.).

##### File structure
- Top-level:
- revit-mcp-commandset.sln (Visual Studio solution)
- .gitignore, LICENSE, README
- Project folder “revit-mcp-commandset” contains:
- Commands/… — C# classes defining ICommand implementations, grouped by functional areas (Access, AnnotationComponents, Delete, ExecuteDynamicCode, etc.).
- Models/… — DTOs and info objects for various domains (Common, Annotation, Architecture, MEP, Views).
- Services/… — EventHandler classes (e.g. CreateDimensionEventHandler, GetSelectedElementsEventHandler) that implement the logic invoked by each command.
- Utils/… — Helper classes for JSON schema generation, transaction management, geometry utilities, duplicate-type handling, etc.
- RevitMCPCommandSet.csproj — project configuration (references to Revit API, Newtonsoft.Json, MCP protocol client).

- Architectural hints:
- A command/event-handler (Command Pattern + event-driven) layered design: Commands → Services → Revit API.
- Models as data contracts between plugin and external MCP server/LLM.
- Utils for cross-cutting concerns.

##### README
- One-line summary: “Core implementation of the Revit-MCP protocol that connects LLMs with Revit. Includes essential CRUD commands for Revit elements enabling AI-driven BIM automation.”

##### Final recommendations
- Be exhaustive: include all major folders as logical groupings.
- Extension points: the ExecuteDynamicCode feature should stand out as a customizable hook.
- Error/transaction flow: optionally show Utils/TransactionUtils wrapping Revit API calls.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Service
    ExternalLLM["External MCP/LLM Service"]:::external

    %% Revit Host
    subgraph "Autodesk Revit Host" 
        direction TB
        subgraph "Revit-MCP CommandSet Plugin"
            direction TB
            %% Entry & Registrar
            Registrar["Command Registrar"]:::entry

            %% Commands Layer
            subgraph "Commands Layer" 
                direction TB
                AIFilterCmd["AIElementFilterCommand"]:::command
                AccessCmds["Access Commands"]:::command
                AnnotationCmd["CreateDimensionCommand"]:::command
                CreationCmds["Element Creation Commands"]:::command
                DeleteCmd["DeleteElementCommand"]:::command
                DynamicCmd["ExecuteCodeCommand"]:::command
                OtherCmds["Other Commands"]:::command
            end

            %% Services Layer
            subgraph "Services Layer"
                direction TB
                AIFilterHandler["AIElementFilterEventHandler"]:::service
                AccessHandlers["Access Handlers"]:::service
                AnnotationHandler["CreateDimensionEventHandler"]:::service
                CreationHandlers["Element Creation Handlers"]:::service
                DeleteHandler["DeleteElementEventHandler"]:::service
                DynamicHandler["ExecuteCodeEventHandler"]:::service
                OtherHandlers["Other Handlers"]:::service
            end

            %% Models Layer
            subgraph "Models (DTOs)"
                direction TB
                CommonModels["Common Models"]:::model
                AnnotationModels["Annotation Models"]:::model
                ArchitectureModels["Architecture Models"]:::model
                MEPModels["MEP Models"]:::model
                ViewsModels["Views Models"]:::model
            end

            %% Utils Layer
            subgraph "Utils (Infrastructure)"
                direction TB
                UtilsDir["Utils"]:::util
            end

            %% Revit API
            RevitAPI["Revit API (Autodesk.Revit.DB/UI)"]:::infra
        end
    end

    %% Flow Arrows
    ExternalLLM -->|"Revit-MCP Protocol"| Registrar
    Registrar -->|invokes| AIFilterCmd
    Registrar -->|invokes| AccessCmds
    Registrar -->|invokes| AnnotationCmd
    Registrar -->|invokes| CreationCmds
    Registrar -->|invokes| DeleteCmd
    Registrar -->|invokes| DynamicCmd
    Registrar -->|invokes| OtherCmds

    AIFilterCmd -->|packages into Model| CommonModels
    AccessCmds -->|packages into Model| CommonModels
    AnnotationCmd -->|packages into Model| AnnotationModels
    CreationCmds -->|packages into Model| ArchitectureModels
    DeleteCmd -->|packages into Model| CommonModels
    DynamicCmd -->|packages into Model| CommonModels
    OtherCmds -->|packages into Model| CommonModels

    AIFilterCmd -->|calls| AIFilterHandler
    AccessCmds -->|calls| AccessHandlers
    AnnotationCmd -->|calls| AnnotationHandler
    CreationCmds -->|calls| CreationHandlers
    DeleteCmd -->|calls| DeleteHandler
    DynamicCmd -->|calls| DynamicHandler
    OtherCmds -->|calls| OtherHandlers

    AIFilterHandler -->|uses| RevitAPI
    AccessHandlers -->|uses| RevitAPI
    AnnotationHandler -->|uses| RevitAPI
    CreationHandlers -->|uses| RevitAPI
    DeleteHandler -->|uses| RevitAPI
    DynamicHandler -->|uses| RevitAPI
    OtherHandlers -->|uses| RevitAPI

    %% Utils usage
    AIFilterHandler -->|utilizes| UtilsDir
    AccessHandlers -->|utilizes| UtilsDir
    AnnotationHandler -->|utilizes| UtilsDir
    CreationHandlers -->|utilizes| UtilsDir
    DeleteHandler -->|utilizes| UtilsDir
    DynamicHandler -->|utilizes| UtilsDir
    OtherHandlers -->|utilizes| UtilsDir

    %% Click Events
    click revit-mcp-commandset.sln "https://github.com/revit-mcp/revit-mcp-commandset/blob/main/revit-mcp-commandset.sln"
    click Registrar "https://github.com/revit-mcp/revit-mcp-commandset/blob/main/revit-mcp-commandset/RevitMCPCommandSet.csproj"
    click AIFilterCmd "https://github.com/revit-mcp/revit-mcp-commandset/blob/main/revit-mcp-commandset/Commands/AIElementFilterCommand.cs"
    click AccessCmds "https://github.com/revit-mcp/revit-mcp-commandset/tree/main/revit-mcp-commandset/Commands/Access"
    click AnnotationCmd "https://github.com/revit-mcp/revit-mcp-commandset/blob/main/revit-mcp-commandset/Commands/AnnotationComponents/CreateDimensionCommand.cs"
    click CreationCmds "https://github.com/revit-mcp/revit-mcp-commandset/tree/main/revit-mcp-commandset/Commands"
    click DeleteCmd "https://github.com/revit-mcp/revit-mcp-commandset/blob/main/revit-mcp-commandset/Commands/Delete/DeleteElementCommand.cs"
    click DynamicCmd "https://github.com/revit-mcp/revit-mcp-commandset/blob/main/revit-mcp-commandset/Commands/ExecuteDynamicCode/ExecuteCodeCommand.cs"
    click AccessHandlers "https://github.com/revit-mcp/revit-mcp-commandset/tree/main/revit-mcp-commandset/Services"
    click CommonModels "https://github.com/revit-mcp/revit-mcp-commandset/tree/main/revit-mcp-commandset/Models/Common"
    click AnnotationModels "https://github.com/revit-mcp/revit-mcp-commandset/tree/main/revit-mcp-commandset/Models/Annotation"
    click ArchitectureModels "https://github.com/revit-mcp/revit-mcp-commandset/tree/main/revit-mcp-commandset/Models/Architecture"
    click MEPModels "https://github.com/revit-mcp/revit-mcp-commandset/tree/main/revit-mcp-commandset/Models/MEP"
    click ViewsModels "https://github.com/revit-mcp/revit-mcp-commandset/tree/main/revit-mcp-commandset/Models/Views"
    click UtilsDir "https://github.com/revit-mcp/revit-mcp-commandset/tree/main/revit-mcp-commandset/Utils"

    %% Styles
    classDef external fill:#ffa500,stroke:#333,stroke-width:1px,color:#000;
    classDef entry fill:#007acc,stroke:#333,stroke-width:1px,color:#fff;
    classDef command fill:#1e90ff,stroke:#333,stroke-width:1px,color:#fff;
    classDef service fill:#32cd32,stroke:#333,stroke-width:1px,color:#fff;
    classDef model fill:#f9f871,stroke:#333,stroke-width:1px,color:#000;
    classDef util fill:#d3d3d3,stroke:#333,stroke-width:1px,color:#000;
    classDef infra fill:#888,stroke:#333,stroke-width:1px,color:#fff;
```
