From e6a591bf5119e3303123d3afe1270ffb26043978 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Mon, 7 Apr 2025 20:50:25 -0700 Subject: [PATCH 1/6] Fix StdioServerTransport.DisposeAsync hang - It's not just Unix, it's all platforms that can hang - Windows doesn't hang on Ctrl-C because that triggers the end of the Stream, but that doesn't help in IHostApplicationLifetime.StopAsync() scenarios https://github.com/dotnet/runtime/blob/4e9627e311806330be72b7f7d3660be699878ebd/src/libraries/System.Console/src/System/ConsolePal.Unix.ConsoleStream.cs#L13 https://github.com/dotnet/runtime/blob/4e9627e311806330be72b7f7d3660be699878ebd/src/libraries/System.Console/src/System/ConsolePal.Windows.cs#L1149 --- .../TestServerWithHosting.csproj | 2 +- .../Transport/StdioServerTransport.cs | 30 ++++++++++++- .../ModelContextProtocol.Tests.csproj | 7 +++ .../StdioServerIntegrationTests.cs | 44 +++++++++++++++++++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 tests/ModelContextProtocol.Tests/StdioServerIntegrationTests.cs diff --git a/samples/TestServerWithHosting/TestServerWithHosting.csproj b/samples/TestServerWithHosting/TestServerWithHosting.csproj index 0f3918d9..d12277e2 100644 --- a/samples/TestServerWithHosting/TestServerWithHosting.csproj +++ b/samples/TestServerWithHosting/TestServerWithHosting.csproj @@ -2,7 +2,7 @@ Exe - net9.0 + net9.0;net8.0 enable enable