MCPcopy
hub / github.com/colbymchenry/codegraph / handleToolsCall

Method handleToolsCall

src/mcp/session.ts:239–270  ·  view source on GitHub ↗
(request: JsonRpcRequest)

Source from the content-addressed store, hash-verified

237 }
238
239 private async handleToolsCall(request: JsonRpcRequest): Promise<void> {
240 const params = request.params as {
241 name: string;
242 arguments?: Record<string, unknown>;
243 };
244
245 if (!params || !params.name) {
246 this.transport.sendError(request.id, ErrorCodes.InvalidParams, 'Missing tool name');
247 return;
248 }
249
250 const toolName = params.name;
251 const toolArgs = params.arguments || {};
252
253 const tool = tools.find((t) => t.name === toolName);
254 if (!tool) {
255 this.transport.sendError(
256 request.id,
257 ErrorCodes.InvalidParams,
258 `Unknown tool: ${toolName}`,
259 );
260 return;
261 }
262
263 await this.retryInitIfNeeded();
264
265 const result = await this.engine.getToolHandler().execute(toolName, toolArgs);
266 this.transport.sendResult(request.id, result);
267 // After the reply is on the wire — telemetry must never delay a tool
268 // response (in-memory increment only; see src/telemetry).
269 getTelemetry().recordUsage('mcp_tool', toolName, !result.isError, this.clientInfo);
270 }
271
272 /**
273 * Lazy default-project resolution. Three layers:

Callers 1

handleMessageMethod · 0.95

Calls 7

retryInitIfNeededMethod · 0.95
getTelemetryFunction · 0.90
sendErrorMethod · 0.80
executeMethod · 0.80
getToolHandlerMethod · 0.80
sendResultMethod · 0.80
recordUsageMethod · 0.80

Tested by

no test coverage detected