From e5e25d0e13b2e054cc7e2ca206b7ea70ee3bf4c2 Mon Sep 17 00:00:00 2001 From: haoyuren <13851610112@163.com> Date: Sat, 25 Apr 2026 19:15:49 -0300 Subject: Fix Claude MCP project registration --- package-lock.json | 4 ++-- package.json | 2 +- src/main/index.ts | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7758397..d398421 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lattex", - "version": "0.3.8", + "version": "0.3.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lattex", - "version": "0.3.8", + "version": "0.3.9", "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { diff --git a/package.json b/package.json index 6f0f39d..bbe0f95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lattex", - "version": "0.3.8", + "version": "0.3.9", "description": "LaTeX editor with real-time Overleaf sync", "license": "AGPL-3.0", "author": "Yuren Hao", diff --git a/src/main/index.ts b/src/main/index.ts index 0ad1ed1..4d06ebd 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -64,6 +64,26 @@ async function prepareMcpServerPath(tmpDir: string): Promise { return serverPath } +async function clearDisabledLattexMcpServer(tmpDir: string): Promise { + const settingsPath = join(tmpDir, '.claude', 'settings.local.json') + try { + const raw = await readFile(settingsPath, 'utf-8') + const settings = JSON.parse(raw) as Record + const disabled = settings.disabledMcpjsonServers + if (!Array.isArray(disabled) || !disabled.includes('lattex')) return + + const nextDisabled = disabled.filter((name) => name !== 'lattex') + if (nextDisabled.length > 0) { + settings.disabledMcpjsonServers = nextDisabled + } else { + delete settings.disabledMcpjsonServers + } + await writeFile(settingsPath, JSON.stringify(settings, null, 2)) + } catch { + // No local settings yet, or not JSON. Claude can create it later. + } +} + let commentContextRefreshTimer: ReturnType | null = null function scheduleCommentContextRefresh(): void { if (commentContextRefreshTimer) clearTimeout(commentContextRefreshTimer) @@ -854,11 +874,13 @@ ipcMain.handle('ot:connect', async (_e, projectId: string) => { await writeFile(join(tmpDir, '.mcp.json'), JSON.stringify({ mcpServers: { lattex: { + type: 'stdio', command: 'node', args: [mcpServerPath] } } }, null, 2)) + await clearDisabledLattexMcpServer(tmpDir) } catch (e) { console.log('[mcp] failed to write MCP config:', e) } -- cgit v1.2.3