fix: macOS wxApp warm-up + symbol cache eager loading (#195)

Three-phase MCP server startup: wait for Python READY handshake, send
_warmup command (pcbnew.BOARD() triggers wxApp init on macOS), connect
to MCP transport only after warm-up completes.

Also pre-populate symbol library cache during SymbolLibraryManager
init so the first search_symbols call doesn't parse 241 .kicad_sym
files from disk (30-120s). Both warm-up and cache population happen
before tools are registered with the MCP client.

Fixes #195
This commit is contained in:
Chaitanya Malhotra
2026-05-23 05:39:24 +05:30
parent 76e644e4ef
commit ef6c135cda
3 changed files with 187 additions and 4 deletions

View File

@@ -55,6 +55,21 @@ class SymbolLibraryManager:
self.libraries: Dict[str, str] = {} # nickname -> path mapping
self.symbol_cache: Dict[str, List[SymbolInfo]] = {} # library -> [SymbolInfo]
self._load_libraries()
self._warm_cache()
def _warm_cache(self) -> None:
"""Pre-parse all symbol libraries so the first search is fast.
Without this, the first ``search_symbols`` call parses every
.kicad_sym file on demand, which can take 30-120 s across
200+ libraries. By populating the cache here (during startup,
before the READY handshake) the cost is paid once.
"""
for nickname in list(self.libraries.keys()):
try:
self.list_symbols(nickname)
except Exception:
logger.debug("Skipping unparseable library: %s", nickname)
def _load_libraries(self) -> None:
"""Load libraries from sym-lib-table files"""