@@ -489,7 +489,8 @@ private void RegisterTaskHandlers(RequestHandlers requestHandlers, IMcpTaskStore
489489 // Advertise task capabilities
490490 _options . Capabilities ??= new ( ) ;
491491
492- // Advertise MRTR support so servers can use IncompleteResult instead of legacy JSON-RPC requests.
492+ // Advertise MRTR support so servers can return IncompleteResult to request input inline
493+ // instead of sending separate server-to-client JSON-RPC requests.
493494 var experimental = _options . Capabilities . Experimental ??= new Dictionary < string , object > ( ) ;
494495 experimental [ MrtrContext . ExperimentalCapabilityKey ] = new JsonObject ( ) ;
495496 var tasksCapability = _options . Capabilities . Tasks ??= new McpTasksCapability ( ) ;
@@ -559,10 +560,11 @@ private async Task<InputResponse> ResolveInputRequestAsync(InputRequest inputReq
559560 case RequestMethods . SamplingCreateMessage :
560561 if ( _options . Handlers . SamplingHandler is { } samplingHandler )
561562 {
562- var samplingParams = inputRequest . SamplingParams ;
563+ var samplingParams = inputRequest . SamplingParams
564+ ?? throw new McpException ( $ "Failed to deserialize sampling parameters from MRTR input request.") ;
563565 var result = await samplingHandler (
564566 samplingParams ,
565- samplingParams ? . ProgressToken is { } token ? new TokenProgress ( this , token ) : NullProgress . Instance ,
567+ samplingParams . ProgressToken is { } token ? new TokenProgress ( this , token ) : NullProgress . Instance ,
566568 cancellationToken ) . ConfigureAwait ( false ) ;
567569 return InputResponse . FromSamplingResult ( result ) ;
568570 }
@@ -573,7 +575,8 @@ private async Task<InputResponse> ResolveInputRequestAsync(InputRequest inputReq
573575 case RequestMethods . ElicitationCreate :
574576 if ( _options . Handlers . ElicitationHandler is { } elicitationHandler )
575577 {
576- var elicitParams = inputRequest . ElicitationParams ;
578+ var elicitParams = inputRequest . ElicitationParams
579+ ?? throw new McpException ( $ "Failed to deserialize elicitation parameters from MRTR input request.") ;
577580 var result = await elicitationHandler ( elicitParams , cancellationToken ) . ConfigureAwait ( false ) ;
578581 result = ElicitResult . WithDefaults ( elicitParams , result ) ;
579582 return InputResponse . FromElicitResult ( result ) ;
@@ -585,7 +588,8 @@ private async Task<InputResponse> ResolveInputRequestAsync(InputRequest inputReq
585588 case RequestMethods . RootsList :
586589 if ( _options . Handlers . RootsHandler is { } rootsHandler )
587590 {
588- var rootsParams = inputRequest . RootsParams ;
591+ var rootsParams = inputRequest . RootsParams
592+ ?? throw new McpException ( $ "Failed to deserialize roots parameters from MRTR input request.") ;
589593 var result = await rootsHandler ( rootsParams , cancellationToken ) . ConfigureAwait ( false ) ;
590594 return InputResponse . FromRootsResult ( result ) ;
591595 }
0 commit comments