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

Function upsertCodeGraphMcpServer

src/installer/targets/hermes.ts:275–297  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

273}
274
275function upsertCodeGraphMcpServer(content: string): string {
276 const lines = splitLines(content);
277 const parent = topLevelRange(lines, 'mcp_servers');
278 const child = parent ? childRange(lines, parent, 'codegraph') : null;
279 const replacement = renderCodeGraphMcpChild();
280
281 if (!parent) {
282 if (lines.length > 0 && lines[lines.length - 1] === '') lines.pop();
283 if (lines.length > 0) lines.push('');
284 lines.push(...renderCodeGraphMcpBlock());
285 return joinLines(lines);
286 }
287
288 if (child) {
289 const existing = lines.slice(child.start, child.end);
290 if (arrayEqual(existing, replacement)) return joinLines(lines);
291 lines.splice(child.start, child.end - child.start, ...replacement);
292 return joinLines(lines);
293 }
294
295 lines.splice(parent.end, 0, ...replacement);
296 return joinLines(lines);
297}
298
299function removeCodeGraphMcpServer(content: string): string {
300 const lines = splitLines(content);

Callers 1

writeHermesConfigFunction · 0.85

Calls 7

splitLinesFunction · 0.85
topLevelRangeFunction · 0.85
childRangeFunction · 0.85
renderCodeGraphMcpChildFunction · 0.85
renderCodeGraphMcpBlockFunction · 0.85
joinLinesFunction · 0.85
arrayEqualFunction · 0.85

Tested by

no test coverage detected