cyclecad 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/API-BUILD-MANIFEST.txt +339 -0
  2. package/API-SERVER.md +535 -0
  3. package/Architecture-Deck.pptx +0 -0
  4. package/CLAUDE.md +172 -11
  5. package/CLI-BUILD-SUMMARY.md +504 -0
  6. package/CLI-INDEX.md +356 -0
  7. package/CLI-README.md +466 -0
  8. package/COLLABORATION-INTEGRATION-GUIDE.md +325 -0
  9. package/CONNECTED_FABS_GUIDE.md +612 -0
  10. package/CONNECTED_FABS_README.md +310 -0
  11. package/DELIVERABLES.md +343 -0
  12. package/DFM-ANALYZER-INTEGRATION.md +368 -0
  13. package/DFM-QUICK-START.js +253 -0
  14. package/Dockerfile +69 -0
  15. package/IMPLEMENTATION.md +327 -0
  16. package/LICENSE +31 -0
  17. package/MARKETPLACE_QUICK_REFERENCE.txt +294 -0
  18. package/MCP-INDEX.md +264 -0
  19. package/QUICKSTART-API.md +388 -0
  20. package/QUICKSTART-CLI.md +211 -0
  21. package/QUICKSTART-MCP.md +196 -0
  22. package/README-MCP.md +208 -0
  23. package/TEST-TOKEN-ENGINE.md +319 -0
  24. package/TOKEN-ENGINE-SUMMARY.md +266 -0
  25. package/TOKENS-README.md +263 -0
  26. package/TOOLS-REFERENCE.md +254 -0
  27. package/app/index.html +168 -3
  28. package/app/js/TOKEN-INTEGRATION.md +391 -0
  29. package/app/js/agent-api.js +3 -3
  30. package/app/js/ai-copilot.js +1435 -0
  31. package/app/js/cam-pipeline.js +840 -0
  32. package/app/js/collaboration-ui.js +995 -0
  33. package/app/js/collaboration.js +1116 -0
  34. package/app/js/connected-fabs-example.js +404 -0
  35. package/app/js/connected-fabs.js +1449 -0
  36. package/app/js/dfm-analyzer.js +1760 -0
  37. package/app/js/marketplace.js +1994 -0
  38. package/app/js/material-library.js +2115 -0
  39. package/app/js/token-dashboard.js +563 -0
  40. package/app/js/token-engine.js +743 -0
  41. package/app/test-agent.html +1801 -0
  42. package/bin/cyclecad-cli.js +662 -0
  43. package/bin/cyclecad-mcp +2 -0
  44. package/bin/server.js +242 -0
  45. package/cycleCAD-Architecture.pptx +0 -0
  46. package/cycleCAD-Investor-Deck.pptx +0 -0
  47. package/demo-mcp.sh +60 -0
  48. package/docs/API-SERVER-SUMMARY.md +375 -0
  49. package/docs/API-SERVER.md +667 -0
  50. package/docs/CAM-EXAMPLES.md +344 -0
  51. package/docs/CAM-INTEGRATION.md +612 -0
  52. package/docs/CAM-QUICK-REFERENCE.md +199 -0
  53. package/docs/CLI-INTEGRATION.md +510 -0
  54. package/docs/CLI.md +872 -0
  55. package/docs/MARKETPLACE-API-SCHEMA.json +564 -0
  56. package/docs/MARKETPLACE-INTEGRATION.md +467 -0
  57. package/docs/MARKETPLACE-SETUP.html +439 -0
  58. package/docs/MCP-SERVER.md +403 -0
  59. package/examples/api-client-example.js +488 -0
  60. package/examples/api-client-example.py +359 -0
  61. package/examples/batch-manufacturing.txt +28 -0
  62. package/examples/batch-simple.txt +26 -0
  63. package/model-marketplace.html +1273 -0
  64. package/package.json +14 -3
  65. package/server/api-server.js +1120 -0
  66. package/server/mcp-server.js +1161 -0
  67. package/test-api-server.js +432 -0
  68. package/test-mcp.js +198 -0
  69. package/~$cycleCAD-Investor-Deck.pptx +0 -0
