Package io.modelcontextprotocol.spec
Class ClosedMcpTransportSession<CONNECTION>
java.lang.Object
io.modelcontextprotocol.spec.ClosedMcpTransportSession<CONNECTION>
- Type Parameters:
CONNECTION- the resource representing the connection that the transport manages.
- All Implemented Interfaces:
McpTransportSession<CONNECTION>
public class ClosedMcpTransportSession<CONNECTION>
extends Object
implements McpTransportSession<CONNECTION>
Represents a closed MCP session, which may not be reused. All calls will throw a
McpTransportSessionClosedException.- Author:
- Daniel Garnier-Moiroux
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnection(CONNECTION connection) Adds a resource that this transport session can monitor and dismiss when needed.voidclose()Close and clear the monitored resources.org.reactivestreams.Publisher<Void>Close and clear the monitored resources in a graceful manner.booleanmarkInitialized(String sessionId) Stateful operation that flips the un-initialized state to initialized if this is the first call.voidremoveConnection(CONNECTION 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.
-
Constructor Details
-
ClosedMcpTransportSession
-
-
Method Details
-
sessionId
Description copied from interface:McpTransportSessionIn case of stateful MCP servers, the value is present and contains the String identifier for the transport-level session.- Specified by:
sessionIdin interfaceMcpTransportSession<CONNECTION>- Returns:
- optional session id
-
markInitialized
Description copied from interface:McpTransportSessionStateful 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:
markInitializedin interfaceMcpTransportSession<CONNECTION>- Parameters:
sessionId- session identifier as provided by the server- Returns:
- if successful, this method returns
trueand means that a post-initialization step can be performed
-
addConnection
Description copied from interface:McpTransportSessionAdds a resource that this transport session can monitor and dismiss when needed.- Specified by:
addConnectionin interfaceMcpTransportSession<CONNECTION>- Parameters:
connection- the managed resource
-
removeConnection
Description copied from interface:McpTransportSessionCalled when the resource is terminating by itself and the transport session does not need to track it anymore.- Specified by:
removeConnectionin interfaceMcpTransportSession<CONNECTION>- Parameters:
connection- the resource to remove from the monitored collection
-
close
public void close()Description copied from interface:McpTransportSessionClose and clear the monitored resources. Potentially asynchronous.- Specified by:
closein interfaceMcpTransportSession<CONNECTION>
-
closeGracefully
Description copied from interface:McpTransportSessionClose and clear the monitored resources in a graceful manner.- Specified by:
closeGracefullyin interfaceMcpTransportSession<CONNECTION>- Returns:
- completes once all resources have been dismissed
-