@@ -348,7 +348,8 @@ export class ActorsMcpServer {
348348 */
349349 this . server . setRequestHandler ( CallToolRequestSchema , async ( request , extra ) => {
350350 // eslint-disable-next-line prefer-const
351- let { name, arguments : args } = request . params ;
351+ let { name, arguments : args , _meta : meta } = request . params ;
352+ const { progressToken } = meta || { } ;
352353 const apifyToken = ( request . params . apifyToken || process . env . APIFY_TOKEN ) as string ;
353354 const userRentedActorIds = request . params . userRentedActorIds as string [ ] | undefined ;
354355
@@ -433,24 +434,28 @@ export class ActorsMcpServer {
433434 try {
434435 client = await connectMCPClient ( serverTool . serverUrl , apifyToken ) ;
435436
436- // TODO: for some reason the client does not receive notifications
437- // we need to investigate this
438- // Set up notification handlers for the client
439- for ( const schema of ServerNotificationSchema . options ) {
440- const method = schema . shape . method . value ;
441- // Forward notifications from the proxy client to the server
442- client . setNotificationHandler ( schema , async ( notification ) => {
443- log . info ( 'Sending MCP notification' , {
444- method,
445- notification,
437+ // Only set up notification handlers if progressToken is provided by the client
438+ if ( progressToken ) {
439+ // Set up notification handlers for the client
440+ for ( const schema of ServerNotificationSchema . options ) {
441+ const method = schema . shape . method . value ;
442+ // Forward notifications from the proxy client to the server
443+ client . setNotificationHandler ( schema , async ( notification ) => {
444+ log . info ( 'Sending MCP notification' , {
445+ method,
446+ notification,
447+ } ) ;
448+ await extra . sendNotification ( notification ) ;
446449 } ) ;
447- await extra . sendNotification ( notification ) ;
448- } ) ;
450+ }
449451 }
450452
451453 const res = await client . callTool ( {
452454 name : serverTool . originToolName ,
453455 arguments : args ,
456+ _meta : {
457+ progressToken,
458+ } ,
454459 } , CallToolResultSchema , {
455460 timeout : EXTERNAL_TOOL_CALL_TIMEOUT_MSEC ,
456461 } ) ;
0 commit comments