@@ -0,0 +1,403 @@
1
+ # cycleCAD MCP Server
2
+
3
+ Model Context Protocol (MCP) server for cycleCAD. Exposes the complete Agent API (55+ commands) as MCP tools that can be used by LLMs like Claude, GPT, and Gemini.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Start the server
9
+ npx cyclecad-mcp
10
+
11
+ # Or with custom WebSocket URL
12
+ npx cyclecad-mcp --ws-url ws://10.0.0.1:3000/api/ws
13
+
14
+ # Or with debug logging
15
+ npx cyclecad-mcp --debug
16
+
17
+ # Show help
18
+ npx cyclecad-mcp --help
19
+ ```
20
+
21
+ The server reads JSON-RPC requests from stdin and writes responses to stdout (MCP protocol).
22
+
23
+ ## Features
24
+
25
+ - **55+ Tools**: All Agent API commands exposed as MCP tools
26
+ - **10 Namespaces**: sketch, ops, transform, view, export, validate, render, query, assembly, ai, meta, scene
27
+ - **Dual Transport**: WebSocket (preferred) + HTTP fallback
28
+ - **Non-blocking**: Commands queued if connection unavailable
29
+ - **Zero Dependencies**: No npm packages required (uses Node.js built-ins)
30
+ - **JSON Schema**: Full input validation schemas for all tools
31
+
32
+ ## Tool Categories
33
+
34
+ ### SKETCH (8 tools)
35
+ - `sketch_start` — Start sketch mode on XY/XZ/YZ plane
36
+ - `sketch_end` — End sketch, return all entities
37
+ - `sketch_line` — Draw a line segment
38
+ - `sketch_rect` — Draw a rectangle
39
+ - `sketch_circle` — Draw a circle
40
+ - `sketch_arc` — Draw an arc
41
+ - `sketch_clear` — Clear all sketch entities
42
+ - `sketch_entities` — List current sketch entities
43
+
44
+ ### OPS (20 tools)
45
+ - `ops_extrude` — Extrude sketch into 3D solid
46
+ - `ops_revolve` — Revolve sketch around axis
47
+ - `ops_primitive` — Create primitive shape (box, sphere, cylinder, cone, torus, capsule)
48
+ - `ops_fillet` — Apply fillet to edges
49
+ - `ops_chamfer` — Apply chamfer to edges
50
+ - `ops_boolean` — Boolean operations (union, cut, intersect)
51
+ - `ops_shell` — Create hollow shell
52
+ - `ops_pattern` — Create array pattern
53
+ - `ops_material` — Change material
54
+ - `ops_sweep` — Sweep profile along path
55
+ - `ops_loft` — Loft between profiles
56
+ - `ops_spring` — Generate helical spring
57
+ - `ops_thread` — Generate screw thread
58
+ - `ops_bend` — Sheet metal bend
59
+
60
+ ### TRANSFORM (3 tools)
61
+ - `transform_move` — Translate feature by X/Y/Z offset
62
+ - `transform_rotate` — Rotate feature around axes
63
+ - `transform_scale` — Scale feature along axes
64
+
65
+ ### VIEW (4 tools)
66
+ - `view_set` — Set camera view (front, back, left, right, top, bottom, isometric)
67
+ - `view_fit` — Fit view to feature(s)
68
+ - `view_wireframe` — Toggle wireframe rendering
69
+ - `view_grid` — Toggle grid visibility
70
+
71
+ ### EXPORT (4 tools)
72
+ - `export_stl` — Export STL (binary or ASCII)
73
+ - `export_obj` — Export OBJ
74
+ - `export_gltf` — Export glTF 2.0
75
+ - `export_json` — Export cycleCAD JSON
76
+
77
+ ### VALIDATE (8 tools)
78
+ - `validate_dimensions` — Get bounding box dimensions
79
+ - `validate_wallThickness` — Check minimum wall thickness
80
+ - `validate_printability` — Check FDM/SLA/CNC printability
81
+ - `validate_cost` — Estimate manufacturing cost
82
+ - `validate_mass` — Estimate part mass/weight
83
+ - `validate_surfaceArea` — Calculate surface area
84
+ - `validate_centerOfMass` — Get geometric centroid
85
+ - `validate_designReview` — Auto-analyze (A/B/C/F score)
86
+
87
+ ### RENDER (5 tools)
88
+ - `render_snapshot` — Render viewport as PNG
89
+ - `render_multiview` — Render 6 standard views as PNGs
90
+ - `render_highlight` — Highlight component with color
91
+ - `render_hide` — Hide/show component
92
+ - `render_section` — Enable section cutting (cross-section)
93
+
94
+ ### QUERY (5 tools)
95
+ - `query_features` — List all features
96
+ - `query_bbox` — Get bounding box of feature
97
+ - `query_materials` — List available materials
98
+ - `query_session` — Session info
99
+ - `query_log` — Recent command log
100
+
101
+ ### ASSEMBLY (4 tools)
102
+ - `assembly_addComponent` — Add component to assembly
103
+ - `assembly_removeComponent` — Remove component
104
+ - `assembly_mate` — Define mate constraint
105
+ - `assembly_explode` — Explode component
106
+
107
+ ### SCENE (2 tools)
108
+ - `scene_clear` — Clear all features
109
+ - `scene_snapshot` — Capture viewport as PNG (legacy)
110
+
111
+ ### AI (3 tools)
112
+ - `ai_identifyPart` — Identify part using Gemini Vision
113
+ - `ai_suggestImprovements` — Get design improvement suggestions
114
+ - `ai_estimateCostAI` — AI-powered cost estimation
115
+
116
+ ### META (5 tools)
117
+ - `meta_ping` — Health check + uptime
118
+ - `meta_version` — Version info + feature flags
119
+ - `meta_schema` — Full API schema
120
+ - `meta_modules` — Check available modules
121
+ - `meta_history` — Undo/redo history stack
122
+
123
+ ## Connection
124
+
125
+ The MCP server connects to cycleCAD via:
126
+
127
+ 1. **WebSocket** (preferred): `ws://localhost:3000/api/ws`
128
+ - Non-blocking, real-time bidirectional communication
129
+ - Used for long-running operations
130
+
131
+ 2. **HTTP** (fallback): `http://localhost:3000/api/execute`
132
+ - Used if WebSocket unavailable
133
+ - Commands queued until WebSocket connects
134
+
135
+ The server is non-blocking: if cycleCAD is not running, the MCP server starts anyway and queues commands. Commands are executed as soon as the WebSocket connects.
136
+
137
+ ## Usage Examples
138
+
139
+ ### Via Claude API
140
+ ```python
141
+ import anthropic
142
+
143
+ client = anthropic.Anthropic()
144
+
145
+ response = client.messages.create(
146
+ model="claude-3-5-sonnet-20241022",
147
+ max_tokens=1024,
148
+ tools=[
149
+ {
150
+ "type": "model_context_protocol",
151
+ "name": "cyclecad-mcp",
152
+ "uri": "stdio:///path/to/cyclecad/bin/cyclecad-mcp"
153
+ }
154
+ ],
155
+ messages=[
156
+ {
157
+ "role": "user",
158
+ "content": "Design a simple bracket: rectangle 80x40mm, extrude 5mm, add a cylinder for a bolt hole"
159
+ }
160
+ ]
161
+ )
162
+
163
+ print(response.content)
164
+ ```
165
+
166
+ ### Direct Tool Usage
167
+ ```python
168
+ # After Claude calls tools, tools are automatically executed by the MCP server
169
+ # and results are returned to Claude for further processing
170
+ ```
171
+
172
+ ### Standalone Testing
173
+ ```bash
174
+ # Terminal 1: Start cycleCAD
175
+ npx serve . -p 3000
176
+
177
+ # Terminal 2: Start MCP server
178
+ npx cyclecad-mcp --debug
179
+
180
+ # Terminal 3: Send JSON-RPC requests
181
+ echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | nc localhost 9000
182
+ echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "sketch_rect", "arguments": {"width": 50, "height": 30}}}' | nc localhost 9000
183
+ ```
184
+
185
+ ## Configuration
186
+
187
+ ### Environment Variables
188
+ - `CYCLECAD_WS_URL` — WebSocket URL (default: `ws://localhost:3000/api/ws`)
189
+ - `CYCLECAD_HTTP_URL` — HTTP URL (default: `http://localhost:3000/api/execute`)
190
+ - `DEBUG_MCP` — Enable debug logging (set to `1`)
191
+
192
+ ### Command Line Arguments
193
+ ```
194
+ --ws-url URL Override WebSocket URL
195
+ --http-url URL Override HTTP URL
196
+ --debug Enable debug logging
197
+ --help Show help message
198
+ --version Show version
199
+ ```
200
+
201
+ ## Implementation Details
202
+
203
+ ### JSON-RPC Protocol
204
+ The MCP server implements JSON-RPC 2.0 over stdio:
205
+
206
+ **Request:**
207
+ ```json
208
+ {
209
+ "jsonrpc": "2.0",
210
+ "id": 1,
211
+ "method": "tools/call",
212
+ "params": {
213
+ "name": "sketch_rect",
214
+ "arguments": {
215
+ "width": 50,
216
+ "height": 30
217
+ }
218
+ }
219
+ }
220
+ ```
221
+
222
+ **Response (success):**
223
+ ```json
224
+ {
225
+ "jsonrpc": "2.0",
226
+ "id": 1,
227
+ "result": {
228
+ "content": [
229
+ {
230
+ "type": "text",
231
+ "text": "{\"id\":\"rect_1\",\"type\":\"rect\",\"origin\":[0,0],\"width\":50,\"height\":30,\"area\":1500,\"edges\":4}"
232
+ }
233
+ ]
234
+ }
235
+ }
236
+ ```
237
+
238
+ **Response (error):**
239
+ ```json
240
+ {
241
+ "jsonrpc": "2.0",
242
+ "id": 1,
243
+ "result": {
244
+ "content": [
245
+ {
246
+ "type": "text",
247
+ "text": "{\"ok\":false,\"error\":\"Required parameter \\\"width\\\" is missing\",\"method\":\"sketch.rect\",\"args\":{}}"
248
+ }
249
+ ],
250
+ "isError": true
251
+ }
252
+ }
253
+ ```
254
+
255
+ ### Tool Naming Convention
256
+ - Agent API method: `sketch.start`
257
+ - MCP tool name: `sketch_start` (underscores instead of dots)
258
+ - Conversion: `name.replace(/_/g, '.')`
259
+
260
+ ### JSON Schema
261
+ Each tool has a full JSON Schema for input validation:
262
+
263
+ ```json
264
+ {
265
+ "name": "sketch_rect",
266
+ "description": "Draw a rectangle in the sketch",
267
+ "inputSchema": {
268
+ "type": "object",
269
+ "properties": {
270
+ "x": { "type": "number", "description": "Origin X" },
271
+ "y": { "type": "number", "description": "Origin Y" },
272
+ "width": { "type": "number", "description": "Rectangle width" },
273
+ "height": { "type": "number", "description": "Rectangle height" }
274
+ },
275
+ "required": ["width", "height"]
276
+ }
277
+ }
278
+ ```
279
+
280
+ ## Debugging
281
+
282
+ ### Enable Debug Logging
283
+ ```bash
284
+ npx cyclecad-mcp --debug
285
+ ```
286
+
287
+ Debug output goes to stderr and includes:
288
+ - Request/response method names
289
+ - Connection status
290
+ - WebSocket events
291
+ - Error messages
292
+
293
+ ### Example Debug Output
294
+ ```
295
+ [MCP] Server ready, waiting for requests...
296
+ [MCP] ← tools/list
297
+ [MCP] → OK
298
+ [MCP] ← tools/call
299
+ [MCP] → OK
300
+ [MCP] WebSocket connected
301
+ [MCP] ← tools/call (via WS)
302
+ [MCP] → OK
303
+ ```
304
+
305
+ ## Architecture
306
+
307
+ ```
308
+ ┌─────────────────────────────────────────────────────────┐
309
+ │ Claude / GPT / Gemini / etc (via Claude API) │
310
+ └────────────────────┬────────────────────────────────────┘
311
+
312
+ MCP Protocol (stdio)
313
+
314
+ ┌────────────────────▼────────────────────────────────────┐
315
+ │ cyclecad-mcp Server (Node.js) │
316
+ │ ├─ JSON-RPC dispatch │
317
+ │ ├─ Tool definitions (55+ tools) │
318
+ │ ├─ WebSocket connection (preferred) │
319
+ │ └─ HTTP fallback │
320
+ └────────────┬──────────────────────┬─────────────────────┘
321
+ │ │
322
+ WebSocket (WS) HTTP (POST)
323
+ │ │
324
+ ┌────────────▼─────────────────────▼─────────────────────┐
325
+ │ cycleCAD (Browser or Node.js) │
326
+ │ ├─ Agent API (app/js/agent-api.js) │
327
+ │ ├─ Modules: sketch, ops, viewport, assembly, etc │
328
+ │ └─ Three.js scene graph │
329
+ └──────────────────────────────────────────────────────────┘
330
+ ```
331
+
332
+ ## Testing
333
+
334
+ ### Manual Tool Testing
335
+ ```bash
336
+ # Start MCP server
337
+ npx cyclecad-mcp --debug &
338
+
339
+ # Test sketch_rect tool
340
+ node -e "
341
+ const data = JSON.stringify({
342
+ jsonrpc: '2.0',
343
+ id: 1,
344
+ method: 'tools/call',
345
+ params: {
346
+ name: 'sketch_rect',
347
+ arguments: { width: 50, height: 30 }
348
+ }
349
+ });
350
+ process.stdin.write(data + '\n');
351
+ " | npx cyclecad-mcp --debug
352
+ ```
353
+
354
+ ### Full Design Workflow
355
+ ```javascript
356
+ const commands = [
357
+ { method: 'sketch.start', params: { plane: 'XY' } },
358
+ { method: 'sketch.rect', params: { width: 80, height: 40 } },
359
+ { method: 'ops.extrude', params: { height: 5, material: 'aluminum' } },
360
+ { method: 'sketch.start', params: { plane: 'XY' } },
361
+ { method: 'sketch.circle', params: { cx: 40, cy: 20, radius: 3 } },
362
+ { method: 'ops.extrude', params: { height: 30, material: 'steel' } },
363
+ { method: 'validate.designReview', params: { target: 'extrude_1' } },
364
+ { method: 'export.stl', params: { filename: 'bracket.stl' } }
365
+ ];
366
+
367
+ // Send each command via MCP tools/call
368
+ ```
369
+
370
+ ## Performance
371
+
372
+ - **Startup time**: ~100ms
373
+ - **Tool invocation**: <50ms (JSON-RPC + WebSocket)
374
+ - **Command execution**: Variable (depends on cycleCAD operation)
375
+ - **Memory**: ~50MB baseline
376
+ - **Timeout**: 30 seconds per command (configurable)
377
+
378
+ ## Limitations
379
+
380
+ 1. **Browser-based cycleCAD only**: Server communicates with HTTP/WebSocket endpoints on cycleCAD
381
+ 2. **Single session**: One MCP server instance = one cycleCAD session
382
+ 3. **No persistence**: Commands are in-memory only (use `export.*` to save)
383
+ 4. **No real B-rep**: Boolean operations and fillets use mesh approximations
384
+ 5. **Timeout**: 30 second hard timeout per command
385
+
386
+ ## Roadmap
387
+
388
+ - [ ] Real B-rep boolean operations (OpenCascade.js integration)
389
+ - [ ] Session persistence (save/load projects)
390
+ - [ ] Multi-user collaborative mode
391
+ - [ ] GPU-accelerated rendering
392
+ - [ ] Plugin API for custom tools
393
+ - [ ] Cloud deployment (AWS Lambda, Google Cloud Run)
394
+
395
+ ## License
396
+
397
+ MIT — See LICENSE in cycleCAD repo
398
+
399
+ ## Contact
400
+
401
+ - GitHub: https://github.com/vvlars-cmd/cyclecad
402
+ - Email: vvlars@googlemail.com
403
+ - Web: https://cyclecad.com