The mlightcad team has released @mlightcad/cad-mcp-server, a Model Context Protocol implementation that fundamentally shifts how AI agents interact with CAD drawings. Instead of exposing hundreds of granular operations like draw_line or query_entities as individual tools, the server provides a sandboxed JavaScript execution environment. This allows AI agents to write custom scripts that combine existing capabilities to solve complex, unforeseen drawing tasks without requiring new tool definitions for every possible workflow.
The Tool-Sprawl Problem in CAD Automation
Traditional MCP servers for complex software often suffer from tool sprawl, where developers must anticipate every user request and create a specific tool for it. The mlightcad authors argue that CAD is not a collection of predictable operations but a programming environment. By forcing AI to use a 'shopping list' of tools, developers create a bottleneck where every new queryβsuch as grouping circles by layer and flagging unusual onesβrequires a new API design. This approach bloats the context window and limits the agent's flexibility to handle edge cases.
Architecture: One Core, Multiple Frontends
The system relies on a shared agent core, @mlightcad/cad-agent-core, which provides both a scripting environment and a minimal tool interface. The MCP server exposes only two tools: open_drawing for lifecycle management and execute_cad_script for all operational logic. The script receives a cad object that allows inspection of entities, measurement of geometry, and editing via transactions. Crucially, these scripts run in a sandboxed validator that restricts module imports and browser access, ensuring security while granting the AI full programmatic control over the drawing document.
Real-World Tests: BOMs, Title Blocks, and Sheet Splitting
The team validated this approach with three distinct tasks: extracting a Bill of Materials from line-drawn tables, parsing title block metadata, and splitting multi-sheet drawings into separate DXF files. In the BOM extraction test, the AI wrote a script to group text entities by Y-coordinate and sort them by X-coordinate, successfully reconstructing a Markdown table from raw geometry. For the title block, the agent located the largest closed polyline to define the frame boundary and extracted attributed text. The sheet-splitting test demonstrated editing capabilities, where the agent used transactions to erase entities outside a specific frame and export the remainder, all without a dedicated 'split_sheet' tool.
Why Scripting Beats Tool Calls for Data-Heavy Tasks
Beyond flexibility, this architecture offers significant performance and verification advantages. When dealing with drawings containing 100,000+ entities, sending data back and forth via tool calls consumes massive token counts. With scripting, filtering and processing happen locally within the CAD environment, and only the relevant summary or result is returned to the model. Furthermore, scripts can self-verify; the AI can write code that measures the result of its own edits and checks if conditions are met, creating a more trustworthy workflow than blind tool execution.
The Bottom Line
If you are building MCP servers for complex domain-specific software, stop trying to enumerate every possible action. Give the AI a workbench and a language, and let it build the tools it needs on the fly.
Key Takeaways
- mlightcad's new MCP server uses a sandboxed JavaScript execution environment instead of granular CAD tools.
- The architecture exposes only two tools:
open_drawingandexecute_cad_script, reducing context bloat. - Real-world tests proved AI can extract BOMs, parse title blocks, and split sheets by writing custom scripts.
- Local processing within the CAD environment saves tokens and allows for self-verification of edits.