public class StatelessMcpSession extends java.lang.Object implements McpSession
构造器和说明 |
---|
StatelessMcpSession(McpTransport transport) |
限定符和类型 | 方法和说明 |
---|---|
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.
|
java.lang.String |
getId()
Retrieve the session id.
|
reactor.core.publisher.Mono<java.lang.Void> |
handle(McpSchema.JSONRPCMessage message)
Called by the
McpServerTransportProvider once the session is determined. |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
sendNotification
public StatelessMcpSession(McpTransport transport)
public java.lang.String getId()
McpSession
getId
在接口中 McpSession
public reactor.core.publisher.Mono<java.lang.Void> handle(McpSchema.JSONRPCMessage message)
McpSession
McpServerTransportProvider
once the session is determined.
The purpose of this method is to dispatch the message to an appropriate handler as
specified by the MCP server implementation
(McpAsyncServer
or
McpSyncServer
) via
McpServerSession.Factory
that the server creates.handle
在接口中 McpSession
message
- the incoming JSON-RPC messagepublic <T> reactor.core.publisher.Mono<T> sendRequest(java.lang.String method, java.lang.Object requestParams, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
McpSession
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.
sendRequest
在接口中 McpSession
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 typepublic reactor.core.publisher.Mono<java.lang.Void> sendNotification(java.lang.String method, java.util.Map<java.lang.String,java.lang.Object> params)
McpSession
Similar to McpSession.sendNotification(String)
but allows sending additional
parameters with the notification.
sendNotification
在接口中 McpSession
method
- the name of the notification method to be sent to the counterpartyparams
- a map of parameters to be sent with the notificationpublic reactor.core.publisher.Mono<java.lang.Void> closeGracefully()
McpSession
closeGracefully
在接口中 McpSession
Mono
that completes when the session has been closed.public void close()
McpSession
close
在接口中 McpSession