This is because the read loop in the core transport abstraction uses TextWriter:
| if(await_serverOutput.ReadLineAsync(cancellationToken).ConfigureAwait(false)is not stringline) |
| varline=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:
| publicstaticTask<string>ReadLineAsync(thisTextReaderreader,CancellationTokencancellationToken) |
| { |
| if(cancellationToken.IsCancellationRequested) |
| { |
| returnTask.FromCanceled<string>(cancellationToken); |
| } |
| |
| returnreader.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