Skip to content

Commit 841e810

Browse files
Copilotstephentoub
andauthored
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>
1 parent 186cb93 commit 841e810

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ModelContextProtocol.Core/Server/StdioServerTransport.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken
5959
}
6060
#endif
6161

62+
protected override void Dispose(bool disposing)
63+
{
64+
if (disposing)
65+
{
66+
stdinStream.Dispose();
67+
}
68+
69+
base.Dispose(disposing);
70+
}
71+
6272
// The McpServer shouldn't call flush on the stdin Stream, but it doesn't need to throw just in case.
6373
public override void Flush() { }
6474

tests/ModelContextProtocol.Tests/Transport/StdioServerTransportTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public StdioServerTransportTests(ITestOutputHelper testOutputHelper)
2424
};
2525
}
2626

27-
[Fact(Skip="https://github.com/modelcontextprotocol/csharp-sdk/issues/143")]
27+
[Fact]
2828
public async Task Constructor_Should_Initialize_With_Valid_Parameters()
2929
{
3030
// Act

0 commit comments

Comments
 (0)