MCPcopy
hub / github.com/colbymchenry/codegraph / doInitialize

Method doInitialize

src/mcp/engine.ts:201–222  ·  view source on GitHub ↗
(searchFrom: string)

Source from the content-addressed store, hash-verified

199 }
200
201 private async doInitialize(searchFrom: string): Promise<void> {
202 this.toolHandler.setDefaultProjectHint(searchFrom);
203
204 const resolvedRoot = findNearestCodeGraphRoot(searchFrom);
205 if (!resolvedRoot) {
206 // No .codegraph/ above searchFrom. Sessions may still discover one later via roots/list
207 this.projectPath = searchFrom;
208 return;
209 }
210
211 this.projectPath = resolvedRoot;
212 try {
213 this.cg = await loadCodeGraph().open(resolvedRoot);
214 this.toolHandler.setDefaultCodeGraph(this.cg);
215 this.startWatching();
216 this.catchUpSync();
217 this.maybeStartPool(resolvedRoot);
218 } catch (err) {
219 const msg = err instanceof Error ? err.message : String(err);
220 process.stderr.write(`[CodeGraph MCP] Failed to open project at ${resolvedRoot}: ${msg}\n`);
221 }
222 }
223
224 /**
225 * Start file watching on the active CodeGraph instance. Idempotent — the

Callers 1

ensureInitializedMethod · 0.95

Calls 9

startWatchingMethod · 0.95
catchUpSyncMethod · 0.95
maybeStartPoolMethod · 0.95
findNearestCodeGraphRootFunction · 0.90
setDefaultProjectHintMethod · 0.80
setDefaultCodeGraphMethod · 0.80
loadCodeGraphFunction · 0.70
openMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected