File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ import { getToolPublicFieldOnly } from '../utils/tools.js';
4444import { connectMCPClient } from './client.js' ;
4545import { EXTERNAL_TOOL_CALL_TIMEOUT_MSEC , LOG_LEVEL_MAP } from './const.js' ;
4646import { processParamsGetTools } from './utils.js' ;
47+ import { buildMCPResponse } from '../utils/mcp.js' ;
4748
4849type ToolsChangedHandler = ( toolNames : string [ ] ) => void ;
4950
@@ -654,19 +655,11 @@ export class ActorsMcpServer {
654655 }
655656 }
656657 } catch ( error ) {
657- if ( error instanceof ApifyApiError ) {
658- log . error ( 'Apify API error calling tool' , { toolName : name , error } ) ;
659- return {
660- content : [
661- { type : 'text' , text : `Apify API error calling tool ${ name } : ${ error . message } ` } ,
662- ] ,
663- } ;
664- }
665- log . error ( 'Error calling tool' , { toolName : name , error } ) ;
666- throw new McpError (
667- ErrorCode . InternalError ,
668- `An error occurred while calling the tool.` ,
669- ) ;
658+ log . error ( 'Error occurred while calling tool' , { toolName : name , error } ) ;
659+ const errorMessage = ( error instanceof Error ) ? error . message : 'Unknown error' ;
660+ return buildMCPResponse ( [
661+ `Error calling tool ${ name } : ${ errorMessage } ` ,
662+ ] ) ;
670663 }
671664
672665 const msg = `Unknown tool: ${ name } ` ;
You can’t perform that action at this time.
0 commit comments