MC

MCP Server for CAD Drawing and Annotation

Create and annotate CAD drawings (lines, circles, text) using an MCP server compatible with mainstream CAD software.

Quick Install
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:

git clone https://github.com/daobataotie/CAD-MCP.git
cd CAD-MCP

# Build and run container
docker build -t cad-mcp .
docker run -p 8080:8080 -v $(pwd)/data:/app/data cad-mcp

Local (Python) development:

git clone https://github.com/daobataotie/CAD-MCP.git
cd CAD-MCP

# create venv and install
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# run server
export MCP_HOST=0.0.0.0
export MCP_PORT=8080
python run_server.py

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 namePurposeKey args
draw_lineAdd a straight line between two pointsstart {x,y}, end {x,y}, layer
draw_circleAdd a circle by center and radiuscenter {x,y}, radius, layer
add_textAdd a text annotationposition {x,y}, text, size, layer
export_dxfExport current project to DXFproject_id, filename
get_previewGenerate a PNG/SVG preview imageproject_id, scale
list_layersList layers and their propertiesproject_id
annotateHigh-level annotation (measurement/label)project_id, target_id, note

Example tool invocation format (MCP-style):

{
  "tool": "draw_line",
  "arguments": {
    "project_id": "proj-123",
    "start": {"x": 0, "y": 0},
    "end": {"x": 100, "y": 0},
    "layer": "structural"
  }
}

Endpoint (example):

  • POST /mcp/invoke — body is the tool invocation JSON shown above
  • GET /mcp/project/{id}/export — download generated exports

Use Cases

  1. 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.
  2. Automated annotation of existing drawings

    • Upload a base drawing, then use annotate or add_text to add measurement notes, revision comments, or safety markers.
  3. 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.
  4. 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:

curl -X POST http://localhost:8080/mcp/invoke \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "draw_line",
    "arguments": {
      "project_id": "proj-demo",
      "start": {"x": 0, "y": 0},
      "end": {"x": 200, "y": 0},
      "layer": "base"
    }
  }'

curl http://localhost:8080/mcp/invoke -H "Content-Type: application/json" -d '{
  "tool": "get_preview",
  "arguments":