ai-cad

ai-cad

Provides DXF parsing, entity extraction, geometry analysis, and optional AutoCAD COM automation for CAD tasks.

Category
访问服务器

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- and IsQuiescent-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 an IsQuiescent guard, 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_access reports 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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选