public class McpStreamableServerSession extends java.lang.Object implements McpLoggableSession
限定符和类型 | 类和说明 |
---|---|
static interface |
McpStreamableServerSession.Factory
Factory for new Streamable HTTP MCP sessions.
|
static interface |
McpStreamableServerSession.InitRequestHandler
Request handler for the initialization request.
|
static class |
McpStreamableServerSession.McpStreamableServerSessionInit
Composite holding the
McpStreamableServerSession and the initialization
result |
class |
McpStreamableServerSession.McpStreamableServerSessionStream
An individual SSE stream within a Streamable HTTP context.
|
static class |
McpStreamableServerSession.MethodNotFoundError |
构造器和说明 |
---|
McpStreamableServerSession(java.lang.String id,
McpSchema.ClientCapabilities clientCapabilities,
McpSchema.Implementation clientInfo,
java.time.Duration requestTimeout,
java.util.Map<java.lang.String,McpRequestHandler<?>> requestHandlers,
java.util.Map<java.lang.String,McpNotificationHandler> notificationHandlers)
Create an instance of the streamable session.
|
限定符和类型 | 方法和说明 |
---|---|
reactor.core.publisher.Mono<java.lang.Void> |
accept(McpSchema.JSONRPCNotification notification)
Handle the MCP notification.
|
reactor.core.publisher.Mono<java.lang.Void> |
accept(McpSchema.JSONRPCResponse response)
Handle the MCP response.
|
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.
|
reactor.core.publisher.Mono<java.lang.Void> |
delete() |
java.lang.String |
getId()
Return the Session ID.
|
boolean |
isNotificationForLevelAllowed(McpSchema.LoggingLevel loggingLevel)
Allows checking whether a particular logging level is allowed.
|
McpStreamableServerSession.McpStreamableServerSessionStream |
listeningStream(McpStreamableServerTransport transport)
Create a listening stream (the generic HTTP GET request without Last-Event-ID
header).
|
reactor.core.publisher.Flux<McpSchema.JSONRPCMessage> |
replay(java.lang.Object lastEventId) |
reactor.core.publisher.Mono<java.lang.Void> |
responseStream(McpSchema.JSONRPCRequest jsonrpcRequest,
McpStreamableServerTransport transport)
Provide the SSE stream of MCP messages finalized with a Response.
|
reactor.core.publisher.Mono<java.lang.Void> |
sendNotification(java.lang.String method,
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.
|
void |
setMinLoggingLevel(McpSchema.LoggingLevel minLoggingLevel)
Set the minimum logging level for the client.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
sendNotification
public McpStreamableServerSession(java.lang.String id, McpSchema.ClientCapabilities clientCapabilities, McpSchema.Implementation clientInfo, java.time.Duration requestTimeout, java.util.Map<java.lang.String,McpRequestHandler<?>> requestHandlers, java.util.Map<java.lang.String,McpNotificationHandler> notificationHandlers)
id
- session IDclientCapabilities
- client capabilitiesclientInfo
- client inforequestTimeout
- timeout to use for requestsrequestHandlers
- the map of MCP request handlers keyed by method namenotificationHandlers
- the map of MCP notification handlers keyed by method
namepublic void setMinLoggingLevel(McpSchema.LoggingLevel minLoggingLevel)
McpLoggableSession
setMinLoggingLevel
在接口中 McpLoggableSession
minLoggingLevel
- The minimum logging levelpublic boolean isNotificationForLevelAllowed(McpSchema.LoggingLevel loggingLevel)
McpLoggableSession
isNotificationForLevelAllowed
在接口中 McpLoggableSession
loggingLevel
- the level to checkpublic java.lang.String getId()
public <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.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
- parameters to be sent with the notificationpublic reactor.core.publisher.Mono<java.lang.Void> delete()
public McpStreamableServerSession.McpStreamableServerSessionStream listeningStream(McpStreamableServerTransport transport)
transport
- The dedicated SSE transport streampublic reactor.core.publisher.Flux<McpSchema.JSONRPCMessage> replay(java.lang.Object lastEventId)
public reactor.core.publisher.Mono<java.lang.Void> responseStream(McpSchema.JSONRPCRequest jsonrpcRequest, McpStreamableServerTransport transport)
jsonrpcRequest
- the MCP request triggering the stream creationtransport
- the SSE transport stream to send messages topublic reactor.core.publisher.Mono<java.lang.Void> accept(McpSchema.JSONRPCNotification notification)
notification
- MCP notificationpublic reactor.core.publisher.Mono<java.lang.Void> accept(McpSchema.JSONRPCResponse response)
response
- MCP response to the server-initiated requestpublic 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