MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / uninstallMcpForClient

Function uninstallMcpForClient

apps/desktop/src/main/mcp-integrations.ts:410–452  ·  view source on GitHub ↗
(id: McpClientId)

Source from the content-addressed store, hash-verified

408}
409
410export async function uninstallMcpForClient(id: McpClientId): Promise<McpClientStatus> {
411 const descriptor = MCP_CLIENTS.find((c) => c.id === id)
412 if (!descriptor) throw new Error(`Unknown MCP client: ${id}`)
413 const configPath = clientConfigPath(descriptor)
414
415 if (descriptor.format === 'json') {
416 const cfg = await readJsonConfig(configPath)
417 if (cfg.mcpServers && cfg.mcpServers[descriptor.serverKey]) {
418 const nextServers = { ...cfg.mcpServers }
419 delete nextServers[descriptor.serverKey]
420 const next: JsonMcpConfig = { ...cfg }
421 if (Object.keys(nextServers).length === 0) {
422 delete next.mcpServers
423 } else {
424 next.mcpServers = nextServers
425 }
426 await writeJsonConfig(configPath, next)
427 }
428 } else if (descriptor.format === 'opencode') {
429 const raw = await readTomlFile(configPath)
430 const cfg = readOpenCodeConfig(raw)
431 if (cfg.mcp?.[descriptor.serverKey]) {
432 const next: OpenCodeConfig = { ...cfg }
433 const mcp = { ...cfg.mcp }
434 delete mcp[descriptor.serverKey]
435 if (Object.keys(mcp).length === 0) {
436 delete next.mcp
437 } else {
438 next.mcp = mcp
439 }
440 await fsp.mkdir(path.dirname(configPath), { recursive: true })
441 await fsp.writeFile(configPath, JSON.stringify(next, null, 2) + '\n', 'utf8')
442 }
443 } else {
444 const raw = await readTomlFile(configPath)
445 if (raw.includes(MARK_START)) {
446 const stripped = stripManagedBlock(raw)
447 await writeTomlFile(configPath, stripped)
448 }
449 }
450
451 return (await getMcpClientStatuses()).find((s) => s.id === id)!
452}
453
454// Exported for tests / renderer diagnostics if ever useful.
455export const __internal = {

Callers 1

registerIpcFunction · 0.90

Calls 8

clientConfigPathFunction · 0.85
readJsonConfigFunction · 0.85
writeJsonConfigFunction · 0.85
readTomlFileFunction · 0.85
readOpenCodeConfigFunction · 0.85
stripManagedBlockFunction · 0.85
writeTomlFileFunction · 0.85
getMcpClientStatusesFunction · 0.85

Tested by

no test coverage detected