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

Method initFromRoots

src/mcp/session.ts:334–349  ·  view source on GitHub ↗

* Ask the client for its workspace root via `roots/list` and open the * first one. Falls back to `process.cwd()` on timeout or empty answer.

()

Source from the content-addressed store, hash-verified

332 * first one. Falls back to `process.cwd()` on timeout or empty answer.
333 */
334 private async initFromRoots(): Promise<void> {
335 let target = process.cwd();
336 try {
337 const result = await this.transport.request('roots/list', undefined, ROOTS_LIST_TIMEOUT_MS);
338 const rootPath = firstRootPath(result);
339 if (rootPath) {
340 target = rootPath;
341 } else {
342 process.stderr.write('[CodeGraph MCP] Client returned no workspace roots; falling back to process cwd.\n');
343 }
344 } catch (err) {
345 const msg = err instanceof Error ? err.message : String(err);
346 process.stderr.write(`[CodeGraph MCP] roots/list request failed (${msg}); falling back to process cwd.\n`);
347 }
348 await this.engine.ensureInitialized(target);
349 }
350}

Callers 1

retryInitIfNeededMethod · 0.95

Calls 4

firstRootPathFunction · 0.85
ensureInitializedMethod · 0.80
requestMethod · 0.65
writeMethod · 0.45

Tested by

no test coverage detected