feat: Complete Phase 1 & 2 - Schematic workflow fix and JLCPCB integration

Phase 1: Schematic Workflow Fix (Issue #26)
- Fixed broken schematic workflow using template-based symbol cloning
- Updated create_project to generate both PCB and schematic files
- Rewrote add_schematic_component to use kicad-skip clone() API
- Added template schematics with cloneable R, C, LED symbols
- All schematic tests now passing

Phase 2: JLCPCB Integration Complete
- Integrated JLCSearch public API (no authentication required)
- Access to ~100k JLCPCB parts with real-time stock and pricing
- Implemented parametric search for resistors, capacitors, components
- Added package-to-footprint mapping for KiCad integration
- Cost optimization with Basic vs Extended library classification
- Alternative part suggestions with price comparison

New Components:
- python/commands/jlcsearch.py - JLCSearch API client
- python/templates/ - Template schematics for symbol cloning
- docs/JLCPCB_INTEGRATION.md - Comprehensive API documentation
- docs/SCHEMATIC_WORKFLOW_FIX.md - Phase 1 technical details
- CHANGELOG.md - Consolidated unified changelog
- PHASE_2_COMPLETE.md - Phase 2 implementation summary

MCP Tools Available:
- download_jlcpcb_database - Download full parts catalog
- search_jlcpcb_parts - Parametric search with filters
- get_jlcpcb_part - Part details + footprint suggestions
- get_jlcpcb_database_stats - Database statistics
- suggest_jlcpcb_alternatives - Find similar/cheaper parts

Technical Improvements:
- SQLite database with FTS5 full-text search
- HMAC-SHA256 authentication support (official JLCPCB API)
- Improved .gitignore to exclude credentials and databases
- Template-based schematic creation workflow

Testing:
- All integration tests passing
- Database operations validated
- Live API connectivity confirmed
- Schematic workflow end-to-end verified

Credits:
- JLCSearch API: @tscircuit
- Local JLCPCB search: @l3wi

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
KiCAD MCP Bot
2026-01-10 09:04:46 -05:00
parent d5402e134a
commit 994965e041
14 changed files with 1848 additions and 118 deletions

View File

@@ -265,7 +265,9 @@ class KiCADInterface:
self.symbol_library_commands = SymbolLibraryCommands()
# Initialize JLCPCB API integration
self.jlcpcb_client = JLCPCBClient()
self.jlcpcb_client = JLCPCBClient() # Official API (requires auth)
from commands.jlcsearch import JLCSearchClient
self.jlcsearch_client = JLCSearchClient() # Public API (no auth required)
self.jlcpcb_parts = JLCPCBPartsManager()
# Schematic-related classes don't need board reference
@@ -1492,7 +1494,7 @@ class KiCADInterface:
# JLCPCB API handlers
def _handle_download_jlcpcb_database(self, params):
"""Download JLCPCB parts database from API"""
"""Download JLCPCB parts database from JLCSearch API"""
try:
force = params.get('force', False)
@@ -1506,16 +1508,16 @@ class KiCADInterface:
"stats": stats
}
logger.info("Downloading JLCPCB parts database...")
logger.info("Downloading JLCPCB parts database from JLCSearch...")
# Download parts from API
parts = self.jlcpcb_client.download_full_database(
callback=lambda page, total, msg: logger.info(f"Page {page}: {msg}")
# Download parts from JLCSearch public API (no auth required)
parts = self.jlcsearch_client.download_all_components(
callback=lambda total, msg: logger.info(f"{msg}")
)
# Import into database
logger.info(f"Importing {len(parts)} parts into database...")
self.jlcpcb_parts.import_parts(
self.jlcpcb_parts.import_jlcsearch_parts(
parts,
progress_callback=lambda curr, total, msg: logger.info(msg)
)