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

Method run

src/mcp/query-pool.ts:493–510  ·  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

491
492 /** Run a read tool on the pool. Always resolves (never rejects). */
493 run(toolName: string, args: Record<string, unknown>): Promise<ToolResult> {
494 this.clearIdleShrink();
495 return new Promise<ToolResult>((resolve) => {
496 const job: Job = {
497 id: this.nextId++, toolName, args, resolve,
498 retries: 0, settled: false, enqueuedAt: Date.now(),
499 };
500 // Don't let the caller wait past softTimeoutMs. The worker may still be
501 // busy (we can't cancel synchronous CPU), but the CLIENT gets a prompt,
502 // success-shaped "retry" instead of a hard timeout.
503 job.softTimer = setTimeout(() => {
504 if (!job.settled) this.answerBusy(job);
505 }, this.softTimeoutMs);
506 job.softTimer.unref?.();
507 this.queue.push(job);
508 this.drain();
509 });
510 }
511
512 /**
513 * The backstop: answer a caller whose call is not done, and say in the log

Callers 1

tryRunMethod · 0.95

Calls 4

clearIdleShrinkMethod · 0.95
answerBusyMethod · 0.95
drainMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected