diff --git a/src/kicad-server.ts b/src/kicad-server.ts index f77bcac..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 @@ -24,8 +25,8 @@ class KiCADServer { constructor() { // Set absolute path to the Python KiCAD interface script - // Using a hardcoded path to avoid cwd() issues when running from Cline - this.kicadScriptPath = "c:/repo/KiCAD-MCP/python/kicad_interface.py"; + this.kicadScriptPath = process.env.KICAD_SCRIPT_PATH || + path.join(path.dirname(fileURLToPath(import.meta.url)), "../python/kicad_interface.py"); // Check if script exists if (!existsSync(this.kicadScriptPath)) {