* 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.
()
| 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 | } |
no test coverage detected