Skip to content

Conversation

atomAltera
Copy link

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.

Enable MCP communication over arbitrary I/O streams beyond stdin/stdout, supporting custom transport implementations.
@findleyr
Copy link
Contributor

We have a CommandTransport for communicating with a server started via an exec.Cmd. What's the use case for separating the transport from the command lifecycle?

In other words: why do you need to start the process separately from connecting the server?

@atomAltera
Copy link
Author

atomAltera commented Aug 28, 2025

I have the following case: I run a command in a Docker container using the Docker Go package. Its ContainerAttach call returns a bufio.Reader for reading from stdout/stderr and a net.Conn for writing to stdin. Since I couldn’t find a suitable transport implementation, I decided to add a new one.

The reason I launch MCP servers in a Docker container is that my environment already uses Docker, and I prefer using ready-made Docker images instead of installing additional tools like Node.js or Python.

@findleyr
Copy link
Contributor

Understood, I support this change.

Could you please file a proposal issue describing your use case (e.g. "Proposal: add IOTransport, a generalized transport over a Reader/Writer").

We need to keep the proposal open for a week for feedback, but can still merge this CL as long as it's not released.

// 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants