Add IOTransport for separate reader/writer (#376)
This commit adds ability to create a mcp.Transport with specific io.ReadCloser and io.WriteCloser. Ii is needed when you need create an mcp.Client for mcp.Server launched in separate process and you need to communicate with it with it's own stdin/stdout.
This commit is contained in:
parent
069aae16df
commit
49047aebe8
1 changed files with 12 additions and 0 deletions
|
|
@ -93,6 +93,18 @@ func (*StdioTransport) Connect(context.Context) (Connection, error) {
|
|||
return newIOConn(rwc{os.Stdin, os.Stdout}), nil
|
||||
}
|
||||
|
||||
// An IOTransport is a [Transport] that communicates over separate
|
||||
// io.ReadCloser and io.WriteCloser using newline-delimited JSON.
|
||||
type IOTransport struct {
|
||||
Reader io.ReadCloser
|
||||
Writer io.WriteCloser
|
||||
}
|
||||
|
||||
// Connect implements the [Transport] interface.
|
||||
func (t *IOTransport) Connect(context.Context) (Connection, error) {
|
||||
return newIOConn(rwc{t.Reader, t.Writer}), nil
|
||||
}
|
||||
|
||||
// An InMemoryTransport is a [Transport] that communicates over an in-memory
|
||||
// network connection, using newline-delimited JSON.
|
||||
type InMemoryTransport struct {
|
||||
|
|
|
|||
Loading…
Reference in a new issue