public interface McpSession
The session operates asynchronously using Project Reactor's Mono
type for
non-blocking operations. It supports both request-response patterns and one-way
notifications.
限定符和类型 | 方法和说明 |
---|---|
void |
close()
Closes the session and releases any associated resources.
|
reactor.core.publisher.Mono<java.lang.Void> |
closeGracefully()
Closes the session and releases any associated resources asynchronously.
|
default reactor.core.publisher.Mono<java.lang.Void> |
sendNotification(java.lang.String method)
Sends a notification to the model client or server without parameters.
|
reactor.core.publisher.Mono<java.lang.Void> |
sendNotification(java.lang.String method,
java.util.Map<java.lang.String,java.lang.Object> params)
Sends a notification to the model client or server with parameters.
|
<T> reactor.core.publisher.Mono<T> |
sendRequest(java.lang.String method,
java.lang.Object requestParams,
com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
Sends a request to the model counterparty and expects a response of type T.
|
<T> reactor.core.publisher.Mono<T> sendRequest(java.lang.String method, java.lang.Object requestParams, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
This method handles the request-response pattern where a response is expected from the client or server. The response type is determined by the provided TypeReference.
T
- the type of the expected responsemethod
- the name of the method to be called on the counterpartyrequestParams
- the parameters to be sent with the requesttypeRef
- the TypeReference describing the expected response typedefault reactor.core.publisher.Mono<java.lang.Void> sendNotification(java.lang.String method)
This method implements the notification pattern where no response is expected from the counterparty. It's useful for fire-and-forget scenarios.
method
- the name of the notification method to be called on the serverreactor.core.publisher.Mono<java.lang.Void> sendNotification(java.lang.String method, java.util.Map<java.lang.String,java.lang.Object> params)
Similar to sendNotification(String)
but allows sending additional
parameters with the notification.
method
- the name of the notification method to be sent to the counterpartyparams
- a map of parameters to be sent with the notificationreactor.core.publisher.Mono<java.lang.Void> closeGracefully()
Mono
that completes when the session has been closed.void close()