Package io.modelcontextprotocol.spec
Interface McpTransportStream<CONNECTION>
- Type Parameters:
CONNECTION- the resource on which the stream is being served and consumed via this mechanism
- All Known Implementing Classes:
DefaultMcpTransportStream
public interface McpTransportStream<CONNECTION>
A representation of a stream at the transport layer of the MCP protocol. In particular,
it is currently used in the Streamable HTTP implementation to potentially be able to
resume a broken connection from where it left off by optionally keeping track of
attached SSE event ids.
- Author:
- Dariusz Jędrzejczyk
-
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<McpSchema.JSONRPCMessage>consumeSseStream(org.reactivestreams.Publisher<reactor.util.function.Tuple2<Optional<String>, Iterable<McpSchema.JSONRPCMessage>>> eventStream) Allows keeping track of the transport stream of events (currently an SSE stream from Streamable HTTP specification) and enable resumability and reconnects in case of stream errors.lastId()The last observed event identifier.longstreamId()An internal stream identifier used to distinguish streams while debugging.
-
Method Details
-
lastId
The last observed event identifier.- Returns:
- if not empty, contains the most recent event that was consumed
-
streamId
long streamId()An internal stream identifier used to distinguish streams while debugging.- Returns:
- a
longstream identifier value
-
consumeSseStream
org.reactivestreams.Publisher<McpSchema.JSONRPCMessage> consumeSseStream(org.reactivestreams.Publisher<reactor.util.function.Tuple2<Optional<String>, Iterable<McpSchema.JSONRPCMessage>>> eventStream) Allows keeping track of the transport stream of events (currently an SSE stream from Streamable HTTP specification) and enable resumability and reconnects in case of stream errors.- Parameters:
eventStream- aPublisherof tuples (pairs) of an optional identifier associated with a collection of messages- Returns:
- a flattened
PublisherofJSON-RPC messageswith the identifier stripped away
-