(request: JsonRpcRequest)
| 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: |
no test coverage detected