MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / removeCodegraphServer

Function removeCodegraphServer

src/installer/targets/json-config.ts:118–136  ·  view source on GitHub ↗
(file: string, alsoEdit: Edit = noEdit)

Source from the content-addressed store, hash-verified

116 * written through it (#2721).
117 */
118export function removeCodegraphServer(file: string, alsoEdit: Edit = noEdit): FileResult {
119 if (!fs.existsSync(file)) return { path: file, action: 'not-found' };
120 const before = fs.readFileSync(file, 'utf-8');
121 const { config, valid } = parseConfig(before);
122 if (!valid) return { path: file, action: 'not-found' };
123
124 let text = before;
125 const servers: unknown = config.mcpServers;
126 if (isObject(servers) && 'codegraph' in servers) {
127 text = editJson(text, SERVER_PATH, undefined);
128 if (Object.keys(servers).length === 1) text = editJson(text, ['mcpServers'], undefined);
129 }
130 text = alsoEdit(text);
131
132 if (text === before) return { path: file, action: 'not-found' };
133 if (/^\s*\{\s*\}\s*$/.test(text)) removeFileUnlessLinked(file, '{}\n');
134 else atomicWriteFileSync(file, text);
135 return { path: file, action: 'removed' };
136}

Callers 7

uninstallMethod · 0.90
uninstallMethod · 0.90
uninstallMethod · 0.90
uninstallMethod · 0.90
uninstallMethod · 0.90
uninstallMethod · 0.90
uninstallMethod · 0.90

Calls 5

removeFileUnlessLinkedFunction · 0.90
atomicWriteFileSyncFunction · 0.90
isObjectFunction · 0.85
editJsonFunction · 0.85
parseConfigFunction · 0.70

Tested by

no test coverage detected