Commit Graph

58 Commits

Author SHA1 Message Date
KiCAD MCP Bot
d2723bc292 fix: Resolve Python executable validation failure on Linux (Issue #29)
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>
2026-01-10 22:23:54 -05:00
KiCAD MCP Bot
aa18486359 fix: Replace SetFootprintName with SetFPID for KiCAD 9.x compatibility
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>
2026-01-10 11:43:54 -05:00
KiCAD MCP Bot
6fffb39bc7 docs: Document Phase 2 power net and wire connectivity completion
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>
2026-01-10 11:14:18 -05:00
KiCAD MCP Bot
a5a542b1e9 feat: Implement wire graph analysis for net connectivity (Phase 2)
Major Feature: Wire Graph Analysis
- Rewrote get_net_connections() with geometric wire tracing
- Added points_coincide() helper for coordinate matching
- Implemented multi-step connectivity algorithm:
  1. Find all labels with target net name
  2. Trace wires connected to label positions
  3. Find component pins at wire endpoints using PinLocator
  4. Return accurate component/pin connections

Technical Implementation:
- Tolerance-based point matching (0.5mm for grid alignment)
- Wire polyline support (traces multi-segment paths)
- Accurate pin location matching with rotation support
- Fallback proximity matching when schematic_path unavailable

Testing Results:  100% PASSING
- VCC: 2 connections (R1_/1, D1_/1) ✓
- GND: 4 connections (R1_/2, R2_/2, C1_/2, D1_/2) ✓
- +3V3: 1 connection (R2_/1) ✓
- +5V: 1 connection (C1_/1) ✓
- Netlist generation: 4 nets detected ✓
- Comprehensive power circuit test: PASSED ✓

Updates:
- get_net_connections() now accepts optional schematic_path parameter
- generate_netlist() automatically uses improved connectivity analysis
- Full integration with PinLocator for accurate pin matching

Addresses: Phase 2 net connectivity analysis requirements

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-10 10:52:20 -05:00
KiCAD MCP Bot
b77f0081d6 fix: Resolve template mapping bug in dynamic symbol loading
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>
2026-01-10 10:49:08 -05:00
KiCAD MCP Bot
c67f400383 feat: Update connect_to_net to use WireManager (Phase 2)
Updates:
- ConnectionManager.connect_to_net() now uses PinLocator + WireManager
- Accepts Path parameter instead of Schematic object
- Creates wire stub (2.54mm) from pin to label position
- Uses WireManager.add_wire() and WireManager.add_label()
- Updated MCP handler _handle_connect_to_net()

Testing:
-  connect_to_net test: 100% passing
-  R1/1 → VCC wire stub + label
-  D1/2 → GND wire stub + label
-  Verified with kicad-skip: 5 wires, 4 labels

Part of Phase 2: Net Labels & Named Nets (Issue #26)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-10 10:40:56 -05:00
KiCAD MCP Bot
d396ccd61f docs: Update README and CHANGELOG with wiring implementation
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>
2026-01-10 10:39:07 -05:00
KiCAD MCP Bot
16703e28f9 feat: Integrate WireManager and PinLocator into MCP interface handlers
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>
2026-01-10 10:35:16 -05:00
KiCAD MCP Bot
203572cd1a docs: Create comprehensive schematic wiring implementation plan
Created detailed 500+ line implementation plan for schematic wiring tools
addressing user questions from Issue #26.

## Plan Overview

**Phases:**
1. Core Wire Functionality (Week 1) - 26 hours
   - Research kicad-skip wire API
   - Fix wire creation
   - Implement pin discovery
   - Fix add_schematic_connection

2. Net Labels & Named Nets (Week 1-2) - 28 hours
   - Net label creation
   - connect_to_net implementation
   - Net connection discovery
   - Power symbol support

3. Advanced Features (Week 2-3) - 28 hours
   - Junction support
   - No-connect flags
   - Orthogonal routing
   - Bus and hierarchical labels

4. Validation & Polish (Week 3-4) - 28 hours
   - ERC integration
   - Comprehensive testing
   - Error handling
   - Documentation

**Total Timeline:** 5 weeks (110 hours)
**Accelerated:** 2-3 weeks (core features only)

## Technical Approach

**Option A:** Use kicad-skip native API (preferred)
**Option B:** S-expression manipulation (fallback, like dynamic loading)
**Recommended:** Hybrid approach

## Key Challenges Identified

1. kicad-skip wire API uncertainty - needs research
2. Pin location calculation with rotation
3. Smart wire routing (orthogonal preferred)
4. Net label attachment to wires

## Current State

- ConnectionManager class exists with methods
- MCP handlers registered (6 tools)
- Basic implementation present but untested
- User reported add_schematic_wire fails

## Next Steps

1. Research kicad-skip wire API (TODAY)
2. Create test environment (TOMORROW)
3. Implement basic wire (THIS WEEK)
4. Fix pin discovery (THIS WEEK)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-10 10:24:25 -05:00
KiCAD MCP Bot
60d19e5235 docs: Update README with dynamic symbol loading breakthrough
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>
2026-01-10 10:20:44 -05:00
KiCAD MCP Bot
148f3ef401 docs: Update dynamic loading status - Phase C COMPLETE!
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>
2026-01-10 10:16:47 -05:00
KiCAD MCP Bot
1d9e92a165 feat: Complete MCP integration for dynamic symbol loading! 🎉
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>
2026-01-10 10:16:07 -05:00
KiCAD MCP Bot
62d97f1fa6 feat: Dynamic symbol loading - CORE FUNCTIONALITY WORKING! 🎉
**MAJOR BREAKTHROUGH:** Implemented dynamic symbol loading from KiCad library files!
This eliminates the 13-component limitation and enables access to ALL KiCad symbols.

**What Works (Phase A Complete):**
 Symbol extraction from .kicad_sym library files
 S-expression parsing and manipulation
 Dynamic injection of symbols into schematics
 Template instance creation for cloning
 Full end-to-end workflow tested successfully

**Test Results:**
- Loaded 5 symbols dynamically (R, C, LED, L, D) from Device.kicad_sym
- Injected symbol definitions into schematic's lib_symbols section
- Created template instances at offscreen positions
- Successfully cloned components from dynamic templates
- All operations work with kicad-skip library

**New File:**
- python/commands/dynamic_symbol_loader.py (400+ lines)
  - DynamicSymbolLoader class
  - find_kicad_symbol_libraries() - cross-platform library discovery
  - parse_library_file() - S-expression parsing with caching
  - extract_symbol_definition() - extract specific symbols
  - inject_symbol_into_schematic() - inject symbols into lib_symbols
  - create_template_instance() - create cloneable templates
  - load_symbol_dynamically() - complete workflow

**Modified:**
- python/commands/component_schematic.py
  - Added dynamic loader integration hooks
  - get_or_create_template() method for hybrid approach
  - Falls back to static templates gracefully

**How It Works:**
1. Parse .kicad_sym file with sexpdata library
2. Extract specific symbol definition (S-expression tree)
3. Inject into schematic's lib_symbols section
4. Create offscreen template instance (_TEMPLATE_Device_R)
5. kicad-skip can clone() the template to create components

**Benefits:**
- Access to ~10,000+ standard KiCad symbols
- No manual template maintenance required
- Works with ANY .kicad_sym library file
- Maintains static template fallback

**Next Steps (Integration):**
- Wire through MCP interface layer (has schematic path)
- Create add_schematic_component_dynamic MCP tool
- Add symbol search/discovery tools
- Cross-platform testing (Windows, macOS)

**Technical Notes:**
- Uses sexpdata library for S-expression manipulation
- Caches parsed libraries for performance
- Generates unique UUIDs for template instances
- Positions templates offscreen (y = -100 - offset)
- Preserves schematic structure and formatting

This is a MASSIVE step forward! The hardest part (S-expression manipulation
and template injection) is DONE and WORKING. 🚀

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-10 10:10:57 -05:00
KiCAD MCP Bot
0540a5d0f4 fix: Issue #27 - list_library_symbols now returns proper error for missing libraries
**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>
2026-01-10 10:06:16 -05:00
KiCAD MCP Bot
4a543313eb feat: Expand schematic component support from 3 to 13 types + plan dynamic loading
Issue #26 Follow-up: The original fix only supported 3 component types (R, C, LED).
This expands the template-based approach to 13 types while planning for unlimited access.

**Expanded Template (Option 1 - Immediate Solution):**
- Added 10 new component types to template
- Passives: R, C, L, Crystal (4 types)
- Semiconductors: D, LED, Q_NPN, Q_NMOS (4 types)
- ICs: OpAmp, Voltage Regulator (2 types)
- Connectors: Conn_2pin, Conn_4pin (2 types)
- Misc: Switch/Button (1 type)

**Components Now Supported:**
1. Resistor (R)
2. Capacitor (C)
3. Inductor (L)
4. Crystal (Y)
5. Diode (D)
6. LED
7. NPN Transistor (Q_NPN)
8. N-Channel MOSFET (Q_NMOS)
9. Op-Amp (U)
10. Voltage Regulator (U_REG)
11. 2-pin Connector (J2)
12. 4-pin Connector (J4)
13. Push Button/Switch (SW)

**Implementation:**
- Created template_with_symbols_expanded.kicad_sch with all 13 types
- Updated TEMPLATE_MAP with comprehensive type mappings
- Updated project.py to use expanded template by default
- All tests passing (13/13 components added successfully)

**Future Plan (Option 2 - Dynamic Library Loading):**
- Documented comprehensive plan for accessing ALL KiCad symbols (~10,000+)
- Dynamic loading from .kicad_sym library files
- S-expression injection approach
- 6-8 week implementation timeline
- Maintains template fallback for compatibility

**Files Added:**
- python/templates/template_with_symbols_expanded.kicad_sch
- docs/DYNAMIC_LIBRARY_LOADING_PLAN.md

**Files Modified:**
- python/commands/component_schematic.py (expanded TEMPLATE_MAP)
- python/commands/project.py (use expanded template)

This provides immediate value (13 types vs 3) while we plan the long-term
solution of unlimited symbol access through dynamic library loading.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-10 09:54:51 -05:00
KiCAD MCP Bot
81a24a9e4f docs: Update README with Phase 1 schematic workflow fix details
Highlights:
- Added prominent section explaining Issue #26 resolution
- Documented template-based symbol cloning approach
- Updated schematic tools section with fix notice
- Enhanced project status to show schematic workflow is fully functional
- Added JLCSearch and JLCParts acknowledgments

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-10 09:18:01 -05:00
KiCAD MCP Bot
994965e041 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>
2026-01-10 09:04:56 -05:00
mixelpixx
d5402e134a Update print statement from 'Hello' to 'Goodbye' 2026-01-05 08:20:51 -05:00
mixelpixx
ada9689abc Update print statement from 'Hello' to 'Goodbye' 2026-01-04 14:54:52 -05:00
mixelpixx
07b3ef2d6d Update print statement from 'Hello' to 'Goodbye' 2025-12-31 11:23:08 -05:00
KiCAD MCP Bot
55a0279dce docs: Update README with comprehensive JLCPCB integration documentation
- 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>
2025-12-31 11:17:08 -05:00
KiCAD MCP Bot
b257778bc9 docs: Add attribution for local symbol library search to @l3wi
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>
2025-12-31 11:11:54 -05:00
KiCAD MCP Bot
4c6514eb6b feat: Add complete JLCPCB API integration with dual-mode support
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>
2025-12-31 11:04:08 -05:00
Lewis Freiberg
0227dd48d2 feat: Add local symbol library search and 3rd party library support (#25)
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>
2025-12-31 10:57:10 -05:00
KiCAD MCP Bot
8a1cb46b39 fix: Add macOS support for KiCad bundled Python detection
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>
2025-12-28 11:36:38 -05:00
jbjardine
834d05130c fix: Replace Windows tasklist with Toolhelp32 API for reliable process detection (#21)
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>
2025-12-28 11:29:09 -05:00
KiCAD MCP Bot
c65600049e feat: Implement intelligent tool router pattern (Phase 1)
Adds tool discovery system to reduce AI context usage by up to 70% while
maintaining full access to all 59 tools. Organizes tools into 7 logical
categories with automatic discovery and execution.

## What's New

### Tool Router System
- 12 direct tools (always visible for high-frequency operations)
- 47 routed tools (organized into 7 discoverable categories)
- 4 router tools for discovery and execution:
  - list_tool_categories - Browse all categories
  - get_category_tools - View tools in a category
  - search_tools - Find tools by keyword
  - execute_tool - Execute any routed tool

### Tool Categories
1. board (9 tools) - Board configuration, layers, zones
2. component (8 tools) - Advanced component operations
3. export (8 tools) - Manufacturing file generation
4. drc (8 tools) - Design rule checking & validation
5. schematic (8 tools) - Schematic editor operations
6. library (4 tools) - Footprint library access
7. routing (2 tools) - Advanced routing (vias, copper pours)

## Implementation Details

### New Files
- src/tools/registry.ts - Tool categorization and lookup system
- src/tools/router.ts - Router tool implementations
- docs/ROUTER_ARCHITECTURE.md - Design specification
- docs/ROUTER_IMPLEMENTATION_STATUS.md - Implementation status
- docs/TOOL_INVENTORY.md - Complete tool catalog
- docs/ROUTER_QUICK_START.md - User guide
- docs/mcp-router-guide.md - Implementation guide
- test-router.js - Registry test suite

### Modified Files
- src/server.ts - Integrated router tool registration
- README.md - Updated with router documentation and user feedback section

## Benefits
- Reduces AI context by organizing tools into discoverable categories
- Maintains backwards compatibility (all tools still functional)
- Seamless user experience (discovery is automatic)
- Extensible architecture for adding new tools
- Comprehensive documentation

## Testing
 Build passes (npm run build)
 Registry tests pass (node test-router.js)
 Server starts successfully with router tools
 All 59 tools remain accessible

## Current State
Phase 1 Complete: Infrastructure implemented and tested
Phase 2 Pending: Optional token optimization (hide routed tools from context)

Token impact:
- Current: ~42K tokens (all tools still registered)
- Potential: ~12K tokens (70% reduction with Phase 2)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-28 11:07:07 -05:00
mixelpixx
c6e896c837 Delete REBUILD_STATUS.md 2025-12-09 00:32:33 -05:00
KiCAD MCP Bot
119f1dfc16 feat: Extend IPC backend with 21 commands and hybrid footprint placement
- Add IPC handlers for zone operations (add_copper_pour, refill_zones)
- Add IPC handlers for board operations (add_board_outline, add_mounting_hole, get_layer_list)
- Add IPC handlers for component operations (rotate_component, get_component_properties)
- Add IPC handlers for net operations (delete_trace, get_nets_list)
- Implement hybrid footprint placement (SWIG library loading + IPC placement)
- Extend create_schematic to handle filename, title, projectName params
- Update documentation for IPC backend status and known issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 08:48:37 -05:00
mixelpixx
03d7de980a Merge pull request #17 from fariouche/main
Fixes create_schematic timeout
2025-12-03 08:11:17 -05:00
fariouche
e3f66a6321 cleanup 2025-12-02 21:30:41 +01:00
fariouche
946203146d reverted temporary test code 2025-12-02 21:29:07 +01:00
fariouche
1e557d5d84 fixed create_schematics timeout 2025-12-02 21:26:13 +01:00
fariouche
c91cd45006 fixed interface parameter name projectName 2025-12-02 21:25:45 +01:00
mixelpixx
8bc73ed408 Delete tsconfig-json.json 2025-11-30 14:41:55 -05:00
mixelpixx
050ca8db62 Revise README for version 2.1.0-alpha
Updated README.md to include new features, installation instructions, and usage examples for version 2.1.0-alpha.
2025-11-30 14:39:25 -05:00
KiCAD MCP Bot
319473b1d8 feat: Implement IPC backend for real-time UI synchronization
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>
2025-11-30 14:33:27 -05:00
KiCAD MCP Bot
dd12d21f46 feat: Enhance schematic functionality with pin-to-pin connections and netlist generation
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>
2025-11-29 10:29:02 -05:00
KiCAD MCP Bot
34ccdb8822 fix: Register schematic and library tools in MCP server
- 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>
2025-11-29 10:17:55 -05:00
KiCAD MCP Bot
8a1fb3d5c3 Merge branch 'main' of https://github.com/mixelpixx/KiCAD-MCP-Server 2025-11-29 10:02:26 -05:00
mixelpixx
6b83d47226 Merge pull request #13 from sid115/include-userprofile-in-setup-script
Added USERPROFILE to possible KiCad paths in Windows setup script
2025-11-29 09:59:16 -05:00
Joshua Reichmann
19b30088f6 Added USERPROFILE to possible KiCad paths in Windows setup script 2025-11-28 15:17:33 +01:00
mixelpixx
ac8563758a Merge pull request #10 from gwall-ceres/main
Fix MCP protocol compliance and Windows compatibility
2025-11-18 18:22:46 -05:00
ByteBard
70c0be6fd0 Fix MCP protocol compliance and Windows compatibility
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
2025-11-18 17:29:21 -05:00
ByteBard
bb1c7a0883 Fix BOM export for KiCAD 9.0 - GetFootprintName() API change
Replace FOOTPRINT.GetFootprintName() with str(GetFPID()) for KiCAD 9.0 compatibility.

Issue:
- KiCAD 9.0 removed FOOTPRINT.GetFootprintName() method
- BOM export was failing with AttributeError

Fix:
- Changed: module.GetFootprintName() → str(module.GetFPID())
- GetFPID() returns the footprint library ID (LIB_ID object)
- Converting to string gives "Library:Footprint" format

Testing:
- Endpoint test: export_bom  PASS
- Generates CSV BOM with all 415 components
- Footprint names correctly formatted (e.g., "Capacitor_SMD:C_0603_1608Metric")

Related KiCAD 9.0 fixes in this repo:
- design_rules.py: SetCurrent* → SetCustom* API
- export.py: EXCELLON_WRITER → kicad-cli for drill files
- view.py: PlotLayer() signature update
- component.py: FP_VIRTUAL → FP_BOARD_ONLY

Status: All export operations working 

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 16:44:00 -05:00
ByteBard
bc7de47053 Fix Gerber drill file export for KiCAD 9.0
Replace EXCELLON_WRITER.SetOptions() Python API with kicad-cli subprocess for reliable drill file generation across KiCAD versions.

Issue:
- KiCAD 9.0 changed EXCELLON_WRITER.SetOptions() signature
- Added 3 required parameters: aMinimalHeader, aOffset, aMerge_PTH_NPTH
- API signature unstable across versions

Fix:
- Replace Python API with kicad-cli subprocess approach
- Use 'kicad-cli pcb export drill' command
- More stable and version-independent
- Generates separate PTH/NPTH drill files correctly

Command used:
```
kicad-cli pcb export drill \
  --output <dir> \
  --format excellon \
  --drill-origin absolute \
  --excellon-separate-th \
  <board_file>
```

Testing:
- Integration test: 12/12 tests passed (100% success)
- Generates PTH.drl and NPTH.drl files correctly
- Works with KiCAD 9.0.6 on Windows

Related to earlier fixes:
- design_rules.py: SetCurrent* → SetCustom* API migration
- view.py: PlotLayer() signature update
- component.py: FP_VIRTUAL → FP_BOARD_ONLY

Status: All KiCAD 9.0 API changes resolved 

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 16:12:22 -05:00
ByteBard
afcfe842cf Fix KiCAD 9.0 API compatibility for board, export, and view commands
This commit resolves critical KiCAD 9.0 API compatibility issues identified
through comprehensive testing and code audit.

## Major Fixes

### board/size.py - Board Outline Creation
- **Issue:** Stub implementation didn't create actual board edges
- **Fix:** Delegate to BoardOutlineCommands for proper Edge.Cuts geometry creation
- **Impact:** set_board_size() now creates actual rectangular board outlines
- **Tested:** 100x80mm and 4x3 inch board creation validated

### board/view.py - Board Extents Query
- **Issue:** get_board_extents() command not implemented
- **Fix:** New implementation returns complete bounding box data
- **Returns:** left, top, right, bottom, width, height, center coordinates
- **Tested:** Successfully returns 93.55mm × 212.05mm for test board

### board/__init__.py - Delegation Wiring
- **Fix:** Added get_board_extents() delegation to BoardViewCommands
- **Impact:** Completes board query API surface

### export.py - 3D Model Export
- **Issue:** Get3DViewer() doesn't work in headless KiCAD 9.0
- **Fix:** Replace with kicad-cli subprocess calls for STEP/VRML export
- **New:** _find_kicad_cli() helper for cross-platform CLI detection
- **Features:**
  - STEP export with component/copper/silkscreen/soldermask options
  - VRML export with configurable units
  - 5-minute timeout for large boards
  - Proper error handling and validation
- **Tested:**
  - STEP export: 144.65 MB (full), 114.61 MB (board-only)
  - VRML export: 60.69 MB
  - All exports successful on 415-component board

## Test Results

All changes validated with test_kicad_9_fixes.py:
-  Board outline creation (mm and inch units)
-  Board extents query
-  STEP 3D export (full and board-only)
-  VRML 3D export
-  Error handling and validation

## Compatibility

- **KiCAD Version:** 9.0.6 (tested)
- **Backward Compatible:** Yes (kicad-cli available in KiCAD 8.0+)
- **Platform:** Windows, macOS, Linux

## Breaking Changes

None - all changes are additions or fixes to broken functionality.

## Related

- Complements previous fixes: design_rules.py, component.py, layers.py
- Part of comprehensive KiCAD 9.0 compatibility effort
- Documentation: PYTHON_AUDIT_REPORT_FINAL.md, TEST_RESULTS.md

Fixes #<issue-number-if-applicable>
2025-11-17 15:40:20 -05:00
ByteBard
8c04038371 various fixes for kicad 9 2025-11-14 16:38:16 -05:00
mixelpixx
f8238e6190 Add files via upload
fix powershell script
2025-11-12 21:11:02 -05:00
KiCAD MCP Bot
53e4bcace7 fix: Replace Unicode characters in setup-windows.ps1 with ASCII alternatives
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>
2025-11-12 21:08:32 -05:00