Skip to content

Commit daf7c43

Browse files
committed
Flip stdin and stdout in StreamClientTransport
1 parent 3cdaeec commit daf7c43

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/ModelContextProtocol.Tests/Transport/StreamClientTransport.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ internal sealed class StreamClientTransport : TransportBase, IClientTransport
1111
private readonly JsonSerializerOptions _jsonOptions = McpJsonUtilities.DefaultOptions;
1212
private Task? _readTask;
1313
private CancellationTokenSource _shutdownCts = new CancellationTokenSource();
14-
private readonly TextReader _stdin;
15-
private readonly TextWriter _stdout;
14+
private readonly TextReader _stdout;
15+
private readonly TextWriter _stdin;
1616

17-
public StreamClientTransport(TextReader stdin, TextWriter stdout)
17+
public StreamClientTransport(TextWriter stdin, TextReader stdout)
1818
: base(NullLoggerFactory.Instance)
1919
{
20-
_stdin = stdin;
2120
_stdout = stdout;
21+
_stdin = stdin;
2222
_readTask = Task.Run(() => ReadMessagesAsync(_shutdownCts.Token), CancellationToken.None);
2323
SetConnected(true);
2424
}
@@ -31,13 +31,13 @@ public override async Task SendMessageAsync(IJsonRpcMessage message, Cancellatio
3131
messageWithId.Id.ToString() :
3232
"(no id)";
3333

34-
await _stdout.WriteLineAsync(JsonSerializer.Serialize(message)).ConfigureAwait(false);
35-
await _stdout.FlushAsync(cancellationToken).ConfigureAwait(false);
34+
await _stdin.WriteLineAsync(JsonSerializer.Serialize(message)).ConfigureAwait(false);
35+
await _stdin.FlushAsync(cancellationToken).ConfigureAwait(false);
3636
}
3737

3838
private async Task ReadMessagesAsync(CancellationToken cancellationToken)
3939
{
40-
while (await _stdin.ReadLineAsync(cancellationToken).ConfigureAwait(false) is string line)
40+
while (await _stdout.ReadLineAsync(cancellationToken).ConfigureAwait(false) is string line)
4141
{
4242
if (!string.IsNullOrWhiteSpace(line))
4343
{

0 commit comments

Comments
 (0)