From 9f77d47c6e93554bc3f1dc6d9c11ed5e94826f26 Mon Sep 17 00:00:00 2001 From: Adam Tombleson Date: Tue, 5 May 2026 21:26:48 +0545 Subject: [PATCH] fix: use fileURLToPath for cross-platform compatibility import.meta.url.pathname returns /C:/... on Windows (leading slash), breaking path.join. fileURLToPath handles Windows paths correctly. Co-Authored-By: Claude Sonnet 4.6 --- src/kicad-server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kicad-server.ts b/src/kicad-server.ts index 5cd4ed0..e7ad4d7 100644 --- a/src/kicad-server.ts +++ b/src/kicad-server.ts @@ -4,6 +4,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js"; import { spawn, ChildProcess } from "child_process"; import { existsSync } from "fs"; +import { fileURLToPath } from "url"; import path from "path"; // Import all tool definitions for reference @@ -25,7 +26,7 @@ class KiCADServer { constructor() { // Set absolute path to the Python KiCAD interface script this.kicadScriptPath = process.env.KICAD_SCRIPT_PATH || - path.join(path.dirname(new URL(import.meta.url).pathname), "../python/kicad_interface.py"); + path.join(path.dirname(fileURLToPath(import.meta.url)), "../python/kicad_interface.py"); // Check if script exists if (!existsSync(this.kicadScriptPath)) {