public interface MCPTransport
Known subtypesMCPLoopbackSocketTransport
A bidirectional line delimited transport for MCP JSON-RPC messages.
The MCP stdio transport frames messages as newline delimited JSON, one complete JSON-RPC object per line with no embedded newlines. Implementations therefore exchange whole message strings and never deal with partial frames.
Methods
public abstract void open()
throws IOException | Opens the transport, blocking until it is ready to exchange messages. |
public abstract String readMessage()
throws IOException | Reads the next complete JSON-RPC message. |
public abstract void writeMessage(String message)
throws IOException | Writes a complete JSON-RPC message and flushes it. |
public abstract void close() | Closes the transport and releases any underlying resources. |
Method details
open
public abstract void open()
throws IOExceptionOpens the transport, blocking until it is ready to exchange messages. For a
socket transport this waits for the first client connection.
Throws
readMessage
public abstract String readMessage()
throws IOExceptionReads the next complete JSON-RPC message. Returns null at end of stream.
Throws
writeMessage
public abstract void writeMessage(String message)
throws IOExceptionWrites a complete JSON-RPC message and flushes it. The value must not contain
embedded newlines.
Throws
close
public abstract void close()Closes the transport and releases any underlying resources.