Repository navigation
Description
CADCraft's MCP server and control channel already give an agent a typed way into the drawing. We work with LLM agents on real office drawings in another CAD program through a COM/AutoLISP bridge, and most of the time lost there goes to the same few things: an agent addresses something that isn't there and gets no error, it can't tell what coordinate system or unit a value is in, it gets a free-text error it can't act on, or it gets a reply too large to read. CADCraft can get these right now, while the interface is young and before more tools build on it.
Proposed contract, each point small and separate:
- 1. Addressing is strict. A handle that names nothing is an error that lists it, and nothing changes. JSON handles: reject a malformed handle instead of using the selection (fixes #330) #331 and fix(table): malformed explicit handles fall back to the selected table #934/Table commands reject a malformed handle instead of using the selected table (#934) #970 reject malformed handles; a well-formed handle that names nothing is still silent:
move {handles: ["FFFFF"], …}returns{"moved": 0}. (PR: JSON handles: an unknown or erased handle is an error that names it, and nothing changes #1043) - 2. Coordinates say what they are. Geometry is WCS. The DXF reader already maps mirrored objects (extrusion 0,0,−1, common in architectural drawings) to WCS since DXF read: map mirrored OCS (extrusion 0,0,−1) of 2D entities to WCS #277, but an agent can't see that an object was mirrored in the source file, nor which unit a drawing uses. The PR adds
extrusionto entity output when it isn't (0,0,1) and a WCSbbox, hasinspectreportinsunits, and documents the unit of every angle field in docs/mcp.md. (PR: MCP: compact results with structuredContent; entities carry bbox and unusual extrusions; inspect reports insunits #1040) - 3. Output is sized for a context window. Compact JSON plus
structuredContent, and no full entity dump by default frominspect_drawing(about 72 KB of text, 81 KB on the wire, for the 58-entityexamples/apartment.dxf);query_entitiesandfind_textserve entities, paged as they already are. (PR: MCP: compact results with structuredContent; entities carry bbox and unusual extrusions; inspect reports insunits #1040) - 4. Errors are data. The engine already has a typed error (
EngineError). At the MCP and control boundary it becomes free text. Return{code, command, param, message}alongside the text, so an agent can tell a bad parameter from a missing object from "not available yet". (PR: MCP and control channel: engine errors carry a stable code, the command and the parameter #1047; a separatenot_foundcode is left for a follow-up) - 5. Writes report what they did. A mutating command returns the handles it created, changed and deleted, so an agent doesn't have to read back to verify. Some commands do this already (
blockreturns handles), others only a count (copyreturns{"copied": n}). Making it uniform is a later step. - 6. Nothing blocks. Programmatic calls never open dialogs (already a rule in AGENTS.md). Long calls should report progress and be cancellable; a lost reply already says whether the command ran (
not-runvsmay-have-run, Control channel: a timed-out request is cancelled, and the reply says whether it ran (fixes #345) #348). Audit: upstream main source-review findings — 35 correctness, reliability and defensive-security follow-ups #947 lists ambiguous MCP write-completion and retry behaviour as needing contract clarification; this is meant as that clarification.
Later and larger, not part of this issue: transactions (all-or-nothing over several commands, one undo group; see #933 for a command that kept partial changes), dry-run, compare as an MCP tool, and queries by block name, attribute and property with block contents expanded to WCS. Related: #905 (agent skills, docs only), #803 (render options).
Real-file side: we keep a private corpus of office DWGs and re-run it against main with BricsCAD as an independent reader (#1041). We can add agent tasks on those files (count, measure, check a sheet) as a benchmark, with the reference answers taken from the other program.
Happy to adjust the split or the names if the maintainers prefer another shape.
Activity
ParadoxEthos commentedon Oct 15, 2026
+1 to this contract. For the last few months I've been building synTAX, an AutoLISP command that gives an AI sight into a live AutoCAD drawing: it captures the drawing's full state at database depth (environment, sysvars, symbol tables, and every group code of every entity, including XDATA; owner/reactor pointers and binary data chunks are being added now), then adds computed geometry on top (bulge-aware area and perimeter, implied loops from loose LINE chains, scale census, congruent groups, health checks), all as structured TXT/JSON/CSV. The model reasons from exact ground truth instead of guessing at what the drawing contains. Most of my bug fixes there ended up as rules for this kind of contract. Offering them in case they help shape #1040/#1047 and the later steps:
On 3 (output sized for a context window)
profile: "compact"onquery_entitiesonce paging is settled.raw) meant no consumer broke.On 4 (errors are data) — options, not just handles
On 6 (nothing blocks) — interrupted and partial results
"status": "interrupted", or"truncated": truewith the cap that applied), never a cut-off payload.Something not on the list yet: a schema version
schemafield on every tool result, with an explicit rule: adding a field is free, but renaming one or changing its position, units or meaning bumps the version and documents a migration. Once tools build on these results (as this issue anticipates), that rule is what keeps them from breaking quietly. It also pairs well with point 2: units and coordinate systems become part of a field's meaning.Clean-room note: everything above is about my own code's behavior and output; none of it involves AutoCAD files or output.
Happy to turn any of these into a PR once #1040 and #1047 land, so I'm not working against them.
Disclosure: I used Perplexity (Computer) to research CADCraft's codebase and open issues/PRs, compare them against my tool, and draft this comment. The lessons and measurements are from my own tool; I've reviewed the text and stand behind it.
STE1200 commentedon Oct 16, 2026
Thanks, this is very useful, and it matches what we see on the COM/AutoLISP side.
unknown option --typo), but as far as I can see, unknown keys in MCP/control params aren't checked the same way yet. Rejecting them, and rejecting wrongly typed values, fits MCP and control channel: engine errors carry a stable code, the command and the parameter #1047 directly:bad_paramswithparamset to the offending key. That's a good follow-up once MCP and control channel: engine errors carry a stable code, the command and the parameter #1047 is settled.truncatedflag with the cap that applied, plus found/decoded/skipped counts, belongs in the contract.raw-by-flag default is in the spirit of MCP: compact results with structuredContent; entities carry bbox and unusual extrusions; inspect reports insunits #1040.Waiting until #1040/#1047 land before opening PRs sounds right to me too.
STE1200 commentedon Oct 25, 2026
Status update from my side: I have closed #1040, #1043, #1047 and #1048. All four conflicted with
mainafter about a week, and none had a review. I would rather not leave stale work in the queue.The findings stay valid as of 13 October and are listed here for anyone who picks them up:
inspect_drawing {}onexamples/apartment.dxf(58 entities) returned 72 KB of pretty-printed JSON. The PR measured 81,194 → 3,440 bytes for the whole reply. Units and the angle convention (radians or degrees) were not stated either.move {handles: ["FFFFF"], ...}→{"moved": 0}).EngineErrorkinds reach the agent as plain text. A stable code with the command and the parameter would help.infoandconvertdid not report what a damaged DWG left out (Open damaged DWGs partially and say what was left out (acadrust 0.6.4, #800) #859).I did not re-check these on current
main. If any of them is still wanted, tell me which one, and I will redo it as one small PR against currentmain.Rickpixell commentedon Oct 26, 2026
@STE1200, on "Read notes in the CLI" (#1048): still open on the released v0.13.0, measured on Windows 11 with a synthetic file; on
main(d3ae8a6)convertstill prints onlyskipped_message, which counts the DXF reader's records, not the DWG read notes (apps/cadcraft-cli/src/main.rs#L283-L285 on v0.13.0). The open #1790 makes the same change (read_notes_messageon stderr ininfoandconvert,readNotesindrawing.inspect), but it conflicts withmainand has not moved since 22 Oct.Case: a 4-entity drawing (2 LINE, 1 CIRCLE, 1 TEXT) saved by
cadcraft-clias DXF, converted by the ODA File Converter 27.1 to an R12 DWG (AC1009), and the type byte of its first entity record set to an unused value (one byte changed). Then:run --metric --cmd 'open {"path":"bad.dwg"}'"warnings":["DWG: 1 object record couldn't be read and was left out; …"]"entities":0run bad.dwg --save out.dxfconvert bad.dwg out.dxfwrote out.dxf (19766 bytes)info bad.dwg"entityCount": 0,"skipped": {"count": 0}Same result with two other one-place defects (the CRC of the 2nd record, 8 data bytes of the 3rd). So a script that uses
convertorinfogets an empty drawing, exit 0 andskipped: 0. Three more things the same case shows, in case they matter for the redo:info,convertandrun), and so do the same drawing as R13, R14 and 2018 DWG.file-format-parity.mdon v0.13.0 lists R11/R12 DWG read as "no"; DWG: name the version and the missing blocks when an R12 or older file opens #1589 (open) is about R12 files whose blocks are not read.out.dxffrom the damaged file opens with 0 entities. The one from the intact R12 (and from the R13, R14 and 2000 DWGs) is saved as an R2000 DXF and AutoCAD refuses to load it, stopping at the first CLASS record's group 91, which the open DXF: no CLASS instance counts in R2000 files (AutoCAD LT 2026 hung opening them) #1060 drops from R2000 output (I have not built it). From the 2018 DWG it opens with 4 of 4.I could not make a damaged 2000+ DWG that leaves a note (bytes changed inside a TEXT object of an R2000 DWG were read without one), so the R12 file is the only case I measured; the code path above is the same for every version.
CLI: info and convert report what a damaged DWG left out (read notes, s…
CLI: info and convert report what a damaged DWG left out (read notes, s…
CLI: info and convert report what a damaged DWG left out (read notes, #…