From b112b5357a23a72c0df9054a64010536159eff0f Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 4 Mar 2026 07:40:01 +0000 Subject: [PATCH] fix: wrap logToolCall in try-catch to prevent cascading failures Matches the pattern used by logApiRequest and recordQuotaUsage. Without this, a missing mcp_tool_calls table causes the entire API response to fail even when tool execution succeeds. Co-Authored-By: Claude Opus 4.6 --- src/Mcp/Controllers/McpApiController.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Mcp/Controllers/McpApiController.php b/src/Mcp/Controllers/McpApiController.php index d561486..3cb9e7a 100644 --- a/src/Mcp/Controllers/McpApiController.php +++ b/src/Mcp/Controllers/McpApiController.php @@ -307,15 +307,20 @@ class McpApiController extends Controller bool $success, ?string $error = null ): void { - McpToolCall::log( - serverId: $request['server'], - toolName: $request['tool'], - params: $request['arguments'] ?? [], - success: $success, - durationMs: $durationMs, - errorMessage: $error, - workspaceId: $apiKey?->workspace_id - ); + try { + McpToolCall::log( + serverId: $request['server'], + toolName: $request['tool'], + params: $request['arguments'] ?? [], + success: $success, + durationMs: $durationMs, + errorMessage: $error, + workspaceId: $apiKey?->workspace_id + ); + } catch (\Throwable $e) { + // Don't let logging failures affect API response + report($e); + } } /**