public class WebRxSseServerTransportProvider extends Object implements McpServerTransportProvider, IMcpHttpServerTransport
Key features:
The transport operates on two main endpoints:
/sse - The SSE endpoint where clients establish their event stream
connection
This implementation uses ConcurrentHashMap to safely manage multiple client
sessions in a thread-safe manner. Each client session is assigned a unique ID and
maintains its own SSE connection.
McpServerTransportProvider,
Handler| Modifier and Type | Class and Description |
|---|---|
static class |
WebRxSseServerTransportProvider.Builder
Builder for creating instances of WebMvcSseServerTransportProvider.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_SSE_ENDPOINT
Default SSE endpoint path as specified by the MCP transport specification.
|
static String |
ENDPOINT_EVENT_TYPE
Event type for sending the message endpoint URI to clients.
|
static String |
MESSAGE_EVENT_TYPE
Event type for JSON-RPC messages sent through the SSE connection.
|
| Constructor and Description |
|---|
WebRxSseServerTransportProvider(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
String baseUrl,
String messageEndpoint,
String sseEndpoint,
McpTransportContextExtractor<org.noear.solon.core.handle.Context> contextExtractor,
Duration keepAliveInterval)
Deprecated.
Use the builder
builder() instead for better configuration
options. |
| Modifier and Type | Method and Description |
|---|---|
static WebRxSseServerTransportProvider.Builder |
builder()
Creates a new Builder instance for configuring and creating instances of
WebMvcSseServerTransportProvider.
|
reactor.core.publisher.Mono<Void> |
closeGracefully()
Initiates a graceful shutdown of the transport.
|
String |
getMcpEndpoint() |
reactor.core.publisher.Mono<Void> |
notifyClients(String method,
Object params)
Broadcasts a notification to all connected clients through their SSE connections.
|
List<String> |
protocolVersions()
Returns the protocol version supported by this transport provider.
|
void |
setSessionFactory(McpServerSession.Factory sessionFactory)
Sets the session factory that will be used to create sessions for new clients.
|
void |
toHttpHandler(org.noear.solon.SolonApp app) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclosepublic static final String MESSAGE_EVENT_TYPE
public static final String ENDPOINT_EVENT_TYPE
public static final String DEFAULT_SSE_ENDPOINT
@Deprecated public WebRxSseServerTransportProvider(com.fasterxml.jackson.databind.ObjectMapper objectMapper, String baseUrl, String messageEndpoint, String sseEndpoint, McpTransportContextExtractor<org.noear.solon.core.handle.Context> contextExtractor, Duration keepAliveInterval)
builder() instead for better configuration
options.objectMapper - The ObjectMapper to use for JSON serialization/deserialization
of messages.baseUrl - The base URL for the message endpoint, used to construct the full
endpoint URL for clients.messageEndpoint - The endpoint URI where clients should send their JSON-RPC
messages via HTTP POST. This endpoint will be communicated to clients through the
SSE connection's initial endpoint event.sseEndpoint - The endpoint URI where clients establish their SSE connections.
* @param keepAliveInterval The interval for sending keep-alive messages toIllegalArgumentException - if any parameter is nullpublic void toHttpHandler(org.noear.solon.SolonApp app)
toHttpHandler in interface IMcpHttpServerTransportpublic String getMcpEndpoint()
getMcpEndpoint in interface IMcpHttpServerTransportpublic List<String> protocolVersions()
McpServerTransportProviderBaseprotocolVersions in interface McpServerTransportProviderBasepublic void setSessionFactory(McpServerSession.Factory sessionFactory)
McpServerTransportProvidersetSessionFactory in interface McpServerTransportProvidersessionFactory - the session factory to be used for initiating client sessionspublic reactor.core.publisher.Mono<Void> notifyClients(String method, Object params)
notifyClients in interface McpServerTransportProviderBasemethod - The method name for the notificationparams - The parameters for the notificationMcpSession#sendNotification(String, Map)public reactor.core.publisher.Mono<Void> closeGracefully()
closeGracefully in interface McpServerTransportProviderBasepublic static WebRxSseServerTransportProvider.Builder builder()
Copyright © 2025. All rights reserved.