From d0162055842e5343bca54153f8f9ce83d969f2a3 Mon Sep 17 00:00:00 2001 From: haoyuren <13851610112@163.com> Date: Sun, 15 Mar 2026 14:13:21 -0500 Subject: Fix MCP server in packaged app: bundle with esbuild, asarUnpack MCP server was not included in DMG builds. Now esbuild bundles it into a single file (out/mcp/lattex.mjs) with all dependencies inlined, and electron-builder unpacks it from asar so external node can execute it. Co-Authored-By: Claude Opus 4.6 --- src/main/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/index.ts') diff --git a/src/main/index.ts b/src/main/index.ts index b6648bb..4169079 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -752,8 +752,10 @@ ipcMain.handle('ot:connect', async (_e, projectId: string) => { mcpPathDocMap = pathDocMap writeMcpState() // Write .mcp.json so Claude Code auto-discovers the MCP server - const appRoot = app.isPackaged ? join(app.getAppPath(), '..') : join(__dirname, '..', '..') - const mcpServerPath = join(appRoot, 'src', 'mcp', 'lattex.mjs') + // Dev: use source file. Packaged: use bundled file in app.asar.unpacked/out/mcp/ + const mcpServerPath = app.isPackaged + ? join(app.getAppPath() + '.unpacked', 'out', 'mcp', 'lattex.mjs') + : join(__dirname, '..', '..', 'src', 'mcp', 'lattex.mjs') writeFile(join(tmpDir, '.mcp.json'), JSON.stringify({ mcpServers: { lattex: { -- cgit v1.2.3