connectStdioServer method

  1. @Deprecated('Use stdioChannel and connectServer instead.')
ServerConnection connectStdioServer(
  1. StreamSink<List<int>> stdin,
  2. Stream<List<int>> stdout, {
  3. Sink<String>? protocolLogSink,
  4. void onDone()?,
})

Connect to a new MCP server over stdin and stdout, where these correspond to the stdio streams of the server process (not the client).

If protocolLogSink is provided, all messages sent between the client and server will be forwarded to that Sink as well, with <<< preceding incoming messages and >>> preceding outgoing messages. It is the responsibility of the caller to close this sink.

If onDone is passed, it will be invoked when the connection shuts down.

Implementation

@Deprecated('Use stdioChannel and connectServer instead.')
ServerConnection connectStdioServer(
  StreamSink<List<int>> stdin,
  Stream<List<int>> stdout, {
  Sink<String>? protocolLogSink,
  void Function()? onDone,
}) {
  final channel = stdioChannel(input: stdout, output: stdin);
  final connection = connectServer(channel, protocolLogSink: protocolLogSink);
  if (onDone != null) connection.done.then((_) => onDone());
  return connection;
}