Interface MCPTransport
public interface MCPTransport
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.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the transport and releases any underlying resources.voidopen()Opens the transport, blocking until it is ready to exchange messages.Reads the next complete JSON-RPC message.voidwriteMessage(String message) Writes a complete JSON-RPC message and flushes it.
-
Method Details
-
open
Opens the transport, blocking until it is ready to exchange messages. For a socket transport this waits for the first client connection.- Throws:
IOException
-
readMessage
Reads the next complete JSON-RPC message. Returns null at end of stream.- Throws:
IOException
-
writeMessage
Writes a complete JSON-RPC message and flushes it. The value must not contain embedded newlines.- Throws:
IOException
-
close
void close()Closes the transport and releases any underlying resources.
-