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

Method maybeStartPool

src/mcp/engine.ts:152–172  ·  view source on GitHub ↗

* Start the worker-thread query pool after resolving the default project * (which may be absent). Honors `CODEGRAPH_QUERY_POOL_SIZE`; best-effort: * if workers can't spawn on this platform the ToolHandler keeps serving reads * in-process, so the pool can only help, never break, tool calls.

(root: string | null)

Source from the content-addressed store, hash-verified

150 * in-process, so the pool can only help, never break, tool calls.
151 */
152 private maybeStartPool(root: string | null): void {
153 if (this.opts.readOnly || !this.opts.queryPool || this.queryPool || this.closed) return;
154 const envSize = process.env.CODEGRAPH_QUERY_POOL_SIZE;
155 let size = resolvePoolSize(envSize, os.cpus().length);
156 if ((envSize === undefined || envSize === '') && this.opts.queryPoolDefaultMax !== undefined) {
157 size = Math.min(size, this.opts.queryPoolDefaultMax);
158 }
159 if (size <= 0) {
160 process.stderr.write('[CodeGraph MCP] Query pool disabled (CODEGRAPH_QUERY_POOL_SIZE=0); serving reads in-process.\n');
161 return;
162 }
163 try {
164 this.queryPool = new QueryPool({ root, size });
165 this.toolHandler.setQueryPool(this.queryPool);
166 process.stderr.write(`[CodeGraph MCP] Query pool: up to ${size} worker thread(s) for concurrent reads.\n`);
167 } catch (err) {
168 const msg = err instanceof Error ? err.message : String(err);
169 process.stderr.write(`[CodeGraph MCP] Query pool unavailable (${msg}); serving reads in-process.\n`);
170 this.queryPool = null;
171 }
172 }
173
174 /**
175 * Convenience for {@link MCPServer} compatibility: pre-seed an explicit

Callers 2

retryInitializeSyncMethod · 0.95
doInitializeMethod · 0.95

Calls 3

resolvePoolSizeFunction · 0.90
setQueryPoolMethod · 0.80
writeMethod · 0.65

Tested by

no test coverage detected