public class McpClientSession extends java.lang.Object implements McpSession
The session manages:
限定符和类型 | 类和说明 |
---|---|
static class |
McpClientSession.MethodNotFoundError |
static interface |
McpClientSession.NotificationHandler
Functional interface for handling incoming JSON-RPC notifications.
|
static interface |
McpClientSession.RequestHandler<T>
Functional interface for handling incoming JSON-RPC requests.
|
构造器和说明 |
---|
McpClientSession(java.time.Duration requestTimeout,
McpTransport transport,
java.util.Map<java.lang.String,McpClientSession.RequestHandler<?>> requestHandlers,
java.util.Map<java.lang.String,McpClientSession.NotificationHandler> notificationHandlers)
Creates a new McpClientSession with the specified configuration and handlers.
|
限定符和类型 | 方法和说明 |
---|---|
void |
close()
Closes the session immediately, potentially interrupting pending operations.
|
reactor.core.publisher.Mono<java.lang.Void> |
closeGracefully()
Closes the session gracefully, allowing pending operations to complete.
|
static McpClientSession.MethodNotFoundError |
getMethodNotFoundError(java.lang.String method) |
reactor.core.publisher.Mono<java.lang.Void> |
sendNotification(java.lang.String method,
java.util.Map<java.lang.String,java.lang.Object> params)
Sends a JSON-RPC notification.
|
<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 JSON-RPC request and returns the response.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
sendNotification
public McpClientSession(java.time.Duration requestTimeout, McpTransport transport, java.util.Map<java.lang.String,McpClientSession.RequestHandler<?>> requestHandlers, java.util.Map<java.lang.String,McpClientSession.NotificationHandler> notificationHandlers)
requestTimeout
- Duration to wait for responsestransport
- Transport implementation for message exchangerequestHandlers
- Map of method names to request handlersnotificationHandlers
- Map of method names to notification handlerspublic static McpClientSession.MethodNotFoundError getMethodNotFoundError(java.lang.String method)
public <T> reactor.core.publisher.Mono<T> sendRequest(java.lang.String method, java.lang.Object requestParams, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
sendRequest
在接口中 McpSession
T
- The expected response typemethod
- The method name to callrequestParams
- The request parameterstypeRef
- Type reference for response deserializationpublic reactor.core.publisher.Mono<java.lang.Void> sendNotification(java.lang.String method, java.util.Map<java.lang.String,java.lang.Object> params)
sendNotification
在接口中 McpSession
method
- The method name for the notificationparams
- The notification parameterspublic reactor.core.publisher.Mono<java.lang.Void> closeGracefully()
closeGracefully
在接口中 McpSession
public void close()
close
在接口中 McpSession