Skip to content

Commit d3a54d7

Browse files
committed
Address PR feedback
1 parent f675320 commit d3a54d7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/ModelContextProtocol/Protocol/Transport/StdioServerTransport.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,19 @@ public override Task<int> ReadAsync(byte[] buffer, int offset, int count, Cancel
8787

8888
#if NET
8989
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
90-
=> new(stdinStream.ReadAsync(buffer, cancellationToken).AsTask().WaitAsync(cancellationToken));
90+
{
91+
ValueTask<int> vt = stdinStream.ReadAsync(buffer, cancellationToken);
92+
return vt.IsCompletedSuccessfully ? vt : new(vt.AsTask().WaitAsync(cancellationToken));
93+
}
9194
#endif
9295

96+
// The McpServer shouldn't call flush on the stdin Stream, but it doesn't need to throw just in case.
97+
public override void Flush() { }
98+
9399
public override long Length => throw new NotSupportedException();
94100

95101
public override long Position { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
96102

97-
public override void Flush() => throw new NotSupportedException();
98103
public override int Read(byte[] buffer, int offset, int count) => throw new NotSupportedException();
99104
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
100105

0 commit comments

Comments
 (0)