Interface McpTransportSession<CONNECTION>

Type Parameters:
CONNECTION - the resource representing the connection that the transport manages.
All Known Implementing Classes:
DefaultMcpTransportSession

public interface McpTransportSession<CONNECTION>
An abstraction of the session as perceived from the MCP transport layer. Not to be confused with the McpSession type that operates at the level of the JSON-RPC communication protocol and matches asynchronous responses with previously issued requests.
Author:
Dariusz Jędrzejczyk
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a resource that this transport session can monitor and dismiss when needed.
    void
    Close and clear the monitored resources.
    org.reactivestreams.Publisher<Void>
    Close and clear the monitored resources in a graceful manner.
    boolean
    Stateful operation that flips the un-initialized state to initialized if this is the first call.
    void
    Called when the resource is terminating by itself and the transport session does not need to track it anymore.
    In case of stateful MCP servers, the value is present and contains the String identifier for the transport-level session.
  • Method Details

    • sessionId

      Optional<String> sessionId()
      In case of stateful MCP servers, the value is present and contains the String identifier for the transport-level session.
      Returns:
      optional session id
    • markInitialized

      boolean markInitialized(String sessionId)
      Stateful operation that flips the un-initialized state to initialized if this is the first call. If the transport provides a session id for the communication, argument should not be null to record the current identifier.
      Parameters:
      sessionId - session identifier as provided by the server
      Returns:
      if successful, this method returns true and means that a post-initialization step can be performed
    • addConnection

      void addConnection(CONNECTION connection)
      Adds a resource that this transport session can monitor and dismiss when needed.
      Parameters:
      connection - the managed resource
    • removeConnection

      void removeConnection(CONNECTION connection)
      Called when the resource is terminating by itself and the transport session does not need to track it anymore.
      Parameters:
      connection - the resource to remove from the monitored collection
    • close

      void close()
      Close and clear the monitored resources. Potentially asynchronous.
    • closeGracefully

      org.reactivestreams.Publisher<Void> closeGracefully()
      Close and clear the monitored resources in a graceful manner.
      Returns:
      completes once all resources have been dismissed