Class ClosedMcpTransportSession

java.lang.Object
io.modelcontextprotocol.spec.ClosedMcpTransportSession
All Implemented Interfaces:
McpTransportSession<reactor.core.Disposable>

public final class ClosedMcpTransportSession extends Object implements McpTransportSession<reactor.core.Disposable>
Represents a closed MCP session, which may not be reused.
Author:
Daniel Garnier-Moiroux, Dariusz Jędrzejczyk
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addConnection(reactor.core.Disposable connection)
    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
    removeConnection(reactor.core.Disposable connection)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • sessionId

      public Optional<String> sessionId()
      Description copied from interface: McpTransportSession
      In case of stateful MCP servers, the value is present and contains the String identifier for the transport-level session.
      Specified by:
      sessionId in interface McpTransportSession<reactor.core.Disposable>
      Returns:
      optional session id
    • markInitialized

      public boolean markInitialized(String sessionId)
      Description copied from interface: McpTransportSession
      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.
      Specified by:
      markInitialized in interface McpTransportSession<reactor.core.Disposable>
      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

      public void addConnection(reactor.core.Disposable connection)
      Description copied from interface: McpTransportSession
      Adds a resource that this transport session can monitor and dismiss when needed.
      Specified by:
      addConnection in interface McpTransportSession<reactor.core.Disposable>
      Parameters:
      connection - the managed resource
    • removeConnection

      public void removeConnection(reactor.core.Disposable connection)
      Description copied from interface: McpTransportSession
      Called when the resource is terminating by itself and the transport session does not need to track it anymore.
      Specified by:
      removeConnection in interface McpTransportSession<reactor.core.Disposable>
      Parameters:
      connection - the resource to remove from the monitored collection
    • close

      public void close()
      Description copied from interface: McpTransportSession
      Close and clear the monitored resources. Potentially asynchronous.
      Specified by:
      close in interface McpTransportSession<reactor.core.Disposable>
    • closeGracefully

      public org.reactivestreams.Publisher<Void> closeGracefully()
      Description copied from interface: McpTransportSession
      Close and clear the monitored resources in a graceful manner.
      Specified by:
      closeGracefully in interface McpTransportSession<reactor.core.Disposable>
      Returns:
      completes once all resources have been dismissed