{ "mcpServers": { "layermap": { "command": "node", "args": [ "--input-type=module", "-e", "// Generated from scripts/launcher.mjs.\n// Runs one LayerMap version in this process: its MCP server, or, for the layermap command of the\n// Claude Code plugin, its command line with the arguments given. The version is installed once into\n// LayerMap's cache, from where every later start runs without npm or a network. The agent starts\n// this in the project, which stays the working directory the server maps; npm runs in the cache,\n// so the project's own npm settings and packages play no part in what gets installed.\nimport { spawn } from \"node:child_process\";\nimport {\n existsSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nconst VERSION = \"0.1.53\";\nconst ARGUMENTS = [\"mcp\"];\n\n// The same directory as cacheDirectory in src/agent/environment.ts.\nconst env = process.env;\nconst cache = env.LAYERMAP_CACHE\n ? path.resolve(env.LAYERMAP_CACHE)\n : process.platform === \"darwin\"\n ? path.join(homedir(), \"Library\", \"Caches\", \"layermap\")\n : process.platform === \"win32\"\n ? path.join(env.LOCALAPPDATA || path.join(homedir(), \"AppData\", \"Local\"), \"layermap\", \"Cache\")\n : path.join(env.XDG_CACHE_HOME || path.join(homedir(), \".cache\"), \"layermap\");\nconst versions = path.join(cache, \"versions\");\nconst home = path.join(versions, VERSION);\nconst installed = path.join(home, \"node_modules\", \"layermap\");\nconst manifest = path.join(installed, \"package.json\");\n\n// The npm of the Node running this, else the one on PATH.\nconst npm = () => {\n const directory = path.dirname(process.execPath);\n for (const cli of [\n path.join(directory, \"node_modules\", \"npm\", \"bin\", \"npm-cli.js\"),\n path.join(directory, \"..\", \"lib\", \"node_modules\", \"npm\", \"bin\", \"npm-cli.js\"),\n ])\n if (existsSync(cli)) return [process.execPath, [cli]];\n if (process.platform === \"win32\") throw new Error(`no npm beside ${process.execPath}`);\n return [\"npm\", []];\n};\n\n// npm installs into a directory of its own, renamed into place once complete, so no server starts\n// from half an install, and two starting at once both end up with the one that was renamed first.\n// --prefer-online has npm ask the registry for the versions it has, which a cached list may lack.\nasync function install() {\n mkdirSync(versions, { recursive: true, mode: 0o700 });\n const staging = mkdtempSync(path.join(versions, `.${VERSION}-`));\n process.stderr.write(`layermap: installing layermap@${VERSION} with npm\\n`);\n const [command, prefix] = npm();\n const args = [\n ...prefix,\n \"install\",\n `layermap@${VERSION}`,\n \"--prefix\",\n staging,\n \"--prefer-online\",\n \"--omit=dev\",\n \"--no-audit\",\n \"--no-fund\",\n \"--no-update-notifier\",\n \"--loglevel=error\",\n ];\n await new Promise((resolve, reject) => {\n const child = spawn(command, args, {\n cwd: staging,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n windowsHide: true,\n });\n let output = \"\";\n child.stdout.on(\"data\", (data) => (output += data));\n child.stderr.on(\"data\", (data) => (output += data));\n child.on(\"error\", reject);\n child.on(\"close\", (code) =>\n code === 0 ? resolve() : reject(new Error(`npm exited with ${code}\\n${output.trim()}`)),\n );\n }).catch((error) => {\n rmSync(staging, { recursive: true, force: true });\n throw error;\n });\n try {\n renameSync(staging, home);\n } catch (error) {\n rmSync(staging, { recursive: true, force: true });\n if (!existsSync(manifest)) throw error;\n }\n}\n\ntry {\n if (!existsSync(manifest)) await install();\n // LayerMap removes a version from its cache once nothing has started it for a week.\n writeFileSync(path.join(home, \"last-used\"), \"\");\n const entry = path.join(installed, JSON.parse(readFileSync(manifest, \"utf8\")).bin.layermap);\n process.argv = [process.argv[0], entry, ...ARGUMENTS];\n await import(pathToFileURL(entry).href);\n} catch (error) {\n process.stderr.write(\n `layermap: could not start LayerMap ${VERSION}: ${error?.message ?? error}\\n`,\n );\n process.exit(1);\n}\n" ], "startup_timeout_sec": 120, "tool_timeout_sec": 300, "default_tools_approval_mode": "approve" } } }