public interface McpStreamableServerTransportProvider extends McpServerTransportProviderBase
The lifecycle of the provider dictates that it be created first, upon application
startup, and then passed into either
McpServer.sync(McpStreamableServerTransportProvider)
or
McpServer.async(McpStreamableServerTransportProvider)
.
As a result of the MCP server creation, the provider will be notified of a
McpStreamableServerSession.Factory
which will be used to handle a 1:1
communication between a newly connected client and the server using a session concept.
The provider's responsibility is to create instances of
McpStreamableServerTransport
that the session will utilise during the session
lifetime.
Finally, the McpStreamableServerTransport
s can be closed in bulk when
close()
or closeGracefully()
are called as part of the normal
application shutdown event. Individual McpStreamableServerTransport
s can also
be closed on a per-session basis, where the McpServerSession.close()
or
McpServerSession.closeGracefully()
closes the provided transport.
限定符和类型 | 方法和说明 |
---|---|
default void |
close()
Immediately closes all the transports with connected clients and releases any
associated resources.
|
reactor.core.publisher.Mono<java.lang.Void> |
closeGracefully()
Gracefully closes all the transports with connected clients and releases any
associated resources asynchronously.
|
reactor.core.publisher.Mono<java.lang.Void> |
notifyClients(java.lang.String method,
java.lang.Object params)
Sends a notification to all connected clients.
|
void |
setSessionFactory(McpStreamableServerSession.Factory sessionFactory)
Sets the session factory that will be used to create sessions for new clients.
|
protocolVersions
void setSessionFactory(McpStreamableServerSession.Factory sessionFactory)
sessionFactory
- the session factory to be used for initiating client sessionsreactor.core.publisher.Mono<java.lang.Void> notifyClients(java.lang.String method, java.lang.Object params)
notifyClients
在接口中 McpServerTransportProviderBase
method
- the name of the notification method to be called on the clientsparams
- parameters to be sent with the notificationMcpSession#sendNotification(String, Map)
default void close()
close
在接口中 McpServerTransportProviderBase
reactor.core.publisher.Mono<java.lang.Void> closeGracefully()
closeGracefully
在接口中 McpServerTransportProviderBase
Mono
that completes when the connections have been closed.