MCP Server for CAD Drawing and Annotation
Create and annotate CAD drawings (lines, circles, text) using an MCP server compatible with mainstream CAD software.
npx -y @daobataotie/CAD-MCP#Overview
This MCP (Model Context Protocol) server provides a lightweight, developer-friendly API for programmatically creating and annotating CAD drawings. It exposes a set of MCP-compatible tools that let language models, automation scripts, or other clients emit CAD primitives (lines, circles, text) and annotations, then export or preview the result in formats supported by mainstream CAD applications (DXF/DWG/PNG). The server is intended to sit between an LLM-driven agent and CAD software, turning high-level intents into concrete drawing operations.
By using an MCP interface, the server is designed to integrate easily with model-driven pipelines: a model can call named tools with structured arguments, receive confirmation or diagnostics, and iterate. This makes it useful for tasks like converting natural-language specifications into sketch-level CAD, annotating existing drawings, running automated drawing checks, or generating labeled datasets for training. The project repository (source and examples) is available on GitHub: https://github.com/daobataotie/CAD-MCP#
Features
- Create basic CAD primitives: lines, circles, arcs, polylines, and text labels
- Layered drawing support for grouping and annotation separation
- Export to common formats (DXF for CAD import, PNG/SVG for previews)
- MCP-compatible JSON tool interface suitable for LLM integrations
- Simple REST API (HTTP/JSON) for tool invocation and status queries
- Command-line and Docker-ready deployment options
- Lightweight storage of sessions/projects for incremental editing
- Basic validation and error reporting for geometric inputs
Installation / Configuration
Clone the repository and run either with Docker (recommended for quick start) or locally in a Python environment.
Quick start with Docker:
# Build and run container
Local (Python) development:
# create venv and install
# run server
Configuration example (environment variables):
# host and port
MCP_HOST=0.0.0.0
MCP_PORT=8080
# where to persist projects and exports
MCP_STORAGE_PATH=/app/data
# toggle preview generation
MCP_ENABLE_PREVIEW=true
Available Tools
The server exposes a concise set of MCP-style tools. Each tool accepts a JSON argument object and returns a JSON result with success/failure and any metadata (IDs, bounding boxes, export paths).
| Tool name | Purpose | Key args |
|---|---|---|
| draw_line | Add a straight line between two points | start {x,y}, end {x,y}, layer |
| draw_circle | Add a circle by center and radius | center {x,y}, radius, layer |
| add_text | Add a text annotation | position {x,y}, text, size, layer |
| export_dxf | Export current project to DXF | project_id, filename |
| get_preview | Generate a PNG/SVG preview image | project_id, scale |
| list_layers | List layers and their properties | project_id |
| annotate | High-level annotation (measurement/label) | project_id, target_id, note |
Example tool invocation format (MCP-style):
Endpoint (example):
- POST /mcp/invoke — body is the tool invocation JSON shown above
- GET /mcp/project/{id}/export — download generated exports
Use Cases
Convert natural language sketch requests into CAD primitives
- A model can take “draw a 100 mm base line and a circle of radius 25 mm at x=50,y=0” and call draw_line and draw_circle with the parsed coordinates.
Automated annotation of existing drawings
- Upload a base drawing, then use annotate or add_text to add measurement notes, revision comments, or safety markers.
LLM-assisted QA and repair
- Ask a model to check for overlapping entities or missing annotations; have it call list_layers and custom validation tools, then patch geometry via draw_line/add_text.
Batch generation for dataset creation
- Script multiple tool calls to create families of parametrized drawings (e.g., variations of a part) and export DXF for downstream training or CAD import.
Concrete curl example — draw a line and request a preview: