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 --- src/main/index.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') 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