# zh19980811/easy-mcp-autocad architecture

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

- Interactive diagram: https://gitdiagram.com/zh19980811/easy-mcp-autocad
- Repository: https://github.com/zh19980811/easy-mcp-autocad

## Overview

##### Project type and purpose
- This is an open-source “Model Context Protocol” (MCP) server for AutoCAD, written in Python.
- It lives as a standalone executable (server.py → PyInstaller → server.spec) that your LLM client (e.g., Claude Desktop) spawns and communicates with over standard I/O.
- Its purpose is to expose a set of CAD-focused “tool” APIs (draw_line, draw_circle, export_to_database, etc.) to a large language model, translate those calls into COM calls against a running AutoCAD instance, and optionally persist CAD elements in a local SQLite database.

##### File structure
- Top-level scripts:
- server.py: entry point that implements the MCP protocol and dispatches incoming requests.
- main.py: may hold CLI or bootstrap logic (if separate from server.py).
- autocad_manager.py: encapsulates all COM interactions with AutoCAD (drawing commands, layer management, scanning).
- db_manager.py: manages SQLite connections, schema, and CRUD operations for CAD element storage.
- requirements.txt & pyproject.toml: declare Python dependencies (e.g., pywin32, sqlite3, any JSON/RPC library).
- server.spec: PyInstaller specification for bundling into a standalone .exe.
- .python-version, .gitignore: environment and VCS hygiene.
- CAD-mpc简单实现.mp4: demo video (not part of runtime).

##### README for additional insights
- System requirements section tells you it runs only on Windows (due to COM).
- Usage section shows how a user configures Claude Desktop to launch “autocad_mcp_server.exe” and how the protocol is registered as an MCP server.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "External Systems"
        ClaudeDesktop["Claude Desktop\n(LLM Client)"]:::external
        AutoCADCOM["AutoCAD COM Application"]:::external
    end

    MCPServerProcess["MCP Server Process\n(server.py)"]:::internal
    subgraph "Server Internal Modules"
        direction TB
        ProtocolHandler["Protocol Handler\n(server.py)"]:::internal
        ToolController["Tool Controller\n(main.py / server.py)"]:::internal
    end

    subgraph "Adapters"
        direction TB
        AutoCADManager["AutoCADManager\n(autocad_manager.py)"]:::adapter
        DBManager["DBManager\n(db_manager.py)"]:::adapter
    end

    subgraph "Data Storage"
        SQLiteDB["SQLite Database\n(.db file)"]:::db
    end

    subgraph "Project Artifacts"
        PyInstallerSpec["PyInstaller Spec\n(server.spec)"]:::internal
        Requirements["Dependencies\n(requirements.txt,\npyproject.toml)"]:::internal
        README["Documentation\n(README.md)"]:::internal
        DemoVideo["Demo Video\n(CAD-mpc简单实现.mp4)"]:::internal
        EnvConfig["Env Config\n(.python-version,\n.gitignore)"]:::internal
    end

    ClaudeDesktop -->|"stdin/stdout JSON-RPC"| MCPServerProcess
    MCPServerProcess --> ProtocolHandler
    ProtocolHandler -->|"dispatch"| ToolController
    ToolController -->|"COM calls"| AutoCADManager
    AutoCADManager --> AutoCADCOM
    ToolController -->|"DB operations"| DBManager
    DBManager --> SQLiteDB
    ToolController -->|"generate JSON response"| ProtocolHandler
    ProtocolHandler -->|"stdout"| ClaudeDesktop

    click MCPServerProcess "https://github.com/zh19980811/easy-mcp-autocad/blob/main/server.py"
    click ProtocolHandler "https://github.com/zh19980811/easy-mcp-autocad/blob/main/server.py"
    click ToolController "https://github.com/zh19980811/easy-mcp-autocad/blob/main/main.py"
    click AutoCADManager "https://github.com/zh19980811/easy-mcp-autocad/blob/main/autocad_manager.py"
    click DBManager "https://github.com/zh19980811/easy-mcp-autocad/blob/main/db_manager.py"
    click PyInstallerSpec "https://github.com/zh19980811/easy-mcp-autocad/blob/main/server.spec"
    click Requirements "https://github.com/zh19980811/easy-mcp-autocad/blob/main/requirements.txt"
    click Requirements "https://github.com/zh19980811/easy-mcp-autocad/blob/main/pyproject.toml"
    click README "https://github.com/zh19980811/easy-mcp-autocad/blob/main/README.md"
    click DemoVideo "https://github.com/zh19980811/easy-mcp-autocad/blob/main/CAD-mpc简单实现.mp4"
    click EnvConfig "https://github.com/zh19980811/easy-mcp-autocad/blob/main/.python-version"
    click EnvConfig "https://github.com/zh19980811/easy-mcp-autocad/blob/main/.gitignore"

    classDef external fill:#f9f,stroke:#333
    classDef internal fill:#bbf,stroke:#333
    classDef adapter fill:#bfb,stroke:#333
    classDef db fill:#fbf,stroke:#333
```
