This commit fixes the critical bug where the MCP server fails to start on
Linux with "Python executable not found: python3" even when python3 is
correctly installed and available in PATH.
Root Cause:
- findPythonExecutable() returned 'python3' (command name) on Linux
- validatePrerequisites() used existsSync('python3') which checks current
directory, not PATH
- Validation failed even though spawn() would resolve 'python3' via PATH
Changes Made:
1. Enhanced findPythonExecutable() for Linux (src/server.ts:42-126):
- Added Linux platform detection
- Check KiCad bundled Python paths first (/usr/lib/kicad/bin/python3, etc.)
- Use 'which python3' to resolve system python3 to absolute path
- Fallback to common system paths (/usr/bin/python3, /bin/python3)
- Import execSync for 'which' command execution
2. Improved validatePrerequisites() (src/server.ts:214-266):
- Distinguish between absolute paths and command names
- Use existsSync for absolute paths
- Use --version execution test for command names
- Added Linux-specific error messages and troubleshooting
3. Documentation Updates (README.md:409-444):
- Added "Linux Python Detection" section
- Documented detection priority order
- Added troubleshooting steps for KICAD_PYTHON
- Clarified that no manual config needed for standard installations
Testing:
- Build completed successfully (npm run build)
- Python detection now resolves /usr/bin/python3 on Ubuntu/Debian
- Maintains backward compatibility with Windows/macOS
- KICAD_PYTHON override still works
Fixes#29
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes issue #28 where place_component fails on KiCAD 9.0.5 with:
'FOOTPRINT' object has no attribute 'SetFootprintName'
KiCAD 9.x API changed from SetFootprintName() to SetFPID(LIB_ID).
Changes:
- place_component: Parse footprint string and use SetFPID with LIB_ID
- update_component: Parse footprint string or preserve existing library
- duplicate_component: Use source.GetFPID() directly
All three methods now use the KiCAD 9.x API while maintaining backward
compatibility with the footprint parameter format.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Comprehensive documentation of Phase 2 achievements including power symbol support, wire graph analysis for net connectivity, critical bug fixes (template mapping, special character handling), and 100% passing integration tests. Removes emoji per style guidelines.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Critical Bug Fixes:
1. Changed get_or_create_template() return type to tuple (template_ref, needs_reload)
2. Added automatic schematic reload after dynamic loading
3. Replaced hasattr() checks with symbol iteration (handles special characters like +)
4. Added template_exists() helper function
5. Fixed template lookup to check multiple potential reference formats
Issues Resolved:
- Multiple components of same type can now be added after dynamic loading
- Power symbols with special characters (+3V3, +5V) work correctly
- Template references with library prefix are properly detected
- Schematic object stays in sync with file after dynamic injections
Testing:
- ✅ Power symbols: 4/4 loaded (VCC, GND, +3V3, +5V)
- ✅ Components: 4/4 placed (R, R, C, LED)
- ✅ Connections: 8/8 created
- ✅ Special character handling (+3V3, +5V) working
Technical Details:
- hasattr() fails with attribute names containing special characters
- Must iterate symbols and check Reference.value directly
- Schematic reload required after S-expression injection
- Template name formats: _TEMPLATE_R, _TEMPLATE_power_VCC, _TEMPLATE_Device_R
Addresses template mapping issues found during Phase 2 power net testing
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Documentation Updates:
- README: Updated Schematic Design section from 6 to 9 tools
- Added "Wiring & Connections" subsection highlighting new capabilities
- Documented automatic pin discovery with rotation support
- Listed smart routing options (direct, orthogonal)
- Added net label management features
- CHANGELOG: Added Phase 1 wiring system entry with complete feature list
New Features Documented:
- add_schematic_connection with auto pin discovery
- add_schematic_net_label with orientation control
- WireManager and PinLocator implementation
- S-expression precision and format compliance
Part of Issue #26 schematic wiring implementation
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updates MCP handlers to use the new wiring infrastructure:
Handler Updates:
- _handle_add_schematic_wire: Uses WireManager.add_wire() with S-expression manipulation
- _handle_add_schematic_connection: Uses ConnectionManager with automatic pin discovery and routing options (direct, orthogonal_h, orthogonal_v)
- _handle_add_schematic_net_label: Uses WireManager.add_label() with support for label types and orientation
Features:
- Automatic pin location discovery with rotation support
- Professional wire routing (direct, orthogonal horizontal-first, orthogonal vertical-first)
- Net label placement with customizable types (label, global_label, hierarchical_label)
- Comprehensive error handling and logging
Testing:
- All MCP handlers tested and verified working
- Integration test: 100% passing (2 wires, 1 label created successfully)
- Verified with kicad-skip that wires and labels are correctly formed
Part of Issue #26 schematic wiring implementation (Phase 1)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated README.md to highlight the major dynamic loading feature:
✅ Updated 'What's New' section
- Added Phase 2: Dynamic Symbol Loading breakthrough
- Documented access to all ~10,000 KiCad symbols
- Added technical architecture explanation
- Example usage with STM32 microcontroller
✅ Updated Schematic Design tools section
- Changed from 'template-based' to 'dynamic loading'
- Explained automatic library search and injection
- Noted fallback to 13 static templates
✅ Updated Project Status
- Added 'DYNAMIC SYMBOL LOADING' as key feature
- Highlighted access to full KiCad symbol libraries
- Noted automatic dynamic injection capability
This brings the README in line with the breakthrough achieved in
commits 1d9e92a and 148f3ef.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated DYNAMIC_LOADING_STATUS.md to reflect:
✅ Phase C (MCP Integration) - COMPLETE
- Full MCP interface integration done
- Save → inject → reload → clone orchestration working
- Smart detection and automatic fallback
- 100% test pass rate (5/5 components)
Added comprehensive integration test results section showing:
- Test matrix with 5 components
- 3 successful dynamic loads (Battery, Fuse, Transformer)
- Zero configuration required for users
- Access to ~10,000 KiCad symbols now available
Status: PRODUCTION READY! 🚀
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
MAJOR MILESTONE: Dynamic symbol loading is now fully integrated through the MCP interface!
## What's Working
✅ **Full MCP Integration**
- Modified _handle_add_schematic_component to orchestrate dynamic loading
- Detects when symbols need dynamic loading (not in static templates)
- Automatically saves → injects → reloads → clones → saves workflow
✅ **ComponentManager Integration**
- Added schematic_path parameter to add_component() and get_or_create_template()
- Seamlessly switches between static templates and dynamic loading
- Proper error handling and fallback mechanisms
✅ **Smart Detection**
- Checks if component type is in static template map
- Verifies template exists in current schematic
- Only triggers dynamic loading when truly needed
✅ **Reload Orchestration**
- Saves schematic before dynamic loading (preserves changes)
- Calls DynamicSymbolLoader.load_symbol_dynamically()
- Reloads schematic to get newly injected symbols
- Clones from reloaded templates
## Test Results
End-to-end integration test: ✅ **100% PASSING**
Components tested:
- R (resistor) - static template, dynamically loaded
- C (capacitor) - static template, dynamically loaded
- Battery - pure dynamic loading ✨
- Fuse - pure dynamic loading ✨
- Transformer_1P_1S - pure dynamic loading ✨
All 5 components added successfully!
## Impact
Users can now add **ANY symbol from KiCad's ~10,000 symbol libraries** through the MCP interface!
No more limitation to 13 pre-configured templates!
## Technical Details
1. MCP handler detects dynamic loading need
2. Saves current schematic state
3. Calls dynamic loader (injects symbol + creates template)
4. Reloads schematic (kicad-skip sees new template)
5. Clones template to create component
6. Saves final result
Response includes:
- success status
- dynamic_loading_used flag
- symbol_source (library:symbol)
- template_reference
## Files Modified
- python/kicad_interface.py: _handle_add_schematic_component - full orchestration
- python/commands/component_schematic.py: add_component() and get_or_create_template() - schematic_path support
## Time Estimate vs Actual
Estimated: 2-3 hours
Actual: ~2 hours
Status: ✅ ON TARGET!
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
**Root Cause:**
When a library wasn't registered in sym-lib-table, the tool returned:
- success: true
- symbols: []
- count: 0
This was confusing because it looked like the library existed but was empty.
**The Fix:**
Now explicitly checks if library exists in sym-lib-table before attempting
to list symbols. If not found, returns:
- success: false
- Clear error message: "Library 'X' not found in sym-lib-table"
- Helpful details about how to resolve (add to sym-lib-table or use available libs)
- Count of available libraries
- Suggestion to use 'list_symbol_libraries' tool
**Test Results:**
✓ Non-existent library (BQ25896RTWT): Returns error as expected
✓ Valid library (Device): Returns 533 symbols successfully
**User Impact:**
Users will now get clear feedback when they try to access libraries that
aren't registered in their KiCad configuration, instead of seeing "0 symbols"
which suggests the library exists but is empty.
Fixes#27
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add JLCPCB Parts Integration section to What's New
- Update tool count from 59 to 64 tools
- Add JLCPCB Integration category (5 tools) to Available Tools
- Add detailed setup instructions for both local libraries and API modes
- Add usage examples for component selection and cost optimization
- Update architecture section with JLCPCB command modules
- Move JLCPCB from Planned to Working Features
- Add acknowledgment for @l3wi's local library search contribution
- Professional formatting without emojis as requested
This documents the dual-mode JLCPCB integration that provides users with
both local symbol library search (from PR #25) and complete API access to
100k+ parts with real-time pricing and cost optimization.
Co-Authored-By: l3wi <l3wi@users.noreply.github.com>
Properly credits @l3wi for the local symbol library search implementation
from PR #25, which provides the foundation for our dual-mode JLCPCB integration.
Co-Authored-By: l3wi <l3wi@users.noreply.github.com>
Implements full JLCPCB parts catalog integration alongside existing local library search,
giving users two complementary approaches for component selection:
1. Local Symbol Libraries (PR #25)
- Search JLCPCB libraries installed via KiCad PCM
- Pre-configured symbols with footprints
- Works offline, no API needed
2. JLCPCB API Integration (NEW)
- Complete 100k+ parts catalog access
- Real-time pricing and stock information
- Basic/Extended library type identification
- Cost optimization and alternative suggestions
- Package-to-footprint mapping
New Features:
- download_jlcpcb_database: Download complete parts catalog to local SQLite DB
- search_jlcpcb_parts: Parametric search with pricing, stock, library type filters
- get_jlcpcb_part: Detailed part info with price breaks and footprint suggestions
- get_jlcpcb_database_stats: Database statistics and status
- suggest_jlcpcb_alternatives: Find cheaper/available alternatives
Implementation:
- Python API client (commands/jlcpcb.py) - JLCPCB API authentication and data fetching
- Parts database manager (commands/jlcpcb_parts.py) - SQLite storage and search
- TypeScript MCP tools (tools/jlcpcb-api.ts) - User-facing tool definitions
- Comprehensive documentation (docs/JLCPCB_USAGE_GUIDE.md)
Database Features:
- ~100k parts with descriptions, pricing, stock levels
- Full-text search on descriptions and part numbers
- Parametric filtering (category, package, manufacturer, library type)
- Package-to-footprint mapping for KiCad
- Intelligent alternative suggestions
Setup Requirements:
- JLCPCB_API_KEY and JLCPCB_API_SECRET environment variables
- One-time database download (~5-10 minutes, 42MB)
- requests library (already in requirements.txt)
Benefits:
- Cost optimization (identify Basic parts = free assembly)
- Real-time stock checking
- Complete catalog access
- Works offline after initial download
- Complements local library search
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds comprehensive local KiCad symbol library search functionality and fixes KICAD9_3RD_PARTY environment variable resolution.
Features:
- Symbol library search by name, LCSC ID, description, manufacturer, MPN
- Support for 3rd party libraries installed via Plugin and Content Manager
- New MCP tools: search_symbols, list_symbol_libraries, get_symbol_info
- Enhanced library path resolution for KiCad 8 and 9
This enables users with locally installed JLCPCB libraries to search and use components directly.
Co-authored-by: l3wi <l3wi@users.noreply.github.com>
Adds macOS-specific detection for KiCad's bundled Python, eliminating manual
PYTHONPATH configuration for macOS users.
Changes:
- Detects KiCad bundled Python at standard macOS install path (Python 3.9-3.12)
- Makes KICAD_PYTHON environment variable cross-platform (not just Windows)
- Adds logging for Python detection to aid debugging
- Updates documentation with simplified macOS setup (no PYTHONPATH needed)
Fixes server startup on macOS where existsSync('python3') was failing validation
because it doesn't check PATH.
Based on PR #18 by @hexatriene - applied manually due to merge conflict with
router implementation. Full credit to hexatriene for the solution design and
implementation.
Co-authored-by: hexatriene <106840313+hexatriene@users.noreply.github.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replaces unreliable tasklist subprocess calls with proper Windows Toolhelp32 API.
- Uses CreateToolhelp32Snapshot/Process32FirstW/Process32NextW for process enumeration
- Adds pointer-size fallback for wintypes.ULONG_PTR missing in KiCad's embedded Python
- Fixes check_kicad_ui intermittent timeouts and false negatives on Windows
- Adds encoding/timeout fixes for 'where' command calls
Fixes#20
Co-authored-by: jbjardine <167578676+jbjardine@users.noreply.github.com>
Add KiCAD IPC API backend using kicad-python library for real-time
communication with KiCAD 9.0+. Changes now appear instantly in KiCAD
UI without manual reload.
Key changes:
- Implement IPCBackend and IPCBoardAPI classes for IPC communication
- Auto-detect IPC availability and fall back to SWIG when unavailable
- Route existing commands (route_trace, add_via, place_component, etc.)
through IPC automatically when available
- Add transaction support for proper undo/redo
- Add socket path auto-detection for Linux (/tmp/kicad/api.sock)
New commands:
- get_backend_info: Check which backend is active
Supported IPC operations:
- Board: set_size, get_board_info, save
- Routing: route_trace, add_via, add_net
- Components: place, move, delete, list
- Text: add_text, add_board_text
SWIG backend is now deprecated and will be removed when KiCAD 10.0
drops SWIG support.
Requires: kicad-python>=0.5.0, KiCAD 9.0+ with IPC enabled
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Major improvements to schematic editing capabilities:
## Python Implementation (connection_schematic.py)
- Implemented pin-to-pin connection logic using kicad-skip
- Added get_pin_location() to find absolute pin positions
- Implemented add_connection() for wire connections between component pins
- Added add_net_label() for creating net labels
- Added connect_to_net() to connect pins to named nets
- Implemented get_net_connections() to query net connectivity
- Added generate_netlist() for schematic netlist extraction
## MCP Handlers (kicad_interface.py)
- Added 5 new command handlers:
- add_schematic_connection - Pin-to-pin wiring
- add_schematic_net_label - Net label placement
- connect_to_net - Connect pin to named net
- get_net_connections - Query net connectivity
- generate_netlist - Export netlist data
## TypeScript Tools (schematic.ts)
- Added 5 new MCP tools with proper schemas and validation
- Enhanced user feedback with descriptive messages
- Total schematic tools increased from 3 to 8
## Features
- Pin location calculation with symbol rotation support
- Automatic wire stub creation for net labels
- Comprehensive netlist generation with component and net info
- Full logging for debugging connection issues
This resolves the schematic editing limitations and enables users to:
- Wire component pins together directly
- Use net labels for cleaner schematics
- Query schematic connectivity
- Generate netlists for manufacturing
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
- Added missing schematic tools registration (fixes#12)
- Created library tools TypeScript implementation
- Added 4 library management tools (list_libraries, search_footprints, list_library_footprints, get_footprint_info)
- Now properly exports and registers all 10 tool categories
- Total of 54 TypeScript tools now properly registered
This resolves the issue where schematic and library tools were defined in Python but not visible to MCP clients.
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit fixes two critical issues for MCP STDIO transport:
1. Logger fix (src/logger.ts) - CRITICAL MCP protocol compliance
- Change all log levels to use console.error() (stderr) exclusively
- Previous code sent info/debug logs to stdout via console.log()
- MCP protocol uses stdout for JSON-RPC messages
- Logging to stdout corrupts protocol communication
- Impact: Prevents intermittent MCP failures from log pollution
2. Windows compatibility fix (src/index.ts)
- Remove import.meta.url conditional check that fails on Windows
- Path separator differences (forward slash vs backslash) cause
the file:// URL comparison to fail
- Server now runs main() unconditionally as intended
- Impact: Reliable server startup on Windows
Changes:
- src/logger.ts: Use console.error() for all log levels
- src/index.ts: Remove 'if (import.meta.url === ...)' check
- src/index.ts: Add explanatory comment about Windows issue
Tested on Windows 11 with KiCAD 9.0.6.
Integration tests confirm 36KB logs to stderr, 0 bytes to stdout.
Fixes: MCP protocol corruption, Windows startup failures
Resolves issue #6 - PowerShell encoding errors on Windows
Changes:
- Replaced checkmark (✓) with [OK]
- Replaced cross (✗) with [ERROR]
- Replaced warning (⚠) with [WARN]
- Replaced arrow (→) with [INFO]
- Replaced Unicode box-drawing characters with simple equals signs
This ensures the script works reliably across all Windows configurations
regardless of PowerShell encoding settings or console code pages.
Generated with Claude Code - https://claude.com/claude-code
Co-Authored-By: Claude <noreply@anthropic.com>