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 Type
    Method
    Description
    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.
    The last observed event identifier.
    long
    An internal stream identifier used to distinguish streams while debugging.
  • Method Details

    • lastId

      Optional<String> 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 long stream 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 - a Publisher of tuples (pairs) of an optional identifier associated with a collection of messages
      Returns:
      a flattened Publisher of JSON-RPC messages with the identifier stripped away