# autocad.site — Web CAD & AI Agent Generative Engine > Professional browser-based CAD platform and Model Context Protocol (MCP) generative engineering engine. > Enables human engineers and AI autonomous agents to draft, compute, stream, and collaborate on massive 2D/3D blueprints with zero token exhaustion. > Production URL: https://autocad.site --- ## 🤖 1. For In-Browser AI Agents (BrowserOS, Playwright, Puppeteer, DevTools) When an AI agent opens https://autocad.site in a web browser, it has direct access to the global in-page controller: `window.CAD`. Do **NOT** attempt to click individual ribbon buttons with mouse clicks to draw thousands of coordinates. Instead, call the high-speed JavaScript bridge: ### Core JavaScript API (`window.CAD`) ```javascript // 1. Execute AutoCAD command strings: window.CAD.execute('LINE 0,0 200,0; CIRCLE 100,50 35; ZOOM E'); // 2. Load built-in showcase blueprints: window.CAD.loadSample('mosque'); // Grand 3D Mosque (Dome, Minaret, Sahn, Mihrab, Riwaqs) window.CAD.loadSample('3d'); // 3D Architectural Pavilion window.CAD.loadSample('arch'); // 2D Residential Floor Plan window.CAD.loadSample('mech'); // Mechanical Flange & Gear Assembly window.CAD.loadSample('elec'); // 555 Timer Circuit Schematic window.CAD.loadSample('empty'); // Reset to clean canvas // 3. Document lifecycle: window.CAD.newDrawing('My_Project.dwg'); window.CAD.zoomExtents(); // 4. Import & Export: await window.CAD.loadDWG(arrayBuffer, 'Site.dwg'); // Native AutoCAD DWG binary (R14-2018+) window.CAD.loadDXF(dxfString); // Standard ASCII DXF const dxfString = window.CAD.exportDXF(); // Standard AutoCAD 2000 (AC1015) ASCII DXF const svgString = window.CAD.exportSVG(); // Precision vector SVG const jsonState = window.CAD.exportJSON(); // Complete document JSON window.CAD.loadJSON(jsonState); // 5. Query drawing entities: const entities = window.CAD.getEntities('current'); // 'current', 'model', or 'all' // 6. Online Real-Time Collaboration (Cloudflare D1): const share = await window.CAD.share({ name: 'Structural_Model', expiresDays: 30 }); console.log('View link:', share.view); console.log('Edit link:', share.edit); ``` ### URL Deep-Linking & Automated Launch Parameters Launch or stream geometry to the site using URL query parameters: * **Direct Sample Load:** `https://autocad.site/?sample=mosque` `https://autocad.site/?sample=3d` * **Auto-Execute Commands on Startup:** `https://autocad.site/?clean=1&cmd=RECTANG,0,0,120,80;CIRCLE,60,40,25;ZOOM,E` * **Zero-Refresh Live Hash Streaming:** Push live updates to an open browser tab without reloading: `window.location.hash = '#cmd=' + encodeURIComponent('CIRCLE 100,100 20; VIEW SWISO');` --- ## 🛠️ 2. For Desktop / Stdio AI Agents (Claude Desktop, Cursor, Antigravity, Windsurf) Connect the project's local MCP server via stdio in your client configuration: ```json { "mcpServers": { "cad-engine": { "command": "node", "args": ["/path/to/acad/mcp-server/index.js"] } } } ``` ### The 5-Step Architectural Blueprint Pattern To generate complex, massive architectural drawings without token exhaustion: #### Step 1: Initialize Space & Layers ```json {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"cad_new_drawing","arguments":{"name":"Grand_Project_3D.dwg"}}} {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"cad_add_layers","arguments":{"layers":[ {"name":"GRID","color":"#555566","linetype":"Center","lineweight":"0.13"}, {"name":"WALLS","color":"#00ffff","linetype":"Continuous","lineweight":"0.50"}, {"name":"COLUMNS","color":"#33ffbb","linetype":"Continuous","lineweight":"0.35"}, {"name":"DOME_3D","color":"#ffaa00","linetype":"Continuous","lineweight":"0.35"}, {"name":"MINARET_3D","color":"#ff7700","linetype":"Continuous","lineweight":"0.35"}, {"name":"HATCH","color":"#2d5a3f","linetype":"Continuous","lineweight":"0.13"}, {"name":"DIMENSIONS","color":"#ff3355","linetype":"Continuous","lineweight":"0.18"}, {"name":"ANNOTATIONS","color":"#ffffff","linetype":"Continuous","lineweight":"0.25"} ]}}} ``` #### Step 2: Batch Add Entities (`cad_batch_add_entities`) Insert entities in batches of 100–150 items. Supported types: - **`LINE`**: `{ p1: {x, y, z}, p2: {x, y, z}, layer, color }` - **`LWPOLYLINE`**: `{ points: [{x, y, bulge}], closed: true, width, layer }` - **`POLYLINE3D`**: `{ points: [{x, y, z}], closed: false, layer }` - **`CIRCLE` / `ARC`**: `{ center: {x, y}, radius, z, normal: [x,y,z], layer }` - **`TEXT` / `MTEXT`**: `{ text, pos: {x, y}, height, justification: "Center", layer }` - **`HATCH`**: `{ pattern: "ANSI31"|"ANSI37"|"SOLID", loops: [[{x, y}]], scale, angle, layer }` - **`DIMENSION`**: `{ dimType: "linear", p1: {x, y}, p2: {x, y}, textPos: {x, y}, textSize: 2.2, layer }` #### Step 3: Add 3D Volumetric Solids (`cad_run_commands`) Drop authentic 3D CSG solids: ```json {"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"cad_run_commands","arguments":{"commands": "BOX 40,90,0 6,6 24; CYL 60,110,20 18 4; SPHERE 60,110,36 18; CYL 125,153,56 4.2 18" }}} ``` #### Step 4: Audit Camera Views & Export ```json // Top Plan View: {"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"cad_run_commands","arguments":{"commands":"VIEW TOP; PLAN"}}} {"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"cad_export_svg","arguments":{"filePath":"plans/plan.svg","background":"#0f172a"}}} // 3D Isometric View: {"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"cad_run_commands","arguments":{"commands":"VIEW SWISO"}}} {"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"cad_export_svg","arguments":{"filePath":"plans/axonometric.svg","background":"#0b1120"}}} // AutoCAD 2000 AC1015 DXF Export: {"jsonrpc":"2.0","id":8,"method":"tools/call","params":{"name":"cad_export_dxf","arguments":{"filePath":"plans/master.dxf"}}} ``` #### Step 5: Procedural Code Sandbox (`cad_execute_script`) For arrays of 10,000+ entities, write pure JavaScript executed inside an isolated Node sandbox: ```javascript // Variable context: S (state), En (entities), M (math), G (geometry) for (let i = 0; i < 16; i++) { const ang = (i * Math.PI * 2) / 16; const pts = []; for (let s = 0; s <= 12; s++) { const phi = (s / 12) * (Math.PI / 2); pts.push({ x: 60 + Math.cos(ang) * 18 * Math.cos(phi), y: 110 + Math.sin(ang) * 18 * Math.cos(phi), z: 24 + 30 * Math.sin(phi) }); } S.addEntity(new En.Polyline3DEntity(pts, false, { layer: 'DOME_3D' })); } ``` --- ## 🕌 3. Case Study Reference: Grand Mosque 3D Blueprint * **Footprint:** 120m × 160m (Prayer Hall: 120m × 100m, Courtyard: 120m × 60m). * **Central Dome:** Ø36.00m span, base drum at +20m, springing at +24m, 16 meridian arches curving to apex lantern at +54m. 4 massive 6m × 6m corner piers and 4 flanking semi-domes. * **Monumental Minaret:** 100m tall tower with 12m × 12m square plinth, squinch transition, octagonal lower shaft, first cantilevered balcony at +56m, cylindrical upper shaft, second balcony at +74m, conical pencil spire, and brass crescent finial at +100m. * **Courtyard (Sahn):** Open marble paving with `ANSI37` cross-hatch, 40-column peristyle arcades (Riwaqs), and central 8-column Shadirvan ablution pavilion. * **Sanctuary:** Arched Mihrab niche, 10-step marble Minbar, elevated Dikka platform, and prayer carpet safuf rows with `ANSI31` weave hatch. * **Verification:** Produces 759 architectural primitives and 3D solids. Exports 100% compliant AC1015 DXF passing all ezdxf audits with 0 errors. --- ## 📋 4. Complete Tool Inventory (19 MCP Tools) 1. `cad_new_drawing`: Initializes or resets drawing space, filename, and units. 2. `cad_add_layers`: Configures layers with colors, linetypes, and lineweights. 3. `cad_batch_add_entities`: Bulk insertion of 20+ CAD primitive types. 4. `cad_create_block`: Defines reusable blocks with `ATTDEF` attributes. 5. `cad_insert_block`: Places block instances with transforms and attributes. 6. `cad_generate_parametric`: Generates structural grids, trusses, flanges, gears, or floorplans. 7. `cad_run_commands`: Runs full AutoCAD CLI command scripts (2D & 3D). 8. `cad_list_commands`: Lists every implemented command with aliases and descriptions. 9. `cad_execute_script`: High-speed procedural JavaScript generator sandbox. 10. `cad_open_dxf`: Opens ASCII DXF (R12 to 2018+) into active session. 11. `cad_export_dxf`: Exports AutoCAD 2000 AC1015 ASCII DXF file. 12. `cad_export_svg`: Renders drawing to precision vector SVG preview. 13. `cad_export_stl`: Exports closed 3D solids to binary or ASCII STL for 3D printing. 14. `cad_solids`: Inspects 3D solids (list, measure, volume, check manifold). 15. `cad_get_stats`: Comprehensive drawing analytics (entity counts, layers, extents). 16. `cad_share_drawing`: Shares active session to Cloudflare D1 with view & edit URLs. 17. `cad_open_shared`: Opens a remote shared drawing into the session. 18. `cad_update_shared`: Updates a shared drawing with session revisions. 19. `cad_revoke_shared`: Deletes/revokes a shared drawing link.