diff --git a/mcp/transport.go b/mcp/transport.go index 111887b4..f2f93f4b 100644 --- a/mcp/transport.go +++ b/mcp/transport.go @@ -90,9 +90,16 @@ type StdioTransport struct{} // Connect implements the [Transport] interface. func (*StdioTransport) Connect(context.Context) (Connection, error) { - return newIOConn(rwc{os.Stdin, os.Stdout}), nil + return newIOConn(rwc{os.Stdin, nopCloserWriter{os.Stdout}}), nil } +// nopCloserWriter is an io.WriteCloser with a trivial Close method. +type nopCloserWriter struct { + io.Writer +} + +func (nopCloserWriter) Close() error { return nil } + // An IOTransport is a [Transport] that communicates over separate // io.ReadCloser and io.WriteCloser using newline-delimited JSON. type IOTransport struct { @@ -107,6 +114,9 @@ func (t *IOTransport) Connect(context.Context) (Connection, error) { // An InMemoryTransport is a [Transport] that communicates over an in-memory // network connection, using newline-delimited JSON. +// +// InMemoryTransports should be constructed using [NewInMemoryTransports], +// which returns two transports connected to each other. type InMemoryTransport struct { rwc io.ReadWriteCloser }