From 0540a5d0f47df0587d9b1b20877bfbad73b495b5 Mon Sep 17 00:00:00 2001 From: KiCAD MCP Bot Date: Sat, 10 Jan 2026 10:06:16 -0500 Subject: [PATCH] fix: Issue #27 - list_library_symbols now returns proper error for missing libraries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **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 --- python/commands/library_symbol.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/python/commands/library_symbol.py b/python/commands/library_symbol.py index 5245619..82a7c7e 100644 --- a/python/commands/library_symbol.py +++ b/python/commands/library_symbol.py @@ -529,6 +529,19 @@ class SymbolLibraryCommands: "message": "Missing library parameter" } + # Check if library exists in sym-lib-table + if library not in self.library_manager.libraries: + available_libs = list(self.library_manager.libraries.keys()) + return { + "success": False, + "message": f"Library '{library}' not found in sym-lib-table", + "errorDetails": f"Library '{library}' is not registered in your KiCad symbol library table. " + f"Found {len(available_libs)} libraries. " + f"Please add this library to your sym-lib-table file, or use one of the available libraries.", + "available_libraries_count": len(available_libs), + "suggestion": "Use 'list_symbol_libraries' to see all available libraries" + } + symbols = self.library_manager.list_symbols(library) return {