This is because the read loop in the core transport abstraction uses TextWriter:
|
if (await _serverOutput.ReadLineAsync(cancellationToken).ConfigureAwait(false) is not string line) |
|
var line = await _inputReader.ReadLineAsync(shutdownToken).ConfigureAwait(false); |
Which in netstandard2.0 is not cancellable and requires a polyfill that does not properly honor the cancellation token:
|
public static Task<string> ReadLineAsync(this TextReader reader, CancellationToken cancellationToken) |
|
{ |
|
if (cancellationToken.IsCancellationRequested) |
|
{ |
|
return Task.FromCanceled<string>(cancellationToken); |
|
} |
|
|
|
return reader.ReadLineAsync(); |
|
} |
This is because the read loop in the core transport abstraction uses
TextWriter:csharp-sdk/src/ModelContextProtocol/Protocol/Transport/StreamClientSessionTransport.cs
Line 99 in 08f9cdb
csharp-sdk/src/ModelContextProtocol/Protocol/Transport/StreamServerTransport.cs
Line 103 in 08f9cdb
Which in
netstandard2.0is not cancellable and requires a polyfill that does not properly honor the cancellation token:csharp-sdk/src/Common/Polyfills/System/IO/TextReaderExtensions.cs
Lines 5 to 13 in 08f9cdb