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

Method run

src/mcp/query-pool.ts:461–478  ·  view source on GitHub ↗

Run a read tool on the pool. Always resolves (never rejects).

(toolName: string, args: Record<string, unknown>)

Source from the content-addressed store, hash-verified

459
460 /** Run a read tool on the pool. Always resolves (never rejects). */
461 run(toolName: string, args: Record<string, unknown>): Promise<ToolResult> {
462 this.clearIdleShrink();
463 return new Promise<ToolResult>((resolve) => {
464 const job: Job = {
465 id: this.nextId++, toolName, args, resolve,
466 retries: 0, settled: false, enqueuedAt: Date.now(),
467 };
468 // Don't let the caller wait past softTimeoutMs. The worker may still be
469 // busy (we can't cancel synchronous CPU), but the CLIENT gets a prompt,
470 // success-shaped "retry" instead of a hard timeout.
471 job.softTimer = setTimeout(() => {
472 if (!job.settled) this.settle(job, busyGuidance(Date.now() - job.enqueuedAt));
473 }, this.softTimeoutMs);
474 job.softTimer.unref?.();
475 this.queue.push(job);
476 this.drain();
477 });
478 }
479
480 /**
481 * {@link run}, but only when a warm worker is idle right now, so the call

Callers 1

tryRunMethod · 0.95

Calls 5

clearIdleShrinkMethod · 0.95
settleMethod · 0.95
drainMethod · 0.95
busyGuidanceFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected