Skip to content

Commit da21e43

Browse files
committed
PR feedback
1 parent b157630 commit da21e43

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ await WriteJsonRpcErrorAsync(context,
154154
{
155155
await using var _ = await session.AcquireReferenceAsync(cancellationToken);
156156
InitializeSseResponse(context);
157+
158+
// We should flush headers to indicate a 200 success quickly, because the initialization response
159+
// will be sent in response to a different POST request. It might be a while before we send a message
160+
// over this response body.
161+
await context.Response.StartAsync(cancellationToken);
157162
await session.Transport.HandleGetRequestAsync(context.Response.Body, cancellationToken);
158163
}
159164
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)

src/ModelContextProtocol.Core/Server/StreamableHttpServerTransport.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ public async Task HandleGetRequestAsync(Stream sseResponseStream, CancellationTo
125125
var primingItem = await _storeSseWriter.WriteEventAsync(SseItem.Prime<JsonRpcMessage>(), cancellationToken).ConfigureAwait(false);
126126
await _httpSseWriter.WriteAsync(primingItem, cancellationToken).ConfigureAwait(false);
127127
}
128-
129-
// We should flush to indicate a 200 success quickly, because the initialization response
130-
// will be sent in response to a different POST request. It might be a while before we send a message
131-
// over this response body.
132-
await sseResponseStream.FlushAsync(cancellationToken).ConfigureAwait(false);
133128
}
134129

135130
// Wait for the response to be written before returning from the handler.

0 commit comments

Comments
 (0)