From 841e81016783e389b190a0bef03a3a6a53be8b75 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:00:12 -0800 Subject: [PATCH] Fix StdioServerTransport.DisposeAsync() hang: CancellableStdinStream missing Dispose override (#1276) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> --- .../Server/StdioServerTransport.cs | 10 ++++++++++ .../Transport/StdioServerTransportTests.cs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ModelContextProtocol.Core/Server/StdioServerTransport.cs b/src/ModelContextProtocol.Core/Server/StdioServerTransport.cs index 307c180..f434263 100644 --- a/src/ModelContextProtocol.Core/Server/StdioServerTransport.cs +++ b/src/ModelContextProtocol.Core/Server/StdioServerTransport.cs @@ -59,6 +59,16 @@ public sealed class StdioServerTransport : StreamServerTransport } #endif + protected override void Dispose(bool disposing) + { + if (disposing) + { + stdinStream.Dispose(); + } + + base.Dispose(disposing); + } + // The McpServer shouldn't call flush on the stdin Stream, but it doesn't need to throw just in case. public override void Flush() { } diff --git a/tests/ModelContextProtocol.Tests/Transport/StdioServerTransportTests.cs b/tests/ModelContextProtocol.Tests/Transport/StdioServerTransportTests.cs index 54a1a96..a993b41 100644 --- a/tests/ModelContextProtocol.Tests/Transport/StdioServerTransportTests.cs +++ b/tests/ModelContextProtocol.Tests/Transport/StdioServerTransportTests.cs @@ -24,7 +24,7 @@ public class StdioServerTransportTests : LoggedTest }; } - [Fact(Skip="https://github.com/modelcontextprotocol/csharp-sdk/issues/143")] + [Fact] public async Task Constructor_Should_Initialize_With_Valid_Parameters() { // Act