Make project-scope sym-lib-table visible to symbol-discovery tools

search_symbols, list_symbol_libraries, list_library_symbols, and
get_symbol_info previously only consulted the global sym-lib-table. A
library registered with project scope (an entry in
<project>/sym-lib-table) was therefore invisible — even right after
open_project succeeded — making add_schematic_component the only tool
that could see it.

Fix has two parts:

1. Wrap project_commands.open_project and project_commands.create_project
   in handlers that rebuild SymbolLibraryCommands.library_manager against
   the project directory. After open_project, project-scope libraries are
   automatically visible to subsequent search/list/info calls.

2. Add an optional projectPath parameter to the four discovery tools
   (accepts a project directory, .kicad_pro, .kicad_pcb, or .kicad_sch
   path). Stateless callers can resolve project libraries without first
   calling open_project. SymbolLibraryCommands._derive_project_path also
   walks up from schematicPath/boardPath to find the directory that owns
   the project, mirroring the logic in _handle_add_schematic_component.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Michael Holm
2026-05-02 20:35:15 +02:00
parent d3c01e20bd
commit 890746c6ac
4 changed files with 158 additions and 11 deletions

View File

@@ -6,6 +6,21 @@ All notable changes to the KiCAD MCP Server project are documented here.
### Bug Fixes
- **Project-scope `sym-lib-table` is now visible to symbol-discovery tools**:
`search_symbols`, `list_symbol_libraries`, `list_library_symbols`, and
`get_symbol_info` previously only consulted the global `sym-lib-table`. A
library registered with project scope (i.e. an entry in
`<project>/sym-lib-table`) was therefore invisible — even right after
`open_project` succeeded — making `add_schematic_component` the only tool
that could see it. Two changes:
1. `open_project` and `create_project` now rebuild the
`SymbolLibraryManager` against the project directory so subsequent
search/list/info calls see project-scope libraries automatically.
2. The four discovery tools also accept an optional `projectPath`
parameter (a project directory, `.kicad_pro`, `.kicad_pcb`, or
`.kicad_sch` path) for stateless callers, so project libraries can be
resolved without first calling `open_project`.
- **Schematic symbol lookup**: `get_schematic_component`,
`edit_schematic_component`, `set_schematic_component_property`,
`remove_schematic_component_property`, and `delete_schematic_component`