Interface McpServerTransportProviderBase
- All Known Subinterfaces:
McpServerTransportProvider,McpStreamableServerTransportProvider
- All Known Implementing Classes:
HttpServletSseServerTransportProvider,HttpServletStreamableServerTransportProvider,StdioServerTransportProvider
The lifecycle of the provider dictates that it be created first, upon application
startup, and then passed into either
McpServer.sync(McpServerTransportProvider) or
McpServer.async(McpServerTransportProvider). As
a result of the MCP server creation, the provider will be notified of a
McpServerSession.Factory which will be used to handle a 1:1 communication
between a newly connected client and the server. The provider's responsibility is to
create instances of McpServerTransport that the session will utilise during the
session lifetime.
Finally, the McpServerTransports can be closed in bulk when close() or
closeGracefully() are called as part of the normal application shutdown event.
Individual McpServerTransports can also be closed on a per-session basis, where
the McpServerSession.close() or McpServerSession.closeGracefully()
closes the provided transport.
- Author:
- Dariusz Jędrzejczyk
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Immediately closes all the transports with connected clients and releases any associated resources.reactor.core.publisher.Mono<Void>Gracefully closes all the transports with connected clients and releases any associated resources asynchronously.default reactor.core.publisher.Mono<Void>notifyClient(String sessionId, String method, Object params) Sends a notification to a specific client session.reactor.core.publisher.Mono<Void>notifyClients(String method, Object params) Sends a notification to all connected clients.Returns the protocol version supported by this transport provider.
-
Method Details
-
notifyClients
Sends a notification to all connected clients.- Parameters:
method- the name of the notification method to be called on the clientsparams- parameters to be sent with the notification- Returns:
- a Mono that completes when the notification has been broadcast
- See Also:
-
notifyClient
default reactor.core.publisher.Mono<Void> notifyClient(String sessionId, String method, Object params) Sends a notification to a specific client session. Transport providers that support resource subscriptions must override this method to enable per-session notifications. The default implementation returns an error indicating that this operation is not supported.- Parameters:
sessionId- the id of the session to notifymethod- the name of the notification method to be called on the clientparams- parameters to be sent with the notification- Returns:
- a Mono that completes when the notification has been sent, or empty if the session is not found
-
close
default void close()Immediately closes all the transports with connected clients and releases any associated resources. -
closeGracefully
reactor.core.publisher.Mono<Void> closeGracefully()Gracefully closes all the transports with connected clients and releases any associated resources asynchronously.- Returns:
- a
reactor.core.publisher.Mono<Void>that completes when the connections have been closed.
-
protocolVersions
Returns the protocol version supported by this transport provider.- Returns:
- the protocol version as a string
-