Install
$ agentstack add mcp-thepiruthvirajan-autocad-mcp-server β scanned Β· β verified β works with Claude Code, Cursor, and more.
Security review
β PassedNo issues found. Passed automated security review. Β· v0.1.0 How review works β
- β Prompt-injection patterns
- β Secret / credential exfiltration
- β Dangerous shell & filesystem operations
- β Untrusted network calls
- β Known-malicious package signatures
What it can access
- β Network access No
- β Filesystem access No
- β Shell / process execution No
- β Environment & secrets No
- β Dynamic code execution No
From automated source analysis of v0.1.0. βUsedβ means the capability is present in the source β more access means more to trust, not that itβs unsafe.
About
AutoCAD MCP Server - Complete Documentation
ποΈ A powerful Python-based Model Context Protocol (MCP) server that provides programmatic control over AutoCAD through COM automation.
Youtube video of the working demo https://www.youtube.com/watch?v=KQpxiXvF4cc
Transform your AutoCAD workflow with intelligent building structure creation, automatic layer management, and comprehensive entity manipulation - all through Claude and other MCP clients.
π Quick Start (30 seconds)
# 1. Clone and setup
git clone https://github.com/yourusername/autocad-mcp-server
cd autocad-mcp-server
pip install -e .
# 2. Start AutoCAD (must be running)
# Open AutoCAD application
# 3. Test the server
python test_script.py
π Table of Contents
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Configuration with Claude Desktop](#configuration-with-claude-desktop)
- [Running the Server](#running-the-server)
- [Basic Usage Examples](#basic-usage-examples)
- [Advanced Features](#advanced-features)
- [API Reference](#api-reference)
- [Troubleshooting](#troubleshooting)
- [Development](#development)
Prerequisites
System Requirements
- Operating System: Windows (COM automation requirement)
- AutoCAD: Any version 2000+ with COM support
- Python: 3.8 or higher
- Claude Desktop: Latest version (for MCP integration)
Required Software
- AutoCAD Installation
- Any AutoCAD version (AutoCAD, AutoCAD LT, Civil 3D, etc.)
- Must have valid license and be able to run
- COM automation must be enabled (default in most installations)
- Python Environment
- Python 3.8+ installed
- Administrative privileges may be required for COM registration
Installation
Method 1: Using pip (Recommended)
# Clone the repository
git clone https://github.com/yourusername/autocad-mcp-server
cd autocad-mcp-server
# Create virtual environment
python -m venv venv
# Activate environment (Windows)
venv\Scripts\activate
# Install the package
pip install -e .
Method 2: Using uv (Faster)
# Install uv if not already installed
pip install uv
# Clone and setup
git clone https://github.com/yourusername/autocad-mcp-server
cd autocad-mcp-server
# Create environment and install
uv venv
uv pip install -e .
Dependencies Installed
mcp>=1.0.0- Model Context Protocol frameworkpywin32>=306- Windows COM automation
Configuration with Claude Desktop
Step 1: Locate Claude Desktop Config
Find your Claude Desktop configuration file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Step 2: Add MCP Server Configuration
Edit the config file to include your AutoCAD MCP server:
{
"mcpServers": {
"autocad-mcp": {
"command": "python",
"args": [
"C:\\path\\to\\your\\autocad-mcp-server\\test_script.py"
],
"env": {
"PYTHONPATH": "C:\\path\\to\\your\\autocad-mcp-server"
}
}
}
}
Important: Replace C:\\path\\to\\your\\autocad-mcp-server with your actual project path.
Step 3: Alternative Configuration (If Installed via pip)
If you installed the package globally:
{
"mcpServers": {
"autocad-mcp": {
"command": "autocad-mcp",
"args": []
}
}
}
Step 4: Restart Claude Desktop
- Close Claude Desktop completely
- Restart the application
- Verify the MCP server appears in available tools
Running the Server
Method 1: Standalone Testing
# Activate your environment
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
# Start AutoCAD first (important!)
# Open AutoCAD application
# Run the test script
python test_script.py
Expected Output:
β
Successfully connected to AutoCAD
π Drawing: Drawing1.dwg
π Entities: 0
π MCP Server starting...
Server running and waiting for client connections...
Method 2: Through Claude Desktop
- Start AutoCAD (must be running before Claude connects)
- Open Claude Desktop
- Start new conversation
- Verify MCP connection - You should see "autocad-mcp" in available tools
- Test with a simple command:
Hi! Can you check what AutoCAD drawing is currently open?
Method 3: Direct MCP Client
For advanced users or custom integrations:
import asyncio
from autocad_mcp import AutoCADCOMServer
async def run_server():
server = AutoCADCOMServer()
await server.main()
asyncio.run(run_server())
Basic Usage Examples
Through Claude Desktop
Once configured, you can use natural language with Claude to control AutoCAD:
Example 1: Check Drawing Status
Claude: Can you tell me about the current AutoCAD drawing?
Claude will use the MCP server to get drawing information and respond with details about the current drawing, layers, and entity count.
Example 2: Create a Simple Room
Claude: Create a 12x10 foot room with walls that are 6 inches thick. Add a door on the south wall and a window on the east wall.
Claude will:
- Create a room structure using
create_structure - Add walls with proper thickness
- Place door and window openings
- Use appropriate layers (WALLS, DOORS, WINDOWS)
- Label the elements
Example 3: Layer Management
Claude: Show me all the layers in the current drawing and create a new layer called "HVAC" with red color.
Example 4: Entity Querying
Claude: List all the entities in the drawing grouped by layer. How many walls do we have?
Direct API Usage (Advanced)
If you're building custom applications:
from autocad_mcp import AutoCADCOMServer
# Initialize server
server = AutoCADCOMServer()
# Connect to AutoCAD
if server.connect_to_autocad():
# Create a wall
result = server.create_structure(
structure_type="wall",
geometry_data={
"start": [0, 0],
"end": [20, 0]
},
thickness=0.5,
label="North Wall"
)
# Create a door
door_result = server.create_structure(
structure_type="door",
geometry_data={
"start": [8, 0],
"end": [11, 0],
"width": 3
},
label="Main Entrance"
)
# Get all entities
entities = server.get_entities()
print(f"Total entities: {entities['total_count']}")
Advanced Features
Intelligent Layer Management
The server automatically assigns structures to appropriate layers:
# Automatically goes to WALLS layer
create_structure("wall", geometry_data)
# Automatically goes to ELECTRICAL layer
create_structure("outlet", geometry_data)
# Custom layer assignment
create_structure("furniture", geometry_data, custom_layer="BEDROOM_FURNITURE")
Thickness and Styling
# Wall with thickness (creates parallel lines with end caps)
create_structure("wall", {
"start": [0, 0],
"end": [20, 0]
}, thickness=0.5, color="white")
# Circle with thickness (creates concentric circles)
create_circle([10, 10], 5, color="red", thickness=0.2)
Batch Operations
# Get all entities
entities = get_entities()
# Delete by criteria
delete_entities_by_layer("TEMP_LAYER")
delete_entities_by_color("red")
delete_entities_by_type("AcDbText")
# Modify existing entities
for entity in entities['entities']:
if entity['type'] == 'AcDbLine':
change_entity_color(entity['handle'], 'blue')
Structure Labeling
# Create room with automatic labeling
create_structure("room", {
"corner1": [0, 0],
"corner2": [12, 8]
}, label="Living Room", thickness=0.25)
# Labels automatically go to ANNOTATION layer
API Reference
Core Information Tools
get_drawing_info()
Purpose: Get comprehensive drawing information Returns: Drawing metadata, layer info, entity counts
{
"filename": "floor_plan.dwg",
"path": "C:\\Projects\\floor_plan.dwg",
"entity_count": 150,
"saved": true,
"current_layer": "WALLS",
"total_layers": 8,
"available_layers": [...]
}
get_entities(max_entities?)
Purpose: Retrieve all entities with layer grouping Parameters:
max_entities(optional): Limit number of entities returned
Returns: Complete entity list with metadata
{
"entities": [...],
"entities_by_layer": {
"WALLS": [25 entities],
"DOORS": [8 entities]
},
"total_count": 150,
"layer_summary": {"WALLS": 25, "DOORS": 8}
}
Structure Creation
create_structure(type, geometry, options)
Purpose: Create intelligent building structures Parameters:
structure_type: "wall", "door", "window", "room", "furniture", etc.geometry_data: Geometry definitioncolor(optional): Override default layer colorthickness(optional): Structure thicknesscustom_layer(optional): Custom layer namelabel(optional): Text label
Examples:
# Wall
create_structure("wall", {
"start": [0, 0], "end": [20, 0]
}, thickness=0.25, label="Exterior Wall")
# Room
create_structure("room", {
"corner1": [0, 0], "corner2": [12, 10]
}, label="Master Bedroom")
# Door with swing
create_structure("door", {
"start": [8, 0], "end": [11, 0], "width": 3
}, label="Front Door")
Basic Entity Creation
create_line(start, end, color?, thickness?)
create_line([0, 0], [10, 0], "red", 0.1)
create_circle(center, radius, color?, thickness?)
create_circle([5, 5], 3, "blue", 0.05)
create_rectangle(corner1, corner2, color?, thickness?)
create_rectangle([0, 0], [10, 8], "green", 0.0)
create_text(position, text, height?, color?)
create_text([5, 5], "Room Label", 0.5, "black")
create_arc(center, radius, start_angle, end_angle, color?, thickness?)
create_arc([0, 0], 5, 0, 90, "cyan", 0.0)
Layer Management
create_or_get_layer(name, color?, description?)
create_or_get_layer("CUSTOM_LAYER", "yellow", "Custom elements")
set_current_layer(name)
set_current_layer("WALLS")
Entity Deletion
delete_entity_by_handle(handle)
delete_entity_by_handle("ABC123")
delete_entities_by_layer(layer_name)
delete_entities_by_layer("TEMP_LAYER")
delete_entities_by_type(entity_type)
delete_entities_by_type("AcDbText") # Delete all text
delete_entities_by_color(color)
delete_entities_by_color("red")
delete_last_entities(count?)
delete_last_entities(5) # Delete last 5 entities
Utility Tools
undo_last_operation()
undo_last_operation() # Ctrl+Z equivalent
change_entity_color(handle, color)
change_entity_color("ABC123", "blue")
zoom_extents()
zoom_extents() # Zoom to show all objects
Predefined Layer System
| Layer Name | Color | Purpose | |------------|-------|---------| | WALLS | White | Building walls and partitions | | DOORS | Green | Door openings and frames | | WINDOWS | Cyan | Window openings and frames | | FURNITURE | Yellow | Furniture and fixtures | | ELECTRICAL | Red | Electrical fixtures and outlets | | PLUMBING | Blue | Plumbing fixtures and pipes | | HVAC | Magenta | HVAC ducts and equipment | | STRUCTURE | Gray | Structural elements | | ANNOTATION | White | Text and dimensions | | SITE | Green | Site elements and landscaping | | UTILITIES | Red | Utility lines and equipment |
Automatic Layer Assignment
The system intelligently assigns layers based on keywords:
structure_mapping = {
"wall", "partition" β "WALLS",
"door", "opening" β "DOORS",
"window" β "WINDOWS",
"furniture", "chair", "table", "bed" β "FURNITURE",
"outlet", "switch", "light" β "ELECTRICAL",
"toilet", "sink", "pipe" β "PLUMBING",
"vent", "duct", "hvac" β "HVAC",
"beam", "column" β "STRUCTURE",
"text", "dimension" β "ANNOTATION"
}
Real-World Examples
Example 1: Complete Floor Plan with Claude
User to Claude:
Create a simple apartment floor plan:
- 20x15 foot room with 6-inch walls
- Front door (3 feet wide) on the south wall, centered
- Two windows (4 feet each) on the east and west walls
- Kitchen area in the northwest corner (8x6 feet)
- Add labels for each area
Claude's Response Process:
- Uses
create_structure("room", ...)for main room - Uses
create_structure("door", ...)for entrance - Uses
create_structure("window", ...)for windows - Uses
create_structure("room", ...)for kitchen - Uses
create_text(...)for labels - Uses
zoom_extents()to show complete drawing
Example 2: Layer Management Workflow
User to Claude:
I need to organize my drawing. Can you:
1. Show me all current layers and their entity counts
2. Move all red entities to a new "HIGHLIGHTED" layer
3. Delete everything on the "TEMP" layer
4. Change all text to be green colored
Claude's Process:
get_entities()to analyze current statecreate_or_get_layer("HIGHLIGHTED", "red")- Filter entities by color, move to new layer
delete_entities_by_layer("TEMP")change_entity_color()for all text entities
Example 3: Electrical Layout
User to Claude:
Add electrical outlets and switches to this room:
- Outlets every 8 feet along the walls
- Light switches by each door
- Ceiling light in the center
- Put everything on the electrical layer with proper labels
Claude's Process:
get_entities()to find existing walls and doors- Calculate outlet positions along walls
create_structure("outlet", ...)for each outletcreate_structure("switch", ...)by doorscreate_structure("light", ...)at room center- All automatically go to ELECTRICAL layer
Troubleshooting
Common Issues and Solutions
β "Not connected to AutoCAD"
Symptoms:
- Error messages about AutoCAD connection
- Server fails to start
Solutions:
- Start AutoCAD First
``bash # Always start AutoCAD before the MCP server # Open AutoCAD application manually ``
- Check AutoCAD Installation
``bash # Verify AutoCAD is installed and licensed # Try opening AutoCAD manually ``
- Administrative Privileges
``bash # Run command prompt as Administrator # Try running the server with elevated privileges ``
- COM Registration Issues
``bash # Re-register AutoCAD COM components # Run as Administrator: regsvr32 "C:\Program Files\Autodesk\AutoCAD 202X\acad.exe" /regserver ``
β Claude Desktop Not Connecting
Symptoms:
- MCP server not appearing in Claude
- Tools not available
Solutions:
- Check Configuration Path
``json // Verify paths in claude_desktop_config.json are correct { "mcpServers": { "autocad-mcp": { "command": "python", "args": ["C:\\CORRECT\\PATH\\test_script.py"] } } } ``
- Restart Claude Desktop
- Close Claude completely (check system tray)
- Restart the application
- Wait for full initialization
- Check Python Environment
``bash # Verify Python and dependencies are accessible python -c "import mcp; print('MCP available')" python -c "import win32com.client; print('COM available')" ``
- Test Server Standalone
``bash # Test the server works independently python test_script.py ``
β COM Timeout Errors
Symptoms:
- Operations taking too long
- "COM operation timed out" errors
Solutions:
- Close Unnecessary AutoCAD Drawings
- Keep only one drawing open
- Close large/complex drawings
- Increase Delay Parameters
```python # In server.py, increase delay in safeoperation def safeoperation(self, operation_fun
β¦
Source & license
This open-source MCP server is cataloged on AgentStack and links to its original source β we do not rehost the code.
- Author: thepiruthvirajan
- Source: thepiruthvirajan/autocad-mcp-server
- License: Apache-2.0
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet β be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.