File tree Expand file tree Collapse file tree
src/ModelContextProtocol.AspNetCore/Authentication Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,8 +43,9 @@ public async Task<bool> HandleRequestAsync()
4343 return false ;
4444 }
4545
46- // This is a request for resource metadata - handle it
47- await HandleResourceMetadataRequestAsync ( ) ;
46+ // Use the request's cancellation token if available
47+ var cancellationToken = Request . HttpContext . RequestAborted ;
48+ await HandleResourceMetadataRequestAsync ( cancellationToken ) ;
4849 return true ;
4950 }
5051
@@ -87,7 +88,8 @@ private string GetAbsoluteResourceMetadataUri()
8788 /// <summary>
8889 /// Handles the resource metadata request.
8990 /// </summary>
90- private async Task HandleResourceMetadataRequestAsync ( )
91+ /// <param name="cancellationToken">A token to cancel the operation.</param>
92+ private Task HandleResourceMetadataRequestAsync ( CancellationToken cancellationToken = default )
9193 {
9294 // Get resource metadata from options, using the dynamic provider if available
9395 var options = _optionsMonitor . CurrentValue ;
@@ -113,7 +115,7 @@ private async Task HandleResourceMetadataRequestAsync()
113115 metadata ,
114116 McpJsonUtilities . DefaultOptions . GetTypeInfo ( typeof ( ProtectedResourceMetadata ) ) ) ;
115117
116- await Response . WriteAsync ( json ) ;
118+ return Response . WriteAsync ( json , cancellationToken ) ;
117119 }
118120
119121 /// <inheritdoc />
You can’t perform that action at this time.
0 commit comments