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>
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>
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>