Labsco
ranvirw18 logo

Mowgli

from ranvirw18

Intelligent product canvas with context and taste โ€” connect your coding agent to iterate on your product's design, from sweeping new flows down to surgical tweaks, and sync it back to your code.

๐Ÿ”ฅ๐Ÿ”ฅFreeQuick setup

AutoCAD MCP Server

A production-grade Model Context Protocol (MCP) server for AutoCAD on Windows, enabling AI assistants (Claude Desktop, ChatGPT, Cursor, etc.) to control AutoCAD through natural language.

Features

  • 10 Comprehensive MCP Tools for CAD operations
  • AutoCAD COM API Integration for native Windows automation
  • Natural Language Control - "Draw a 100x50 rectangle" โ†’ creates geometry
  • Automatic Connection Management with reconnection logic
  • Full Type Hints & Pydantic Validation for safety
  • Production Logging for debugging and monitoring
  • Unit Tests covering all tools and edge cases
  • Fast & Lightweight using FastMCP framework

Tech Stack

Available Tools

Drawing Tools

  1. create_line - Draw a line between two points

    • Parameters: x1, y1, x2, y2
    • Returns: Object ID of created line
  2. create_circle - Draw a circle

    • Parameters: center_x, center_y, radius
    • Returns: Object ID of created circle
  3. create_rectangle - Draw a rectangle

    • Parameters: x, y, width, height
    • Returns: List of object IDs (polyline + entities)
  4. create_text - Add text annotation

    • Parameters: text, x, y, height
    • Returns: Object ID of created text

Layer Management

  1. create_layer - Create a new layer

    • Parameters: layer_name
    • Returns: Layer name (or error if exists)
  2. list_layers - List all layers in document

    • No parameters
    • Returns: List of layer names

Analysis & Measurement

  1. calculate_area - Calculate area of closed shape
    • Parameters: object_id
    • Returns: Calculated area value

Document Operations

  1. save_drawing - Save active drawing

    • Parameters: file_path (optional, defaults to current)
    • Returns: Success message with file path
  2. export_pdf - Export drawing to PDF

    • Parameters: output_path
    • Returns: Success message with PDF path
  3. get_active_document - Get active document info

    • No parameters
    • Returns: Document name and full path

Example Prompts

Once connected, use natural language to control AutoCAD:

Basic Drawing

  • "Draw a line from (0, 0) to (100, 50)" โ†’ Calls create_line with coordinates

  • "Create a circle at center (50, 50) with radius 25" โ†’ Calls create_circle

  • "Draw a 100x50 rectangle at origin" โ†’ Calls create_rectangle

Text & Annotation

  • "Add text 'WALL-A' at coordinates (10, 20) with height 5" โ†’ Calls create_text

Layer Management

  • "Create a new layer called 'Fixtures'" โ†’ Calls create_layer

  • "Show me all layers in the drawing" โ†’ Calls list_layers

Analysis

  • "Calculate the area of object with ID 'ABC123'" โ†’ Calls calculate_area

Document Management

  • "Save the drawing" โ†’ Calls save_drawing

  • "Export the drawing to PDF at C:\output\plan.pdf" โ†’ Calls export_pdf

  • "What's the active document name?" โ†’ Calls get_active_document

Testing

Run the unit test suite:

Copy & paste โ€” that's it
# Run all tests
pytest

# Run with coverage
pytest --cov=src

# Run specific test file
pytest tests/test_models.py

# Run with verbose output
pytest -v

Test coverage includes:

  • โœ… Pydantic model validation
  • โœ… Tool parameter validation
  • โœ… AutoCAD connection logic
  • โœ… API endpoint functionality
  • โœ… Error handling and edge cases

Project Structure

Copy & paste โ€” that's it
autocad-mcp-server/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ server.py                 # MCP server entrypoint
โ”‚   โ”œโ”€โ”€ autocad_client.py         # AutoCAD COM wrapper
โ”‚   โ”œโ”€โ”€ models.py                 # Pydantic validation models
โ”‚   โ””โ”€โ”€ tools/
โ”‚       โ”œโ”€โ”€ __init__.py           # Tool registry
โ”‚       โ”œโ”€โ”€ drawing.py            # Line, circle, rectangle, text
โ”‚       โ”œโ”€โ”€ layers.py             # Layer management
โ”‚       โ”œโ”€โ”€ dimensions.py         # Area calculation
โ”‚       โ””โ”€โ”€ export.py             # Save and PDF export
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_models.py            # Model validation tests
โ”‚   โ”œโ”€โ”€ test_server.py            # API endpoint tests
โ”‚   โ””โ”€โ”€ test_tools.py             # Tool handler tests
โ”œโ”€โ”€ pyproject.toml                # uv/pip dependencies
โ”œโ”€โ”€ .env.example                  # Environment template
โ””โ”€โ”€ README.md                      # This file

Architecture

AutoCAD Connection

Copy & paste โ€” that's it
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     Claude Desktop / ChatGPT / etc      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ”‚ (MCP Protocol)
                   โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     MCP Server (FastMCP)                โ”‚
โ”‚  โ”œโ”€ Tool Registry                       โ”‚
โ”‚  โ”œโ”€ Request Dispatcher                  โ”‚
โ”‚  โ””โ”€ Pydantic Validators                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ”‚ (Python API)
                   โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     AutoCAD Client (pyautocad)          โ”‚
โ”‚  โ”œโ”€ Connection Manager                  โ”‚
โ”‚  โ”œโ”€ Retry Logic                         โ”‚
โ”‚  โ””โ”€ Error Handler                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ”‚ (COM Automation)
                   โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     AutoCAD Application (COM)           โ”‚
โ”‚  โ”œโ”€ Drawing API                         โ”‚
โ”‚  โ”œโ”€ Layer Management                    โ”‚
โ”‚  โ””โ”€ Document Operations                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Performance Notes

  • Fast - Direct COM calls, no network overhead
  • Lightweight - Minimal dependencies
  • Reliable - Auto-reconnection on AutoCAD restart
  • Safe - Full input validation with Pydantic
  • Concurrent - Handles multiple AI assistant requests

Security Considerations

  • โœ… Runs locally on Windows (no cloud exposure)
  • โœ… Input validation on all tool parameters
  • โœ… Type-safe with Pydantic models
  • โœ… Error handling prevents information leakage
  • โš ๏ธ AutoCAD file access - ensure proper file permissions
  • โš ๏ธ When exposing via network, use authentication/TLS

Contributing

Pull requests welcome! Areas for enhancement:

  • Additional drawing primitives (arc, polyline, spline)
  • Block/component support
  • Dimension annotations
  • Hatch patterns
  • Custom properties
  • Multi-document support
  • macOS/Linux via parallel AutoCAD alternatives

License

MIT - See LICENSE file

Support

Changelog

v1.0.0 (2026-06-05)

  • Initial release
  • 10 core CAD tools
  • Claude Desktop integration
  • Full test coverage
  • Production-ready code

Roadmap

  • AutoCAD Web API support for cloud deployments
  • Real-time drawing updates with WebSocket
  • Advanced geometry operations (offset, trim, extend)
  • Material/property management
  • CAM integration
  • Version control for drawing changes

Made with โค๏ธ for AI-powered CAD automation