@@ -39,6 +39,7 @@ import { callActorGetDataset, defaultTools, getActorsAsTools, toolCategories } f
3939import { decodeDotPropertyNames } from '../tools/utils.js' ;
4040import type { ToolEntry } from '../types.js' ;
4141import { buildActorResponseContent } from '../utils/actor-response.js' ;
42+ import { logHttpError } from '../utils/logging.js' ;
4243import { buildMCPResponse } from '../utils/mcp.js' ;
4344import { createProgressTracker } from '../utils/progress.js' ;
4445import { cloneToolEntry , getToolPublicFieldOnly } from '../utils/tools.js' ;
@@ -483,7 +484,7 @@ export class ActorsMcpServer {
483484 // Validate token
484485 if ( ! apifyToken && ! this . options . skyfireMode ) {
485486 const msg = 'APIFY_TOKEN is required. It must be set in the environment variables or passed as a parameter in the body.' ;
486- log . error ( msg ) ;
487+ log . softFail ( msg , { statusCode : 400 } ) ;
487488 await this . server . sendLoggingMessage ( { level : 'error' , data : msg } ) ;
488489 throw new McpError (
489490 ErrorCode . InvalidParams ,
@@ -507,7 +508,7 @@ export class ActorsMcpServer {
507508 . find ( ( t ) => t . name === name || ( t . type === 'actor' && t . actorFullName === name ) ) ;
508509 if ( ! tool ) {
509510 const msg = `Tool ${ name } not found. Available tools: ${ this . listToolNames ( ) . join ( ', ' ) } ` ;
510- log . error ( msg ) ;
511+ log . softFail ( msg , { statusCode : 404 } ) ;
511512 await this . server . sendLoggingMessage ( { level : 'error' , data : msg } ) ;
512513 throw new McpError (
513514 ErrorCode . InvalidParams ,
@@ -516,7 +517,7 @@ export class ActorsMcpServer {
516517 }
517518 if ( ! args ) {
518519 const msg = `Missing arguments for tool ${ name } ` ;
519- log . error ( msg ) ;
520+ log . softFail ( msg , { statusCode : 400 } ) ;
520521 await this . server . sendLoggingMessage ( { level : 'error' , data : msg } ) ;
521522 throw new McpError (
522523 ErrorCode . InvalidParams ,
@@ -529,7 +530,7 @@ export class ActorsMcpServer {
529530 log . debug ( 'Validate arguments for tool' , { toolName : tool . name , input : args } ) ;
530531 if ( ! tool . ajvValidate ( args ) ) {
531532 const msg = `Invalid arguments for tool ${ tool . name } : args: ${ JSON . stringify ( args ) } error: ${ JSON . stringify ( tool ?. ajvValidate . errors ) } ` ;
532- log . error ( msg ) ;
533+ log . softFail ( msg , { statusCode : 400 } ) ;
533534 await this . server . sendLoggingMessage ( { level : 'error' , data : msg } ) ;
534535 throw new McpError (
535536 ErrorCode . InvalidParams ,
@@ -569,7 +570,9 @@ export class ActorsMcpServer {
569570 client = await connectMCPClient ( tool . serverUrl , apifyToken ) ;
570571 if ( ! client ) {
571572 const msg = `Failed to connect to MCP server ${ tool . serverUrl } ` ;
572- log . error ( msg ) ;
573+ // Note: Timeout errors are already logged as warning in connectMCPClient
574+ // This is a fallback log for when connection fails (client-side issue)
575+ log . softFail ( msg , { statusCode : 408 } ) ; // 408 Request Timeout
573576 await this . server . sendLoggingMessage ( { level : 'error' , data : msg } ) ;
574577 return {
575578 content : [
@@ -663,15 +666,15 @@ export class ActorsMcpServer {
663666 }
664667 }
665668 } catch ( error ) {
666- log . error ( 'Error occurred while calling tool' , { toolName : name , error } ) ;
669+ logHttpError ( error , 'Error occurred while calling tool' , { toolName : name } ) ;
667670 const errorMessage = ( error instanceof Error ) ? error . message : 'Unknown error' ;
668671 return buildMCPResponse ( [
669672 `Error calling tool ${ name } : ${ errorMessage } ` ,
670673 ] ) ;
671674 }
672675
673676 const msg = `Unknown tool: ${ name } ` ;
674- log . error ( msg ) ;
677+ log . softFail ( msg , { statusCode : 404 } ) ;
675678 await this . server . sendLoggingMessage ( {
676679 level : 'error' ,
677680 data : msg ,
0 commit comments