fix: use import.meta.url for cross-platform script path resolution

Hardcoded Windows path broke Linux/macOS startup. Use import.meta.url to
derive the script path relative to the compiled JS, with KICAD_SCRIPT_PATH
env override for custom installs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Adam Tombleson
2026-05-05 21:23:38 +05:45
parent 216d3f189d
commit f71ec03e79

View File

@@ -24,8 +24,8 @@ class KiCADServer {
constructor() { constructor() {
// Set absolute path to the Python KiCAD interface script // Set absolute path to the Python KiCAD interface script
// Using a hardcoded path to avoid cwd() issues when running from Cline this.kicadScriptPath = process.env.KICAD_SCRIPT_PATH ||
this.kicadScriptPath = "c:/repo/KiCAD-MCP/python/kicad_interface.py"; path.join(path.dirname(new URL(import.meta.url).pathname), "../python/kicad_interface.py");
// Check if script exists // Check if script exists
if (!existsSync(this.kicadScriptPath)) { if (!existsSync(this.kicadScriptPath)) {