File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66- improved MCP client interruption handling
77- properly adding user input messages to the input history when using MCP tools
88- wrapping long tool message content
9+ - better handling of MCP tool errors
910
1011## [ 0.3.2]
1112
Original file line number Diff line number Diff line change @@ -321,19 +321,30 @@ export class McpClient {
321321
322322 project . sendToolMessage ( toolCall . name , toolCall . args ) ;
323323
324- const toolResponse = await selectedTool . invoke ( toolCall ) ;
324+ try {
325+ const toolResponse = await selectedTool . invoke ( toolCall ) ;
325326
326- logger . debug ( `Tool ${ toolCall . name } returned response` , {
327- toolResponse,
328- } ) ;
329- if ( ! toolResponse ) {
330- logger . warn ( `Tool ${ toolCall . name } didn't return a response` ) ;
331- return null ;
327+ logger . debug ( `Tool ${ toolCall . name } returned response` , {
328+ toolResponse,
329+ } ) ;
330+ if ( ! toolResponse ) {
331+ logger . warn ( `Tool ${ toolCall . name } didn't return a response` ) ;
332+ return null ;
333+ }
334+
335+ // Add tool message to messages
336+ messages . push ( toolResponse ) ;
337+ } catch ( error ) {
338+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
339+ logger . error ( `Error invoking tool ${ toolCall . name } :` , error ) ;
340+
341+ // Send log message about the tool error
342+ project . sendLogMessage ( 'error' , `Tool ${ toolCall . name } failed: ${ errorMessage } ` ) ;
343+
344+ // Add user message to messages for next iteration
345+ messages . push ( new HumanMessage ( errorMessage ) ) ;
332346 }
333347
334- // Add tool message to messages
335- messages . push ( toolResponse ) ;
336-
337348 // Update the last tool call time after the delay
338349 this . lastToolCallTime = Date . now ( ) ;
339350 }
You can’t perform that action at this time.
0 commit comments