diff --git a/src/ModelContextProtocol.Core/Client/StdioClientSessionTransport.cs b/src/ModelContextProtocol.Core/Client/StdioClientSessionTransport.cs index bb446af55..6e9a947ed 100644 --- a/src/ModelContextProtocol.Core/Client/StdioClientSessionTransport.cs +++ b/src/ModelContextProtocol.Core/Client/StdioClientSessionTransport.cs @@ -160,7 +160,10 @@ private async ValueTask WaitForProcessExitAsync() { #if NET using var timeoutCts = new CancellationTokenSource(_options.ShutdownTimeout); - await _process.WaitForExitAsync(timeoutCts.Token).ConfigureAwait(false); + // Keep shutdown bounded even if waiting for redirected output does not observe cancellation. + await _process.WaitForExitAsync(timeoutCts.Token) + .WaitAsync(_options.ShutdownTimeout) + .ConfigureAwait(false); #else if (_process.WaitForExit((int)_options.ShutdownTimeout.TotalMilliseconds)) {