Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions mcp/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,29 @@ func NewStdioTransport() *StdioTransport {
return &StdioTransport{}
}

// An IOTransport is a [Transport] that communicates over separate
// io.ReadCloser and io.WriteCloser using newline-delimited JSON.
type IOTransport struct {
reader io.ReadCloser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just make these exported fields, so that the transport is extensible, and remove NewIOTransport.

See also #286

writer io.WriteCloser
}

// Connect implements the [Transport] interface.
func (t *IOTransport) Connect(context.Context) (Connection, error) {
return newIOConn(rwc{t.reader, t.writer}), nil
}

// NewIOTransport constructs a transport that communicates over
// io.ReadCloser and io.WriteCloser.
//
//go:fix inline
func NewIOTransport(reader io.ReadCloser, writer io.WriteCloser) *IOTransport {
return &IOTransport{
reader: reader,
writer: writer,
}
}

// An InMemoryTransport is a [Transport] that communicates over an in-memory
// network connection, using newline-delimited JSON.
type InMemoryTransport struct {
Expand Down