fix(mcp): resolve the pool's project root only when the pool serves the call (#2027)

The #1465 change read the default project root on every tool call, before
checking whether a query worker would serve it. Resolve it only for a pooled
call; in-process dispatch no longer depends on it (restores the oversized-output
truncation test).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-09-27 13:29:07 +00:00
committed by GitHub
parent 9ad6ee9c9a
commit 6f31afd499
+4 -3
View File
@@ -2228,9 +2228,10 @@ export class ToolHandler {
// The default may have appeared after the workers started. Pass the
// main thread's current root explicitly; with no root or projectPath,
// keep the main handler's workspace-specific not-indexed guidance.
const projectPath = args.projectPath ?? this.cg?.getProjectRoot();
const raw = (projectPath && this.queryPool && this.queryPool.healthy && this.queryPool.ready)
? await this.queryPool.run(toolName, { ...dispatchArgs, projectPath })
const pooled = !!(this.queryPool && this.queryPool.healthy && this.queryPool.ready);
const projectPath = pooled ? args.projectPath ?? this.cg?.getProjectRoot() : undefined;
const raw = (pooled && projectPath)
? await this.queryPool!.run(toolName, { ...dispatchArgs, projectPath })
: await this.executeReadTool(toolName, dispatchArgs);
// Record + STRIP before anything else touches the result: the emission is
// internal bookkeeping and must never reach the client, whether or not a