@hybridlabor-api/bdb-hardware-pcb 0.1.0

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 (192) hide show
  1. package/README.md +116 -0
  2. package/config/mcp/antigravity.json +22 -0
  3. package/config/mcp/claude.json +22 -0
  4. package/config/mcp/codex.toml +25 -0
  5. package/docs/adr/ADR-001-KICAD-OPENSCAD-MCP-STRATEGY.md +334 -0
  6. package/docs/review_documentation.md +121 -0
  7. package/installer.js +358 -0
  8. package/mcp_servers/kicad-mcp-server/.env.example +22 -0
  9. package/mcp_servers/kicad-mcp-server/.github/workflows/ci.yml +36 -0
  10. package/mcp_servers/kicad-mcp-server/CLAUDE.md +487 -0
  11. package/mcp_servers/kicad-mcp-server/README.md +316 -0
  12. package/mcp_servers/kicad-mcp-server/docs/DEVICE_TREE.md +416 -0
  13. package/mcp_servers/kicad-mcp-server/docs/INSTALLATION.md +332 -0
  14. package/mcp_servers/kicad-mcp-server/docs/PIN_ANALYSIS.md +332 -0
  15. package/mcp_servers/kicad-mcp-server/docs/README.md +240 -0
  16. package/mcp_servers/kicad-mcp-server/docs/TESTING.md +613 -0
  17. package/mcp_servers/kicad-mcp-server/docs/VALIDATION.md +268 -0
  18. package/mcp_servers/kicad-mcp-server/pyproject.toml +96 -0
  19. package/mcp_servers/kicad-mcp-server/requirements-dev.txt +16 -0
  20. package/mcp_servers/kicad-mcp-server/requirements-test.txt +24 -0
  21. package/mcp_servers/kicad-mcp-server/requirements.txt +13 -0
  22. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/__init__.py +3 -0
  23. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/__main__.py +17 -0
  24. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/config.py +46 -0
  25. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/models/__init__.py +1 -0
  26. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/models/types.py +87 -0
  27. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/parsers/__init__.py +1 -0
  28. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/parsers/netlist_parser.py +234 -0
  29. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/parsers/pcb_parser.py +375 -0
  30. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/parsers/pcb_parser_kicad.py +327 -0
  31. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/parsers/schematic_parser.py +902 -0
  32. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/server.py +71 -0
  33. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/__init__.py +1 -0
  34. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/arduino/connectivity_test.cpp.j2 +189 -0
  35. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/device_tree/atmega.dts.j2 +77 -0
  36. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/device_tree/esp32.dts.j2 +77 -0
  37. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/device_tree/nrf52.dts.j2 +77 -0
  38. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/device_tree/stm32f4.dts.j2 +89 -0
  39. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/esp_idf/test_suite.c.j2 +340 -0
  40. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/pytest/test_connectivity.py.j2 +147 -0
  41. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/st_hal/hal_test.c.j2 +313 -0
  42. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/tests/pytest_gpio_test.py.j2 +99 -0
  43. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/tests/pytest_i2c_test.py.j2 +117 -0
  44. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/tests/pytest_pinmux_test.py.j2 +43 -0
  45. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/tests/pytest_spi_test.py.j2 +94 -0
  46. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/tests/unity_gpio_test.c.j2 +113 -0
  47. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/tests/unity_i2c_test.c.j2 +101 -0
  48. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/tests/unity_spi_test.c.j2 +94 -0
  49. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/templates/unittest/test_schematic.py.j2 +172 -0
  50. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/__init__.py +36 -0
  51. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/device_tree.py +1187 -0
  52. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/hierarchical_analysis.py +211 -0
  53. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/netlist.py +320 -0
  54. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/parts_registry.py +142 -0
  55. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/pcb.py +955 -0
  56. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/pcb_layout.py +308 -0
  57. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/pin_analysis.py +765 -0
  58. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/project.py +196 -0
  59. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/schematic.py +319 -0
  60. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/schematic_editor.py +674 -0
  61. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/schematic_search.py +158 -0
  62. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/validation.py +866 -0
  63. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/tools/visualization.py +225 -0
  64. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/utils/__init__.py +1 -0
  65. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/utils/file_handlers.py +65 -0
  66. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/utils/kicad_cli.py +103 -0
  67. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/utils/kicad_version.py +103 -0
  68. package/mcp_servers/kicad-mcp-server/src/kicad_mcp_server/utils/parts_registry.py +197 -0
  69. package/mcp_servers/kicad-mcp-server/tests/__init__.py +1 -0
  70. package/mcp_servers/kicad-mcp-server/tests/examples/ESP32S3_TEST.md +219 -0
  71. package/mcp_servers/kicad-mcp-server/tests/fixtures/README.md +65 -0
  72. package/mcp_servers/kicad-mcp-server/tests/fixtures/__init__.py +1 -0
  73. package/mcp_servers/kicad-mcp-server/tests/fixtures/example_pcb.kicad_pcb +177 -0
  74. package/mcp_servers/kicad-mcp-server/tests/fixtures/example_schematic.kicad_sch +145 -0
  75. package/mcp_servers/kicad-mcp-server/tests/fixtures/hier/child.kicad_sch +24 -0
  76. package/mcp_servers/kicad-mcp-server/tests/fixtures/hier/root.kicad_sch +38 -0
  77. package/mcp_servers/kicad-mcp-server/tests/test_tools/__init__.py +1 -0
  78. package/mcp_servers/kicad-mcp-server/tests/test_tools/test_hierarchical_labels.py +195 -0
  79. package/mcp_servers/kicad-mcp-server/tests/test_tools/test_kicad_cli.py +116 -0
  80. package/mcp_servers/kicad-mcp-server/tests/test_tools/test_netlist_cache_path.py +29 -0
  81. package/mcp_servers/kicad-mcp-server/tests/test_tools/test_schematic.py +189 -0
  82. package/mcp_servers/kicad-mcp-server/tests/test_tools/test_schematic_hierarchy.py +69 -0
  83. package/mcp_servers/kicad-mcp-server/tests/test_tools/test_visualization.py +136 -0
  84. package/mcp_servers/kicad-mcp-server/uv.lock +2873 -0
  85. package/mcp_servers/openscad-mcp-server/.dockerignore +9 -0
  86. package/mcp_servers/openscad-mcp-server/.github/workflows/test.yml +40 -0
  87. package/mcp_servers/openscad-mcp-server/Dockerfile +29 -0
  88. package/mcp_servers/openscad-mcp-server/LICENSE +21 -0
  89. package/mcp_servers/openscad-mcp-server/README.md +154 -0
  90. package/mcp_servers/openscad-mcp-server/docs/audit.md +56 -0
  91. package/mcp_servers/openscad-mcp-server/docs/docker.md +66 -0
  92. package/mcp_servers/openscad-mcp-server/docs/issue-followup.md +19 -0
  93. package/mcp_servers/openscad-mcp-server/docs/jetson.md +17 -0
  94. package/mcp_servers/openscad-mcp-server/glama.json +4 -0
  95. package/mcp_servers/openscad-mcp-server/legacy/README.md +15 -0
  96. package/mcp_servers/openscad-mcp-server/legacy/README.original.md +294 -0
  97. package/mcp_servers/openscad-mcp-server/legacy/implementation_plan.md +100 -0
  98. package/mcp_servers/openscad-mcp-server/legacy/old/download_sam2_checkpoint.py +115 -0
  99. package/mcp_servers/openscad-mcp-server/legacy/old/src/ai/sam_segmentation.py +209 -0
  100. package/mcp_servers/openscad-mcp-server/legacy/old/src/models/threestudio_generator.py +231 -0
  101. package/mcp_servers/openscad-mcp-server/legacy/old/src/workflow/image_to_model_pipeline.py +260 -0
  102. package/mcp_servers/openscad-mcp-server/legacy/old/test_sam2_segmentation.py +96 -0
  103. package/mcp_servers/openscad-mcp-server/legacy/requirements.txt +57 -0
  104. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/README.md +39 -0
  105. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/decisions/ai-driven-code-generation.md +122 -0
  106. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/decisions/export-formats.md +76 -0
  107. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/files/src/ai/ai_service.py.md +51 -0
  108. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/files/src/main.py.md +63 -0
  109. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/files/src/models/code_generator.py.md +63 -0
  110. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/files/src/nlp/parameter_extractor.py.md +63 -0
  111. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/knowledge/ai/natural-language-processing.md +78 -0
  112. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/knowledge/nlp/parameter-extraction.md +173 -0
  113. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/knowledge/openscad/export-formats.md +91 -0
  114. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/knowledge/openscad/openscad-basics.md +66 -0
  115. package/mcp_servers/openscad-mcp-server/legacy/rtfmd/knowledge/openscad/primitive-testing.md +79 -0
  116. package/mcp_servers/openscad-mcp-server/legacy/src/__init__.py +0 -0
  117. package/mcp_servers/openscad-mcp-server/legacy/src/ai/ai_service.py +257 -0
  118. package/mcp_servers/openscad-mcp-server/legacy/src/ai/gemini_api.py +161 -0
  119. package/mcp_servers/openscad-mcp-server/legacy/src/ai/venice_api.py +203 -0
  120. package/mcp_servers/openscad-mcp-server/legacy/src/config.py +121 -0
  121. package/mcp_servers/openscad-mcp-server/legacy/src/main.py +1456 -0
  122. package/mcp_servers/openscad-mcp-server/legacy/src/main.py.new +404 -0
  123. package/mcp_servers/openscad-mcp-server/legacy/src/main_remote.py +401 -0
  124. package/mcp_servers/openscad-mcp-server/legacy/src/models/__init__.py +0 -0
  125. package/mcp_servers/openscad-mcp-server/legacy/src/models/code_generator.py +321 -0
  126. package/mcp_servers/openscad-mcp-server/legacy/src/models/cuda_mvs.py +209 -0
  127. package/mcp_servers/openscad-mcp-server/legacy/src/models/scad_templates/basic_shapes.scad +144 -0
  128. package/mcp_servers/openscad-mcp-server/legacy/src/nlp/__init__.py +0 -0
  129. package/mcp_servers/openscad-mcp-server/legacy/src/nlp/parameter_extractor.py +388 -0
  130. package/mcp_servers/openscad-mcp-server/legacy/src/openscad_wrapper/__init__.py +0 -0
  131. package/mcp_servers/openscad-mcp-server/legacy/src/openscad_wrapper/wrapper.py +418 -0
  132. package/mcp_servers/openscad-mcp-server/legacy/src/printer_discovery/__init__.py +1 -0
  133. package/mcp_servers/openscad-mcp-server/legacy/src/printer_discovery/printer_discovery.py +471 -0
  134. package/mcp_servers/openscad-mcp-server/legacy/src/remote/connection_manager.py +537 -0
  135. package/mcp_servers/openscad-mcp-server/legacy/src/remote/cuda_mvs_client.py +435 -0
  136. package/mcp_servers/openscad-mcp-server/legacy/src/remote/cuda_mvs_server.py +787 -0
  137. package/mcp_servers/openscad-mcp-server/legacy/src/remote/error_handling.py +415 -0
  138. package/mcp_servers/openscad-mcp-server/legacy/src/testing/__init__.py +0 -0
  139. package/mcp_servers/openscad-mcp-server/legacy/src/testing/primitive_tester.py +203 -0
  140. package/mcp_servers/openscad-mcp-server/legacy/src/testing/test_primitives.py +98 -0
  141. package/mcp_servers/openscad-mcp-server/legacy/src/utils/__init__.py +1 -0
  142. package/mcp_servers/openscad-mcp-server/legacy/src/utils/cad_exporter.py +241 -0
  143. package/mcp_servers/openscad-mcp-server/legacy/src/utils/format_validator.py +206 -0
  144. package/mcp_servers/openscad-mcp-server/legacy/src/utils/stl_exporter.py +140 -0
  145. package/mcp_servers/openscad-mcp-server/legacy/src/utils/stl_repair.py +91 -0
  146. package/mcp_servers/openscad-mcp-server/legacy/src/utils/stl_validator.py +123 -0
  147. package/mcp_servers/openscad-mcp-server/legacy/src/visualization/__init__.py +0 -0
  148. package/mcp_servers/openscad-mcp-server/legacy/src/visualization/headless_renderer.py +52 -0
  149. package/mcp_servers/openscad-mcp-server/legacy/src/visualization/renderer.py +177 -0
  150. package/mcp_servers/openscad-mcp-server/legacy/src/visualization/web_interface.py +639 -0
  151. package/mcp_servers/openscad-mcp-server/legacy/src/workflow/image_approval.py +148 -0
  152. package/mcp_servers/openscad-mcp-server/legacy/src/workflow/multi_view_to_model_pipeline.py +338 -0
  153. package/mcp_servers/openscad-mcp-server/legacy/test_complete_workflow.py +374 -0
  154. package/mcp_servers/openscad-mcp-server/legacy/test_cuda_mvs.py +191 -0
  155. package/mcp_servers/openscad-mcp-server/legacy/test_gemini_api.py +168 -0
  156. package/mcp_servers/openscad-mcp-server/legacy/test_image_approval.py +192 -0
  157. package/mcp_servers/openscad-mcp-server/legacy/test_image_approval_workflow.py +251 -0
  158. package/mcp_servers/openscad-mcp-server/legacy/test_image_to_model_pipeline.py +145 -0
  159. package/mcp_servers/openscad-mcp-server/legacy/test_model_selection.py +41 -0
  160. package/mcp_servers/openscad-mcp-server/legacy/test_multi_view_pipeline.py +290 -0
  161. package/mcp_servers/openscad-mcp-server/legacy/test_primitives.sh +13 -0
  162. package/mcp_servers/openscad-mcp-server/legacy/test_rabbit_direct.py +71 -0
  163. package/mcp_servers/openscad-mcp-server/legacy/test_remote_cuda_mvs.py +283 -0
  164. package/mcp_servers/openscad-mcp-server/legacy/test_venice_example.py +69 -0
  165. package/mcp_servers/openscad-mcp-server/pyproject.toml +33 -0
  166. package/mcp_servers/openscad-mcp-server/requirements.txt +2 -0
  167. package/mcp_servers/openscad-mcp-server/scad/simple_cube.scad +2 -0
  168. package/mcp_servers/openscad-mcp-server/scripts/test_docker.py +220 -0
  169. package/mcp_servers/openscad-mcp-server/src/openscad_mcp/__init__.py +3 -0
  170. package/mcp_servers/openscad-mcp-server/src/openscad_mcp/__main__.py +3 -0
  171. package/mcp_servers/openscad-mcp-server/src/openscad_mcp/engine.py +94 -0
  172. package/mcp_servers/openscad-mcp-server/src/openscad_mcp/geometry.py +242 -0
  173. package/mcp_servers/openscad-mcp-server/src/openscad_mcp/server.py +245 -0
  174. package/mcp_servers/openscad-mcp-server/src/openscad_mcp/service.py +190 -0
  175. package/mcp_servers/openscad-mcp-server/tests/conftest.py +17 -0
  176. package/mcp_servers/openscad-mcp-server/tests/test_engine.py +37 -0
  177. package/mcp_servers/openscad-mcp-server/tests/test_geometry.py +106 -0
  178. package/mcp_servers/openscad-mcp-server/tests/test_integration.py +172 -0
  179. package/mcp_servers/openscad-mcp-server/tests/test_transports.py +314 -0
  180. package/mcp_servers/openscad-mcp-server/uv.lock +1123 -0
  181. package/package.json +44 -0
  182. package/scripts/install_mcps.sh +86 -0
  183. package/scripts/openscad_wrapper.sh +62 -0
  184. package/scripts/run_kicad_mcp.sh +25 -0
  185. package/scripts/run_openscad_mcp.sh +41 -0
  186. package/scripts/test_mcp_connection.py +626 -0
  187. package/scripts/test_mcp_connection.sh +168 -0
  188. package/skills/code-first-hardware-design/SKILL.md +260 -0
  189. package/skills/pcb-constraint-definition/SKILL.md +236 -0
  190. package/skills/pcb-layout-routing-automation/SKILL.md +153 -0
  191. package/skills/pcb-validation-dfm-signoff/SKILL.md +194 -0
  192. package/skills/schematic-datasheet-analysis/SKILL.md +202 -0
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # BDB Hardware & PCB
2
+
3
+ `@hybridlabor-api/bdb-hardware-pcb` — Electrical Engineering, PCB Design, and 3D
4
+ Mechanical Enclosure tooling for AI coding agents: 5 skills plus two MCP
5
+ servers (KiCad, OpenSCAD) exposing 55 tools over stdio JSON-RPC.
6
+
7
+ Supports **KiCad 9 & 10** automation and **OpenSCAD** parametric enclosures
8
+ across **Anthropic Claude Code**, **OpenAI Codex**, and **Google Antigravity
9
+ (Gemini)**.
10
+
11
+ ---
12
+
13
+ ## Install
14
+
15
+ ### Option A — as part of AOS
16
+
17
+ If you already use `@hybridlabor-api/bdb-dev-optimized-agent-skills` (AOS),
18
+ its installer offers this package as an optional module (same mechanism as
19
+ `bdb-synapse` / `bdb-dev-creator-extension`): AOS downloads this package and
20
+ runs its `installer.js --auto` for you. No separate step needed.
21
+
22
+ ### Option B — standalone
23
+
24
+ ```bash
25
+ npx @hybridlabor-api/bdb-hardware-pcb
26
+ ```
27
+
28
+ This runs `installer.js` directly, non-interactively, on macOS, Linux, or
29
+ Windows. It will:
30
+
31
+ 1. Set up the `kicad-mcp-server` and `openscad-mcp-server` Python virtual
32
+ environments (via `uv sync` if `uv` is on `PATH`, otherwise
33
+ `python3`/`python -m venv` + `pip install -e .`).
34
+ 2. Detect which harnesses are present on this machine (`~/.claude`,
35
+ `~/.codex`, `~/.gemini`, `~/.agents`) and, for each one found:
36
+ - copy the 5 skill directories into its skills folder,
37
+ - merge the `kicad` and `openscad` MCP server entries into its real MCP
38
+ config file (without touching any other entries already there).
39
+
40
+ Every step prints one line saying what it actually did, or why it was
41
+ skipped. Nothing is silently a no-op.
42
+
43
+ Re-run the installer any time (e.g. after moving/reinstalling this package)
44
+ to refresh the registered paths — it is idempotent and self-healing: it
45
+ rewrites stale `command` paths in place rather than leaving them broken.
46
+
47
+ ---
48
+
49
+ ## Verify
50
+
51
+ ```bash
52
+ ./scripts/test_mcp_connection.sh --all
53
+ ```
54
+
55
+ Spawns both MCP servers over real stdio, performs the JSON-RPC `initialize`
56
+ handshake, lists tools, and validates every tool's schema — 47 tools from
57
+ KiCad + 8 from OpenSCAD = **55 tools**, exit code 0 on success.
58
+
59
+ Read [`HANDOFF_REVIEW.md`](HANDOFF_REVIEW.md) for the detailed verification
60
+ dossier, and
61
+ [`docs/adr/ADR-001-KICAD-OPENSCAD-MCP-STRATEGY.md`](docs/adr/ADR-001-KICAD-OPENSCAD-MCP-STRATEGY.md)
62
+ for the architecture decision record behind the KiCad/OpenSCAD MCP choice.
63
+
64
+ ---
65
+
66
+ ## The 5 skills
67
+
68
+ 1. [`code-first-hardware-design`](skills/code-first-hardware-design/SKILL.md) — programmatic schematics via SKiDL, OpenSCAD parametric enclosures, text-based netlists.
69
+ 2. [`pcb-constraint-definition`](skills/pcb-constraint-definition/SKILL.md) — differential impedance, high-voltage creepage/clearance, return-path routing.
70
+ 3. [`schematic-datasheet-analysis`](skills/schematic-datasheet-analysis/SKILL.md) — automated PDF datasheet parsing, pinmux validation, decoupling networks.
71
+ 4. [`pcb-layout-routing-automation`](skills/pcb-layout-routing-automation/SKILL.md) — stackup configuration, placement heuristics, auto-routing via CLI.
72
+ 5. [`pcb-validation-dfm-signoff`](skills/pcb-validation-dfm-signoff/SKILL.md) — automated ERC/DRC execution, SI/PI integrity audits, DFM manufacturing constraints.
73
+
74
+ ## MCP servers
75
+
76
+ - **KiCad MCP Server** (`mcp_servers/kicad-mcp-server`, upstream: [Seeed-Studio/kicad-mcp-server](https://github.com/Seeed-Studio/kicad-mcp-server)) — 47 tools: schematic capture, netlist generation, pinmux analysis, ERC, DRC, 3D rendering.
77
+ - **OpenSCAD MCP Server** (`mcp_servers/openscad-mcp-server`, upstream: [jhacksman/OpenSCAD-MCP-Server](https://github.com/jhacksman/OpenSCAD-MCP-Server)) — 8 tools: parametric 3D enclosure modeling, STL export, multi-view PNG rendering.
78
+
79
+ Both are third-party Python MCP servers vendored under `mcp_servers/`; their
80
+ `.venv/` is created fresh at install time and is never shipped in the npm
81
+ package.
82
+
83
+ ---
84
+
85
+ ## Repository layout
86
+
87
+ ```
88
+ bdb-hardware-pcb/
89
+ ├── installer.js # cross-platform installer (npx entry point / AOS module)
90
+ ├── config/mcp/ # reference-only MCP config templates (placeholder paths;
91
+ │ # installer.js generates the real, machine-specific config)
92
+ ├── docs/adr/ # architectural decision records (ADR-001)
93
+ ├── mcp_servers/
94
+ │ ├── kicad-mcp-server # vendored Python MCP server (KiCad)
95
+ │ └── openscad-mcp-server # vendored Python MCP server (OpenSCAD)
96
+ ├── scripts/
97
+ │ ├── test_mcp_connection.py # zero-dependency stdlib JSON-RPC tester
98
+ │ ├── test_mcp_connection.sh # multi-harness test runner
99
+ │ ├── run_kicad_mcp.sh # self-locating KiCad MCP launcher
100
+ │ ├── run_openscad_mcp.sh # self-locating OpenSCAD MCP launcher
101
+ │ ├── openscad_wrapper.sh # macOS / Linux OpenSCAD binary shim
102
+ │ └── install_mcps.sh # legacy bash-only venv setup (macOS/Linux only —
103
+ │ # installer.js is the cross-platform replacement)
104
+ ├── skills/ # the 5 skills above
105
+ ├── HANDOFF_REVIEW.md # verification dossier
106
+ └── README.md
107
+ ```
108
+
109
+ ## Notes on portability
110
+
111
+ `config/mcp/*.json` and `config/mcp/codex.toml` are reference templates only
112
+ — they contain the placeholder `__INSTALL_DIR__`, never a real machine path,
113
+ and are not read by `installer.js` at install time (it generates configs
114
+ dynamically from `os.homedir()` and its own install directory). They are
115
+ resolved to a real path only by `scripts/test_mcp_connection.sh`, for local
116
+ verification.
@@ -0,0 +1,22 @@
1
+ {
2
+ "_comment": "Reference template only. installer.js generates the real, machine-specific config at install time (see mcpServerEntries() & installIntoHarness() in ../../installer.js) — nothing reads this file at runtime. __INSTALL_DIR__ below is a placeholder for wherever this package is actually installed; it is substituted only by scripts/test_mcp_connection.sh for local verification.",
3
+ "mcpServers": {
4
+ "kicad": {
5
+ "command": "__INSTALL_DIR__/scripts/run_kicad_mcp.sh",
6
+ "args": [],
7
+ "env": {
8
+ "KICAD_CLI_PATH": "/Applications/KiCad/KiCad.app/Contents/MacOS/kicad-cli"
9
+ }
10
+ },
11
+ "openscad": {
12
+ "command": "__INSTALL_DIR__/scripts/run_openscad_mcp.sh",
13
+ "args": [
14
+ "--transport",
15
+ "stdio"
16
+ ],
17
+ "env": {
18
+ "OPENSCAD_EXECUTABLE": "__INSTALL_DIR__/scripts/openscad_wrapper.sh"
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "_comment": "Reference template only. installer.js generates the real, machine-specific config at install time (see mcpServerEntries() & installIntoHarness() in ../../installer.js) — nothing reads this file at runtime. __INSTALL_DIR__ below is a placeholder for wherever this package is actually installed; it is substituted only by scripts/test_mcp_connection.sh for local verification.",
3
+ "mcpServers": {
4
+ "kicad": {
5
+ "command": "__INSTALL_DIR__/scripts/run_kicad_mcp.sh",
6
+ "args": [],
7
+ "env": {
8
+ "KICAD_CLI_PATH": "/Applications/KiCad/KiCad.app/Contents/MacOS/kicad-cli"
9
+ }
10
+ },
11
+ "openscad": {
12
+ "command": "__INSTALL_DIR__/scripts/run_openscad_mcp.sh",
13
+ "args": [
14
+ "--transport",
15
+ "stdio"
16
+ ],
17
+ "env": {
18
+ "OPENSCAD_EXECUTABLE": "__INSTALL_DIR__/scripts/openscad_wrapper.sh"
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,25 @@
1
+ # ==============================================================================
2
+ # OpenAI Codex MCP Server Configuration - Hardware & PCB Tools
3
+ # ==============================================================================
4
+ # Reference template only. installer.js generates the real, machine-specific
5
+ # config at install time (see registerMcpServers() in ../../installer.js) --
6
+ # nothing reads this file at runtime. __INSTALL_DIR__ below is a placeholder
7
+ # for wherever this package is actually installed; it is substituted only by
8
+ # scripts/test_mcp_connection.sh for local verification.
9
+ # ==============================================================================
10
+
11
+ [mcp_servers.kicad]
12
+ command = "__INSTALL_DIR__/scripts/run_kicad_mcp.sh"
13
+ args = []
14
+ enabled = true
15
+
16
+ [mcp_servers.kicad.env]
17
+ KICAD_CLI_PATH = "/Applications/KiCad/KiCad.app/Contents/MacOS/kicad-cli"
18
+
19
+ [mcp_servers.openscad]
20
+ command = "__INSTALL_DIR__/scripts/run_openscad_mcp.sh"
21
+ args = ["--transport", "stdio"]
22
+ enabled = true
23
+
24
+ [mcp_servers.openscad.env]
25
+ OPENSCAD_EXECUTABLE = "__INSTALL_DIR__/scripts/openscad_wrapper.sh"
@@ -0,0 +1,334 @@
1
+ # ADR-001: KiCad 9/10 & OpenSCAD MCP Integration and AI Hardware Automation Strategy
2
+
3
+ - **Status**: RATIFIED
4
+ - **Date**: 2026-09-14
5
+ - **Authors**: BDB Agent OS Core Architecture Team (Worker 1)
6
+ - **Target Systems**: BDB Agent OS (AOS), Antigravity (Gemini CLI), Claude Code, OpenAI Codex
7
+ - **Deciders**: Architect, TechLead, Reviewer, Shipping
8
+ - **References**:
9
+ - `https://github.com/mixelpixx/Konnect`
10
+ - `https://github.com/mixelpixx/KiCAD-MCP-Server`
11
+ - `https://github.com/Seeed-Studio/kicad-mcp-server`
12
+ - `https://github.com/aklofas/kicad-happy`
13
+ - `https://github.com/jhacksman/OpenSCAD-MCP-Server`
14
+ - `https://github.com/archimedes-market/mcp-openscad-render-loop`
15
+ - `https://github.com/petrijr/openscad-mcp`
16
+
17
+ ---
18
+
19
+ ## 1. Context and Problem Statement
20
+
21
+ Hardware engineering and printed circuit board (PCB) design have historically resisted AI automation due to:
22
+ 1. **Monolithic, GUI-Centric Workflows**: Traditional electronic design automation (EDA) tools rely heavily on interactive graphical mouse input and proprietary binary or poorly specified text formats.
23
+ 2. **Fragile In-Process Scripting Bindings**: Legacy scripting in KiCad (v5–v8) depended on SWIG-generated C++ bindings (`pcbnew.so`) that suffer from severe memory safety issues (such as C++ object destructors executing out of sync with Python garbage collection, leading to segmentation faults), lack schematic authoring APIs, and demand tight coupling to platform-specific Python runtimes.
24
+ 3. **Severe LLM Context Window Overhead**: Exposing full EDA tool suites via the Model Context Protocol (MCP) frequently dumps 200+ tool definitions into the prompt, consuming 20,000 to 25,000 tokens *per conversation turn* before any domain reasoning begins.
25
+ 4. **Mechanical & Thermal Decoupling**: Enclosure design is traditionally isolated from PCB layout, leading to manual dimension transcriptions, clearance mismatches, and standoff misalignments.
26
+ 5. **Lack of Grounded Electrical Reasoning ("AI Slop")**: Naive LLM agents emit syntactically plausible circuits with invalid component ratings, floating high-impedance CMOS pins, missing bypass capacitors, acid traps, and return paths crossing plane splits.
27
+
28
+ To establish an autonomous, production-grade hardware engineering capability inside the BDB Agent OS (AOS) ecosystem across all target harnesses (**Google Antigravity**, **Anthropic Claude Code**, and **OpenAI Codex**), we must select and integrate an optimal constellation of MCP servers, headless CLI engines, and domain intelligence frameworks.
29
+
30
+ ---
31
+
32
+ ## 2. Decision Drivers
33
+
34
+ - **Memory Safety and Stability**: Elimination of in-process C++ crashes and cross-runtime desynchronization.
35
+ - **Support for KiCad 9.0 and 10.0 Roadmap**: Alignment with KiCad's official out-of-process IPC API (Protocol Buffers over Nanomsg Next Generation - NNG) and headless `kicad-cli`.
36
+ - **Context Window Economics**: Protection of agent reasoning budgets via tiered starter kits and on-demand toolset activation.
37
+ - **Git-Native / Repository-Bound State**: All generated hardware artifacts (`.kicad_sch`, `.kicad_pcb`, `.scad`, `.stl`, Gerbers) must reside directly in the project workspace, not in opaque hidden local directories.
38
+ - **Deterministic Verification Gates**: Unforgiving automated checks (ERC, DRC, DFM) driven by CLI exit codes rather than subjective LLM self-assessments.
39
+ - **Multi-Harness Compatibility**: Unified operation across Antigravity, Claude Code, and Codex with zero external packaging friction on Apple Silicon macOS and Linux.
40
+
41
+ ---
42
+
43
+ ## 3. Comprehensive Evaluation of KiCad Tooling Options
44
+
45
+ We evaluated four primary tools and MCP server candidates for KiCad integration:
46
+
47
+ ### 3.1 `mixelpixx/KiCAD-MCP-Server` (v2.x)
48
+ - **Architecture**: Dual-runtime hybrid. A Node.js/TypeScript frontend implements the MCP stdio protocol and orchestrates a Python 3.10+ backend via child-process stdio RPC (`LLM -> TypeScript MCP -> Python Bridge -> SWIG/IPC -> KiCad`).
49
+ - **Interaction Mechanisms**:
50
+ - *PCB*: Legacy SWIG bindings to `pcbnew`.
51
+ - *Schematic*: S-expression regex search-and-replace using `kicad-skip`.
52
+ - *Export*: Subprocess calls to `kicad-cli`.
53
+ - *Autorouting*: Freerouting Java bridge.
54
+ - **Tool Surface**: 233 tools registered (173 indexed across 16 categories) plus 23 dynamic resources.
55
+ - **Identified Failure Modes & Architectural Scars**:
56
+ - *SWIG Memory Corruption*: Documented in repository issue #362. Calling `BOARD.Remove()` hands C++ object ownership to Python; when Python drops the reference, it executes the C++ destructor on an object KiCad still references, causing process-wide memory corruption.
57
+ - *Multi-Runtime Friction on macOS*: Requires `setup-macos.sh` to link KiCad's bundled Python framework (`/Applications/KiCad/KiCad.app/Contents/Frameworks/python3`) with Node.js and handle System Integrity Protection (SIP) path restrictions.
58
+ - *Subprocess RPC Desync*: Documented in issue #373 where standard input/output desynchronization between Node.js and the Python child process causes dropped or misrouted JSON-RPC responses.
59
+ - *Context Budget Exhaustion*: Startup tool registration injects ~23,000 tokens of JSON schema into every turn.
60
+ - **Assessment**: **SUPERSEDED / DEPRECATED**. The repository author has officially transitioned development to `Konnect`.
61
+
62
+ ### 3.2 `Seeed-Studio/kicad-mcp-server`
63
+ - **Architecture**: Pure Python implementation built on `fastmcp` (`mcp[cli]>=1.27,<2.0`).
64
+ - **Interaction Mechanisms**:
65
+ - *Dual-Mode PCB Engine*: Recommended mode runs inside KiCad's bundled Python interpreter for native `pcbnew` track geometry and design rules; fallback mode runs in standard Python with text-based S-expression parsing of `.kicad_pcb`.
66
+ - *Schematic Engine*: Pure Python AST parser (`SchematicParser`) and paren-counting S-expression injector (`schematic_editor.py`) for placing components and routing wires.
67
+ - *Validation*: Subprocess execution of `kicad-cli sch erc` and `kicad-cli pcb drc`.
68
+ - **Tool Surface**: Focused set of ~25–30 tools covering schematic queries, component/wire placement, netlist tracing, hierarchical sheet traversal, and pinmux analysis.
69
+ - **Unique Capabilities**:
70
+ - *Embedded Linux Device Tree Generation*: Features an automated tool (`generate_device_tree`) that maps schematic pin assignments directly into Linux Device Tree (`.dts`) source code.
71
+ - *PartReel API Integration*: Direct access to 21,000+ verified open-source hardware components.
72
+ - **Assessment**: **ADOPTED AS SECONDARY / EMBEDDED UTILITY**. Excellent lightweight, single-language pure-Python tool for embedded Linux workflows and environments where native binary compilation is impossible.
73
+
74
+ ### 3.3 `mixelpixx/Konnect`
75
+ - **Architecture**: Purpose-built successor to `KiCAD-MCP-Server` for KiCad 10. Written in pure Rust (1.78+). Packaged as a single static binary (~20 MB) with zero runtime dependencies (no Node.js, Python, pip, or npm trees).
76
+ - **Interaction Mechanisms**:
77
+ - *Official KiCad 10 IPC API*: Native client for KiCad's Protobuf-over-NNG (Nanomsg Next Generation) socket interface (`KICAD_API_SOCKET`). Allows real-time, non-blocking PCB layout modifications integrated directly into KiCad's native Undo/Redo stack.
78
+ - *Native Rust S-Expression Engine*: Byte-for-byte fidelity S-expression parser and serializer for `.kicad_sch` with atomic transactional file updates (`write` -> `fsync` -> atomic `rename`), strict UUID preservation, and syntax versioning.
79
+ - *Routing Engine*: Native Rust Specctra `.dsn` export, integrated Freerouting invocation, and transactional `.ses` session import.
80
+ - *Exports*: Headless `kicad-cli` batch integration.
81
+ - **Tool Surface & Context Management**:
82
+ - Exposes 226 tools organized across 21 toolsets (`schematic_capture`, `pcb_layout`, `pcb_routing`, `design_rules`, `audits`, `jlcpcb`, `reference_circuits`, `manufacturing`, etc.).
83
+ - **Dynamic Tool Router**: Implements on-demand toolset loading. On startup, exposes a ~2,000-token starter kit with meta-tools (`enable_toolset`, `get_recent_calls`). Agents dynamically enable only the toolsets required for the active phase (e.g., `schematic_capture` in Phase 2, `manufacturing` in Phase 5), preserving 85–90% of the LLM context window.
84
+ - **Packaging**: Pre-compiled Universal binary (`macos-universal` for Apple Silicon arm64 and Intel x86_64). Drops into KiCad Plugin & Content Manager (PCM) or executes standalone via stdio/HTTP.
85
+ - **License**: AGPL-3.0 for open-source workflows.
86
+ - **Assessment**: **ADOPTED AS PRIMARY CAD MCP SERVER**. Solves memory corruption, runtime friction, and context exhaustion simultaneously.
87
+
88
+ ### 3.4 `aklofas/kicad-happy`
89
+ - **Architecture**: Electronics engineering intelligence, simulation, and audit suite. Implemented in pure Python 3.10+ using only Python Standard Library modules (zero third-party dependencies; optional `pymupdf` for PDF parsing).
90
+ - **Interaction Mechanisms**: Direct read-only AST parsing of `.kicad_sch`, `.kicad_pcb`, and Gerber files. Operates completely independently of running KiCad instances, `pcbnew`, or `kicad-cli`.
91
+ - **Domain Intelligence Capabilities (11 Specialized Skills)**:
92
+ - *Circuit Topology Detection*: Autonomously identifies subcircuits including buck/boost power stages, LDO regulators, feedback voltage dividers, RC low-pass/high-pass filters, crystal oscillators, and reset generators.
93
+ - *Automated SPICE Testbench Generation*: Translates detected subcircuits into complete, runnable SPICE netlists (ngspice, LTspice, Xyce) with automated Monte Carlo component tolerance sweeps ($\pm 1\%, \pm 5\%$).
94
+ - *44-Rule EMC Pre-Compliance Engine*: Performs physical audits across PCB copper: return path interruptions across plane splits, differential pair length skew ($< 0.1\text{mm}$), PDN high-frequency decoupling loop inductance, and chassis ground isolation.
95
+ - *Connector ESD Audit*: Verifies that external connectors (USB, HDMI, headers) have dedicated bidirectional TVS diode arrays located within 2mm of entry pins with low-inductance ground returns.
96
+ - *Component Sourcing*: Multi-vendor API querying (DigiKey, Mouser, LCSC, JLCPCB, PCBWay) for live pricing, stock validation, and lifecycle status.
97
+ - **Assessment**: **ADOPTED AS CORE DOMAIN INTELLIGENCE SUITE**. Fills the critical gap between mechanical CAD operations and electrical engineering reasoning.
98
+
99
+ ---
100
+
101
+ ## 4. Comprehensive Evaluation of OpenSCAD Tooling Options
102
+
103
+ We evaluated four MCP and code-first CAD options for parametric enclosure co-design:
104
+
105
+ ### 4.1 `jhacksman/OpenSCAD-MCP-Server` (v0.2.0)
106
+ - **Stack**: Python 3.11+ using `fastmcp`, `fastapi`, and `uvicorn`.
107
+ - **Mechanism**: Invokes headless OpenSCAD CLI (`subprocess.run`). Implements atomic file writes via temporary `.render-*` folders and detects assert errors via regex scanning of stderr/stdout.
108
+ - **Features**: Generates 3D models from built-in CSG primitive dictionaries; compiles custom SCAD code; renders 4 orthogonal/perspective PNG views (`perspective`, `front`, `top`, `right`).
109
+ - **Limitation**: Maintains an internal, stateful, hidden model repository (`~/.local/share/openscad-mcp/models/<id>/<rev>`), returning abstract model UUIDs. This decouples generated CAD models from the project's Git repository.
110
+
111
+ ### 4.2 `archimedes-market/mcp-openscad-render-loop`
112
+ - **Stack**: Pure Python FastMCP server.
113
+ - **Mechanism**: Headless OpenSCAD CLI integration designed specifically for iterative agent loops: edit parameters -> render -> compute metrics -> adjust.
114
+ - **Tools**:
115
+ - `validate_scad`: Fast syntax and parameter check via `openscad -o /dev/null --check-parameters true` without triggering full geometry generation.
116
+ - `render_stl`: Renders STL with native `-D key=val` parameter overrides.
117
+ - `render_png`: Renders camera-aligned preview PNGs (`iso`, `top`, `front`, `right`).
118
+ - `parametric_sweep`: Executes Cartesian sweeps across parameter ranges (up to 256 combinations) to test fit tolerances.
119
+ - `compute_metrics`: Uses `numpy-stl` to compute bounding box dimensions (`[dx, dy, dz]`), total volume ($\text{mm}^3$), surface area ($\text{mm}^2$), and triangle count directly into machine-readable JSON.
120
+ - **Assessment**: **ADOPTED AS PRIMARY OPENSCAD MCP SERVER**. Workspace-relative, stateless execution perfectly matches Git-based AOS workflows.
121
+
122
+ ### 4.3 `petrijr/openscad-mcp`
123
+ - **Stack**: Python 3.10+ standard MCP server.
124
+ - **Features**: Content-addressed cache (`OPENSCAD_MCP_CACHE_ROOT`), batch rendering, and inline Base64 `ImageContent` returns.
125
+ - **Assessment**: Strong secondary alternative; architecture verified.
126
+
127
+ ### 4.4 `fboldo/openscad-mcp-server`
128
+ - **Stack**: Node.js running `openscad-wasm`.
129
+ - **Assessment**: **REJECTED**. Severe performance degradation on complex geometry; lacks font rendering; cannot leverage the C++ Manifold geometry kernel.
130
+
131
+ ---
132
+
133
+ ## 5. Architectural Synthesis & Comparison Matrices
134
+
135
+ ### 5.1 KiCad Tooling Comparison Matrix
136
+
137
+ | Dimension | `mixelpixx/KiCAD-MCP-Server` | `Seeed-Studio/kicad-mcp-server` | `mixelpixx/Konnect` | `aklofas/kicad-happy` | `kicad-cli` |
138
+ |---|---|---|---|---|---|
139
+ | **Language & Runtime** | Node.js + Python 3.10+ | Pure Python 3.10+ (`fastmcp`) | Pure Rust 1.78+ (Single Binary) | Pure Python 3.10+ (Stdlib) | C++ Native CLI |
140
+ | **KiCad Connection** | Node stdio -> Python -> SWIG / IPC | Python `pcbnew` SWIG or S-exp text | Official KiCad 10 IPC (NNG/Protobuf) | File-based AST parser | Direct native CLI invocation |
141
+ | **KiCad 9 Support** | Full (SWIG + experimental IPC) | Full (SWIG + text fallback) | Limited (IPC schema changes) | Full (format agnostic) | Full (`kicad-cli` v9) |
142
+ | **KiCad 10 Support** | Partial (legacy bugfixes) | Full (supported via SWIG/CLI) | **Native / Primary Target** | **Full (format agnostic)** | **Native (`kicad-cli` v10)** |
143
+ | **Tool Count** | 233 tools | ~25–30 tools | 226 tools across 21 toolsets | 11 specialized skills | 8 primary CLI subcommands |
144
+ | **Context Overhead** | High (~23,000 tokens) | Low (~3,500 tokens) | **Optimized (~2,000 token starter kit)** | **Negligible (Skill on-demand)** | 0 tokens (CLI execution) |
145
+ | **Schematic Editing** | Regex / paren-matching text | Pure Python S-exp injection | **Native Rust S-exp AST (atomic writes)** | Read-only analysis | Export & ERC only |
146
+ | **PCB Real-time Sync** | Flaky (SWIG crashes, IPC early) | No (file-based or in-process) | **Yes (Full IPC + native Undo/Redo)** | No (offline analyzer) | No (batch processing) |
147
+ | **Electrical Intelligence**| Basic net traversal | Pinmux & Linux DTS generation | Decoupling & rail audits | **Deep (Power trees, SPICE, 44 EMC rules)** | DRC/ERC violations only |
148
+ | **Packaging Friction** | High (`setup-macos.sh`, SIP) | Medium (`pip install -e .`) | **Zero (Universal binary in PATH)** | **Zero (Standard Library only)** | High (Requires KiCad cask) |
149
+ | **License** | MIT | MIT | AGPL-3.0 | MIT | GPL-3.0 |
150
+ | **AOS Role** | *Deprecated* | *Secondary (Device Trees)* | **Primary CAD MCP Server** | **Core Intelligence & Review Suite** | **Headless CI/CD Hard Gate** |
151
+
152
+ ### 5.2 OpenSCAD Tooling Comparison Matrix
153
+
154
+ | Dimension | `jhacksman/OpenSCAD-MCP-Server` | `archimedes-market/mcp-openscad-render-loop` | `petrijr/openscad-mcp` | `fboldo/openscad-mcp-server` |
155
+ |---|---|---|---|---|
156
+ | **Runtime** | Python 3.11+ (`fastmcp`, `uvicorn`) | Python 3.10+ (`fastmcp`) | Python 3.10+ (`mcp`) | Node.js / Bun (`npx`) |
157
+ | **Execution Engine** | Native OpenSCAD CLI | Native OpenSCAD CLI | Native OpenSCAD CLI | WASM in JS runtime |
158
+ | **State Paradigm** | Stateful UUID store in `~/.local/` | **Stateless / Workspace-relative** | Stateless + SHA256 cache | Stateless in-memory |
159
+ | **Syntax Check** | Full render only | Fast check (`-o /dev/null --check-parameters`)| Compiler diagnostics | Failed render error |
160
+ | **Parametric Overrides** | Hardcoded SCAD edits | Native `-D key=val` injection | Native `-D key=val` injection | String replacement |
161
+ | **Physical Metrics** | None | **`compute_metrics` (bbox, volume, triangles)**| Metadata inspection | None |
162
+ | **Multi-View Previews** | Automatic 4 PNGs | Configurable single view PNG | Configurable single view PNG | Single view PNG |
163
+ | **AOS Role** | *Reference / Fallback* | **Primary OpenSCAD MCP Server** | *Secondary Alternative* | *Rejected (Slow WASM)* |
164
+
165
+ ---
166
+
167
+ ## 6. KiCad 9 and 10 Architectural Evolution: SWIG vs IPC vs CLI
168
+
169
+ The transition from KiCad 8 through 9 to 10 marks a fundamental architectural shift in how automated agents interact with EDA software:
170
+
171
+ ```
172
+ +---------------------------------------------------------------------------------------------+
173
+ | KICAD SCRIPTING EVOLUTION |
174
+ +---------------------------------------------------------------------------------------------+
175
+ | KiCad 8.x and earlier: |
176
+ | Agent -> Python Process -> SWIG In-Process C++ Bindings (pcbnew.so) -> PCB Memory Space |
177
+ | * CRITICAL FLAWS: No schematic API; SWIG memory desync segfaults; thread-unsafe. |
178
+ +---------------------------------------------------------------------------------------------+
179
+ | KiCad 9.0 (Transition Phase): |
180
+ | - SWIG deprecated; early IPC daemon introduced over UNIX sockets for PCB Editor. |
181
+ | - kicad-cli expanded with JSON formatting for ERC and DRC reports. |
182
+ +---------------------------------------------------------------------------------------------+
183
+ | KiCad 10.0 (Modern Architecture): |
184
+ | - Official IPC API: Protocol Buffers over Nanomsg Next Generation (NNG). |
185
+ | - Out-of-process, thread-safe, non-blocking requests mapped to native Undo/Redo stack. |
186
+ | - Direct IPC hooks for both Schematic and PCB Editors. |
187
+ | - kicad-cli v10 adds .kicad_jobset batch execution and enhanced custom rule evaluation. |
188
+ +---------------------------------------------------------------------------------------------+
189
+ ```
190
+
191
+ ### 6.1 Why SWIG is Obsolete for AI Agents
192
+ 1. **Destructor Race Conditions**: In-process Python bindings allow Python's garbage collector to destroy underlying C++ pointer objects while KiCad's internal viewport or connectivity graph still references them, triggering instant `SIGSEGV` aborts.
193
+ 2. **Lack of Schematic API**: SWIG bindings were historically compiled exclusively for `pcbnew`. Automated schematic authoring via SWIG is impossible, forcing reliance on brittle regex injection.
194
+ 3. **Interpreter Lock-In**: Under macOS, SWIG binaries must match the exact Python dynamic library (`libpython3.x.dylib`) compiled into the KiCad application bundle, breaking standard virtual environments.
195
+
196
+ ### 6.2 The KiCad 10 IPC Architecture (NNG + Protobuf)
197
+ KiCad 10 standardizes on an external IPC daemon communicating over local UNIX domain sockets (`/tmp/kicad_api.sock` or `KICAD_API_SOCKET` environment variable) or Windows named pipes. Requests and responses are strongly typed using Google Protocol Buffers.
198
+ - **Benefits for Agents**:
199
+ - The agent runs in an isolated process (Rust, Python, or Go) with zero risk of crashing the CAD core.
200
+ - Modifications are transacted through KiCad's command manager, preserving the interactive Undo/Redo stack so human engineers can review agent actions step-by-step.
201
+ - Headless execution can run against a virtual frame buffer (`xvfb-run` on Linux) or headless IPC server.
202
+
203
+ ### 6.3 The Deterministic Headless CLI (`kicad-cli`)
204
+ For automated CI/CD and release gating, interactive IPC is replaced by `kicad-cli`. It operates directly on files, requires no running GUI or socket, and produces deterministic exit codes:
205
+ - `kicad-cli sch erc --exit-code-violations project.kicad_sch`: Returns `0` if clean; returns `1` if electrical rule violations exist.
206
+ - `kicad-cli pcb drc --exit-code-violations --format json -o drc_report.json board.kicad_pcb`: Emits structured JSON diagnostics.
207
+ - `kicad-cli jobset run manufacturing.kicad_jobset`: Atomically produces Gerbers, drill files, BOMs, and STEP models in a single headless pass.
208
+
209
+ ---
210
+
211
+ ## 7. OpenSCAD Engine Acceleration & Host Packaging
212
+
213
+ ### 7.1 The Manifold Geometry Engine
214
+ Legacy OpenSCAD releases used CGAL for Constructive Solid Geometry (CSG) booleans. On intricate enclosure designs containing dozens of USB/connector cutouts, screw threads, and ventilation grilles, CGAL frequently stalls for minutes or hits CPU timeouts.
215
+ Modern OpenSCAD (snapshots 2024–2026) incorporates the **Manifold** geometry kernel:
216
+ - Achieves **10x to 100x rendering acceleration**.
217
+ - Guarantees 2-manifold output (water-tight meshes essential for 3D printing slicing and collision analysis).
218
+ - Enabled via the command-line flag: `--backend=Manifold`.
219
+
220
+ ### 7.2 macOS Packaging & Gatekeeper Resolution
221
+ On macOS host systems:
222
+ - Standard Homebrew `brew install --cask openscad` points to the stale 2021.01 release, which was **disabled by Homebrew maintainers on 2026-09-01** due to macOS Gatekeeper quarantine verification failures.
223
+ - **Mandatory Installation Directive**:
224
+ ```bash
225
+ brew install --cask openscad@snapshot
226
+ ```
227
+ This installs the modern, signed snapshot build containing the Manifold backend, located at `/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD`.
228
+
229
+ ### 7.3 BOSL2 Parametric Enclosure Standard
230
+ To eliminate the extreme computational cost of OpenSCAD's naive `minkowski()` sums, the AOS enclosure design pipeline mandates the **BOSL2** (Belfry OpenSCAD Library v2) framework:
231
+ - Uses analytical rounded geometry: `cuboid([w, d, h], rounding=2, edges="Z")`.
232
+ - Native mounting bosses with heat-set brass insert pockets:
233
+ * M2: $3.2\text{mm}$ hole diameter, $4.0\text{mm}$ depth, $\ge 1.5\text{mm}$ wall thickness.
234
+ * M3: $4.0\text{mm}$ hole diameter, $5.7\text{mm}$ depth, $\ge 1.8\text{mm}$ wall thickness.
235
+ - Automated board collision checking via `%import("board.stl")` background visualization.
236
+
237
+ ---
238
+
239
+ ## 8. Multi-Agent Pipeline Mapping Across AOS Phases (`/startcycle`)
240
+
241
+ The recommended tooling maps directly into the 5 distinct phases of the AOS multi-agent lifecycle:
242
+
243
+ ```
244
+ ====================================================================================================
245
+ PHASE 1: ARCHITECT & SYSTEM PLANNING
246
+ --------------------------------------------------------------------------------------------------
247
+ Agents: Architect, TechLead
248
+ Primary Skills: pcb-constraint-definition, kicad-happy:datasheets, kicad-happy:bom
249
+ Tooling: Konnect (reference_circuits, jlcpcb toolsets)
250
+ Responsibilities:
251
+ 1. Translate product spec into formal `constraints.yaml` and `.kicad_dru` custom rules.
252
+ 2. Select layer stackup (e.g. 4-Layer JLC04161H-7628) and target impedances (50Ω single, 90Ω diff).
253
+ 3. Source verified, in-stock active components using JLCPCB / LCSC / DigiKey APIs.
254
+ ====================================================================================================
255
+ |
256
+ v
257
+ ====================================================================================================
258
+ PHASE 2: CODE-FIRST HARDWARE & CIRCUIT SYNTHESIS
259
+ --------------------------------------------------------------------------------------------------
260
+ Agents: Godmode_Engineering, Godmode_Media_EventTech
261
+ Primary Skills: code-first-hardware-design, schematic-datasheet-analysis
262
+ Tooling: SKiDL (Python), Konnect (schematic_capture), Seeed (device_tree), OpenSCAD + BOSL2
263
+ Responsibilities:
264
+ 1. Synthesize schematic netlist programmatically via SKiDL or atomic S-expression placement.
265
+ 2. Extract PCB board outline (`Edge.Cuts`) and mounting hole centroid CSV.
266
+ 3. Generate parametric 3D printed enclosure (`enclosure.scad`) with BOSL2 snap-fits and standoffs.
267
+ 4. If embedded Linux target, generate Device Tree source (`.dts`) from pin assignments.
268
+ ====================================================================================================
269
+ |
270
+ v
271
+ ====================================================================================================
272
+ PHASE 3: PCB LAYOUT & ROUTING AUTOMATION
273
+ --------------------------------------------------------------------------------------------------
274
+ Agents: Godmode_Engineering
275
+ Primary Skills: pcb-layout-routing-automation
276
+ Tooling: Konnect (pcb_layout, pcb_routing), Freerouting (Specctra DSN/SES)
277
+ Responsibilities:
278
+ 1. Execute floorplanning: decouple IC pins within 1.5mm, cluster power stages, isolate analog.
279
+ 2. Enforce 45-degree trace routing and constant differential pair spacing ($W/S$).
280
+ 3. Execute automated routing pass via Specctra DSN/SES Freerouting bridge.
281
+ 4. Flood continuous ground reference planes and drop perimeter stitching via fences.
282
+ ====================================================================================================
283
+ |
284
+ v
285
+ ====================================================================================================
286
+ PHASE 4: ADVERSARIAL ELECTRICAL & MECHANICAL REVIEW
287
+ --------------------------------------------------------------------------------------------------
288
+ Agents: Reviewer (Adversarial Doubt-Driven Review)
289
+ Primary Skills: schematic-datasheet-analysis, kicad-happy (kicad, spice, emc), mcp-openscad-render-loop
290
+ Tooling: kicad-happy (44 EMC rules, ngspice testbenches), OpenSCAD (compute_metrics, render_png)
291
+ Responsibilities:
292
+ 1. Grounded datasheet audit: verify every pin rating, voltage threshold, and pull-up resistor.
293
+ 2. Negative evidence analysis: detect floating CMOS inputs and unvalidated DNP components.
294
+ 3. Run automated SPICE simulation on feedback dividers, filters, and power supplies.
295
+ 4. Run 44-rule EMC pre-compliance audit (return paths over plane splits, diff skew < 0.1mm).
296
+ 5. Verify mechanical enclosure clearances and render 4-view PNG verification collage.
297
+ ====================================================================================================
298
+ |
299
+ v
300
+ ====================================================================================================
301
+ PHASE 5: FABRICATION RELEASE GATE & DFM SIGNOFF
302
+ --------------------------------------------------------------------------------------------------
303
+ Agents: Godmode_Shipping
304
+ Primary Skills: pcb-validation-dfm-signoff
305
+ Tooling: kicad-cli (sch erc, pcb drc, jobset run), OpenSCAD (export_model STL/3MF)
306
+ Responsibilities:
307
+ 1. Execute headless DRC/ERC hard gate: zero tolerance for errors (`--exit-code-violations`).
308
+ 2. Audit fab-house DFM specs: min trace/space (5/5 mil), drill (0.2mm), solder mask dam (0.1mm).
309
+ 3. Verify SMT assembly fiducials (3 non-collinear markers) and pin-1 orientation indicators.
310
+ 4. Generate production release package: Gerbers (RS-274X/X2), Excellon drill, CPL/Centroid, BOM.
311
+ 5. Sign off and publish `DFM_SIGNOFF_REPORT.md` and `production_artifacts/release.zip`.
312
+ ====================================================================================================
313
+ ```
314
+
315
+ ---
316
+
317
+ ## 9. Final Recommendations & Implementation Directives
318
+
319
+ 1. **Primary KiCad CAD Server**: Standardize on **`mixelpixx/Konnect`** running as a native Rust static binary over stdio.
320
+ 2. **Core Electrical Review & Simulation Suite**: Standardize on **`aklofas/kicad-happy`** (pure Python, zero dependencies) for all circuit topology tracing, SPICE testbench generation, and 44-rule EMC pre-compliance audits.
321
+ 3. **Headless Verification Gate**: Mandate **`kicad-cli` (v10)** for automated DRC/ERC release gates and manufacturing exports.
322
+ 4. **Primary OpenSCAD MCP Server**: Standardize on **`archimedes-market/mcp-openscad-render-loop`** (stateless, workspace-relative, exposing `validate_scad`, `render_stl`, `render_png`, and `compute_metrics`).
323
+ 5. **OpenSCAD Host Runtime**: Mandate **`brew install --cask openscad@snapshot`** with the **`--backend=Manifold`** flag configured for high-speed 3D rendering.
324
+ 6. **Skills Suite**: Deploy the 5 comprehensive, non-slop AI-era PCB skills under `skills/` and mirror them to `~/.agents/skills/` for universal discovery across Antigravity, Claude Code, and Codex.
325
+
326
+ ---
327
+
328
+ ## 10. Invalidation Conditions
329
+
330
+ This architectural decision record shall be formally reviewed and revised if:
331
+ 1. KiCad upstream alters or deprecates the Nanomsg Next Generation (NNG) / Protobuf IPC transport.
332
+ 2. An upstream license change restricts AGPL-3.0 in proprietary commercial client deployments (in which case `Seeed-Studio/kicad-mcp-server` under MIT will be elevated to primary CAD server).
333
+ 3. OpenSCAD introduces a native, reliable STEP B-Rep export kernel, eliminating the CSG/B-Rep boundary.
334
+ 4. A unified single MCP server emerges that combines native KiCad 10 IPC editing, SPICE simulation, and 44-rule EMC analysis in a single memory-safe binary.