ai-cad
Provides DXF parsing, entity extraction, geometry analysis, and optional AutoCAD COM automation for CAD tasks.
README
AI-CAD
AI-CAD is a cleaned-up rebuild of an earlier CAD automation prototype. The first stable core focuses on offline DXF parsing, entity extraction, geometry normalization, and stone blank size analysis.
What Is Included
- DXF parsing with
ezdxf - Unified entity dictionaries for lines, arcs, circles, polylines, text, and inserts
- Layer/type filtering and drawing summaries
- Minimum oriented bounding rectangle analysis
- Multi-part stone grouping by endpoint connectivity
- JSON, CSV, and optional Excel export
- Automation-loop contracts for future computer-use and AutoLISP adapters
- AutoCAD current-viewport assistant contracts for MCP/AutoLISP integration
- A small CLI and focused pytest coverage
- An MCP server (
aicad.mcp_server, built on FastMCP) exposing the DXF tools and, on Windows, timeout- andIsQuiescent-guarded AutoCAD COM tools plus a registry-driven catalog for driving external AutoLISP scripts
Heavy visual rendering and experimental tooling are intentionally left outside this rebuilt core. AutoCAD COM execution is now available as an optional, adapter-style layer through the MCP server (Windows + pywin32), kept behind automation contracts so the geometry/DXF core stays backend-independent. The current-viewport assistant direction is documented in docs/VIEWPORT_ASSISTANT.md, the general edit/validation loop in docs/AUTOMATION_LOOP.md, and migration notes in docs/MIGRATION.md.
Install
python -m pip install -e .
For Excel export:
python -m pip install -e ".[excel]"
For development:
python -m pip install -e ".[dev,excel]"
CLI
aicad summary path/to/file.dxf
aicad extract path/to/file.dxf --layer "stone-*"
aicad blank path/to/file.dxf --margin 2
aicad export path/to/file.dxf --format json --output output/entities.json
You can also run the package module directly:
python -m aicad summary path/to/file.dxf
Python API
from aicad import calculate_blank_size, extract_entities
entities = extract_entities("drawing.dxf", layer_filter="stone-*")
blank = calculate_blank_size("drawing.dxf", margin=2.0)
Every public API function returns a response dictionary:
{
"success": True,
"data": ...,
"error": None,
"metadata": {...},
}
MCP Server
aicad ships an MCP server (FastMCP) so agents can call the toolkit directly.
Install the extra and run it:
python -m pip install -e ".[mcp]"
python -m aicad.mcp_server
Register it with an MCP client (e.g. a project .mcp.json):
{
"mcpServers": {
"ai-cad": { "command": "python", "args": ["-m", "aicad.mcp_server"] }
}
}
Tools:
- DXF (cross-platform):
aicad_extract_entities,aicad_blank_size,aicad_validate_dxf,aicad_build_viewport_probe,aicad_ping - AutoCAD COM (Windows, optional):
autocad_get_active_document,autocad_run_lisp,autocad_send_command,autocad_probe_viewport,autocad_diagnose_access— every COM call runs on a worker thread with a timeout and anIsQuiescentguard, so a busy AutoCAD returns a clean error instead of hanging the server. - Script catalog:
aicad_list_scripts,aicad_describe_script,autocad_run_script— a registry-driven layer for discovering and running your own AutoLISP commands through thin headless wrappers. The registry is read at call time, so adding a script needs no server restart.
Windows integrity note: the COM tools require AutoCAD and the MCP process to run at the same integrity level (both normal, or both "as administrator"). A mismatch (e.g. AutoCAD elevated, MCP not) blocks COM/ROT access and surfaces as an "invalid class string" error —
autocad_diagnose_accessreports this directly.
Repository Layout
src/aicad/ Core Python package
tests/ Reproducible tests and generated fixtures
docs/ Migration notes and project context
.codex/ Agent-facing context notes
Automation Direction
The intended editing loop has two modes:
- visible computer-use validation for screenshots, UI inspection, and interactive diagnosis
- quiet AutoLISP/headless automation for deterministic background edits and validation
Both modes should report through aicad.automation contracts so the geometry and DXF core stays independent from the CAD execution backend.
The next practical focus is the AutoCAD current-viewport assistant: Codex acts as the reasoning brain, while an MCP/AutoLISP backend reads the active view, selected entities, or a requested world-coordinate window and returns formatted JSON.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.