public class DefaultMcpTransportSession extends Object implements McpTransportSession<reactor.core.Disposable>
McpTransportSession which manages the open
connections using tye Disposable type and allows to perform clean up using the
Disposable.dispose() method.| Constructor and Description |
|---|
DefaultMcpTransportSession(Function<String,org.reactivestreams.Publisher<Void>> onClose) |
| Modifier and Type | Method and Description |
|---|---|
void |
addConnection(reactor.core.Disposable connection)
Adds a resource that this transport session can monitor and dismiss when needed.
|
void |
close()
Close and clear the monitored resources.
|
reactor.core.publisher.Mono<Void> |
closeGracefully()
Close and clear the monitored resources in a graceful manner.
|
boolean |
markInitialized(String sessionId)
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.
|
Optional<String> |
sessionId()
In case of stateful MCP servers, the value is present and contains the String
identifier for the transport-level session.
|
public Optional<String> sessionId()
McpTransportSessionsessionId in interface McpTransportSession<reactor.core.Disposable>public boolean markInitialized(String sessionId)
McpTransportSessionmarkInitialized in interface McpTransportSession<reactor.core.Disposable>sessionId - session identifier as provided by the servertrue and means that a
post-initialization step can be performedpublic void addConnection(reactor.core.Disposable connection)
McpTransportSessionaddConnection in interface McpTransportSession<reactor.core.Disposable>connection - the managed resourcepublic void removeConnection(reactor.core.Disposable connection)
McpTransportSessionremoveConnection in interface McpTransportSession<reactor.core.Disposable>connection - the resource to remove from the monitored collectionpublic void close()
McpTransportSessionclose in interface McpTransportSession<reactor.core.Disposable>public reactor.core.publisher.Mono<Void> closeGracefully()
McpTransportSessioncloseGracefully in interface McpTransportSession<reactor.core.Disposable>Copyright © 2025. All rights reserved.