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.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the session and releases any associated resources.
|
reactor.core.publisher.Mono<Void> |
closeGracefully()
Closes the session and releases any associated resources asynchronously.
|
default reactor.core.publisher.Mono<Void> |
sendNotification(String method)
Sends a notification to the model client or server without parameters.
|
reactor.core.publisher.Mono<Void> |
sendNotification(String method,
Object params)
Sends a notification to the model client or server with parameters.
|
<T> reactor.core.publisher.Mono<T> |
sendRequest(String method,
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(String method, 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<Void> sendNotification(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<Void> sendNotification(String method, 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 - parameters to be sent with the notificationreactor.core.publisher.Mono<Void> closeGracefully()
Mono that completes when the session has been closed.void close()
Copyright © 2025. All rights reserved.