Skip to content

Commit 7c6e406

Browse files
committed
Update based on feedback
1 parent 0b030c2 commit 7c6e406

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/ModelContextProtocol.AspNetCore/Authentication/McpAuthenticationHandler.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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 />

0 commit comments

Comments
 (0)