Content
# AutoCAD MCP Server
[](LICENSE)
[](https://www.python.org/downloads/)
[](https://modelcontextprotocol.io)
**Control AutoCAD directly from AI agents — draw, annotate, modify, and export through natural language.**
---
## 📋 Overview
AutoCAD MCP Server is an [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that encapsulates the drawing capabilities of AutoCAD 2020+ into 47 standardized tools. Any AI agent that supports the MCP protocol (such as Reasonix, Claude Desktop, Cursor, VS Code Cline, etc.) can directly control AutoCAD through natural language.
**Supported AutoCAD versions:** 2020+ (Windows only)
**Technical principle:** Using `pywin32` to call the AutoCAD COM API.
---
## 🚀 Quick Start
### Installation
```bash
# Clone
git clone https://github.com/your-username/autocad-mcp-server.git
cd autocad-mcp-server
# Install dependencies
pip install -r requirements.txt
# Install the package
pip install -e .
```
### Test
```bash
# Verify import
python3 -c "from autocad_mcp_server.server import server; print('OK:', len(server._tool_manager._tools), 'tools')"
# Output: OK: 47 tools
```
---
## ⚙️ Configuration
### Reasonix
Add the following to `~/.mcp.json` or `.mcp.json` in the project root directory:
```json
{
"mcpServers": {
"autocad": {
"command": "python3",
"args": [
"-u",
"-m",
"autocad_mcp_server.server"
],
"description": "Control AutoCAD 2020+ via AI agents"
}
}
}
```
### Claude Desktop
Edit `%APPDATA%\Claude\claude_desktop_config.json`:
```json
{
"mcpServers": {
"autocad": {
"command": "python3",
"args": [
"-u",
"-m",
"autocad_mcp_server.server"
],
"description": "AutoCAD drawing control"
}
}
}
```
### Cursor
Create `.cursor/mcp.json` in the project root directory:
```json
{
"mcpServers": {
"autocad": {
"command": "python3",
"args": [
"-u",
"-m",
"autocad_mcp_server.server"
]
}
}
}
```
### VS Code (Cline)
Edit `%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json`:
```json
{
"mcpServers": {
"autocad": {
"command": "python3",
"args": [
"-u",
"-m",
"autocad_mcp_server.server"
],
"disabled": false,
"autoApprove": []
}
}
}
```
---
## 🛠️ Tool List
### Drawing (8 tools)
| Tool Name | Function |
|--------|------|
| `autocad_draw_line` | Draw a line |
| `autocad_draw_circle` | Draw a circle |
| `autocad_draw_arc` | Draw an arc |
| `autocad_draw_polyline` | Draw a polyline |
| `autocad_draw_rectangle` | Draw a rectangle |
| `autocad_draw_polygon` | Draw a polygon |
| `autocad_draw_ellipse` | Draw an ellipse |
| `autocad_draw_spline` | Draw a spline |
### Layers (4 tools)
| Tool Name | Function |
|--------|------|
| `autocad_create_layer` | Create/get a layer |
| `autocad_set_current_layer` | Set the current layer |
| `autocad_layer_control` | Control layer status (on/off/freeze/lock/print) |
| `autocad_list_layers` | List all layers |
### Annotation (9 tools)
| Tool Name | Function |
|--------|------|
| `autocad_add_text` | Add single-line text |
| `autocad_add_mtext` | Add multi-line text |
| `autocad_add_dim_linear` | Linear dimension annotation |
| `autocad_add_dim_aligned` | Aligned dimension annotation |
| `autocad_add_dim_diameter` | Diameter annotation |
| `autocad_add_dim_radius` | Radius annotation |
| `autocad_add_leader` | Leader annotation |
### Document (7 tools)
| Tool Name | Function |
|--------|------|
| `autocad_new_drawing` | Create a new drawing |
| `autocad_open_drawing` | Open a DWG file |
| `autocad_save_drawing` | Save the drawing |
| `autocad_close_drawing` | Close the drawing |
| `autocad_export_to_pdf` | Export to PDF |
| `autocad_export_to_dxf` | Export to DXF |
| `autocad_plot_to_pdf` | Print output PDF |
### Modify (10 tools)
| Tool Name | Function |
|--------|------|
| `autocad_move` | Move an entity |
| `autocad_copy` | Copy an entity |
| `autocad_rotate` | Rotate an entity |
| `autocad_scale` | Scale an entity |
| `autocad_mirror` | Mirror an entity |
| `autocad_offset` | Offset copy |
| `autocad_erase` | Delete an entity |
| `autocad_zoom_extents` | Zoom to extents |
| `autocad_zoom_window` | Window zoom |
| `autocad_get_entity_count` | Get entity count |
### Blocks (4 tools)
| Tool Name | Function |
|--------|------|
| `autocad_create_block` | Create a block definition |
| `autocad_insert_block` | Insert a block |
| `autocad_explode_block` | Explode a block |
| `autocad_list_blocks` | List block definitions |
### Query (6 tools)
| Tool Name | Function |
|--------|------|
| `autocad_get_distance` | Calculate distance between two points |
| `autocad_get_area` | Calculate polygon area |
| `autocad_get_entity_info` | Query entity information |
| `autocad_list_entities` | List entities in the current drawing |
| `autocad_undo` | Undo |
| `autocad_redo` | Redo |
---
## 📝 Usage Examples
### Basic Drawing
> _"Draw a line from (0,0) to (100,50) in AutoCAD, layer set to '墙体'"_
>
> AI call: `autocad_draw_line(0, 0, 100, 50, "墙体")`
### Complex Workflow
> _"Create a new drawing → create layer '墙体' (red) and '标注' (blue) → switch to 墙体 layer → draw a 10m×3m wall (rectangle) → switch to 标注 layer → annotate dimensions → export to PDF"_
### Batch Operations
> _"Select all entities on '门窗' layer → move to (200, 0) → zoom to extents"_
---
## 📂 Project Structure
```
src/autocad_mcp_server/
├── __init__.py # Package entry
├── server.py # MCP Server main entry (47 tools registered)
├── cad_connection.py # AutoCAD COM connection management
├── tools_drawing.py # Drawing tools
├── tools_layer.py # Layer management
├── tools_annotation.py # Annotation tools
├── tools_document.py # Document operations
├── tools_modify.py # Modify tools
├── tools_block.py # Block operations
└── tools_query.py # Query tools
```
---
## ⚠️ Requirements
| Item | Requirement |
|------|------|
| OS | Windows 10/11 (Windows only, due to AutoCAD COM API) |
| Python | 3.10+ |
| AutoCAD | 2020+ (any version, as long as COM interface is available) |
| Dependencies | `mcp>=1.0.0`, `pywin32>=311` |
---
## 📄 License
This project is licensed under the [GNU General Public License v3.0](LICENSE).
---
## 🤝 Contributing
Welcome to submit issues and pull requests!
- Fork this repository
- Create a feature branch (`git checkout -b feature/my-feature`)
- Commit changes (`git commit -am 'Add my feature'`)
- Push to the branch (`git push origin feature/my-feature`)
- Create a pull request